Skip to content

Faster parsing: reduce String usage, list-based input rows.#15681

Merged
asdf2014 merged 8 commits intoapache:masterfrom
gianm:faster-parsers
Jan 18, 2024
Merged

Faster parsing: reduce String usage, list-based input rows.#15681
asdf2014 merged 8 commits intoapache:masterfrom
gianm:faster-parsers

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Jan 14, 2024

Three changes:

  1. Reworked FastLineIterator to optionally avoid generating Strings
    entirely, and reduce copying somewhat. Benefits the line-oriented
    JSON, CSV, delimited (TSV), and regex formats.

  2. In the delimited (TSV) format, when the delimiter is a single byte,
    split on UTF-8 bytes directly.

  3. In CSV and delimited (TSV) formats, use list-based input rows when
    the column list is provided upfront by the user.

Benchmarks below. Findings:

  • JsonLineReaderBenchmark only benefits from change (1), and got a 15% improvement.
  • DelimitedInputFormatBenchmark with fromHeader: true benefits from (1) and (2), and got a 22% improvement.
  • DelimitedInputFormatBenchmark with fromHeader: false benefits from all three changes, and got a 30% improvement.
Benchmark                               (fromHeader)  Mode  Cnt     Score    Error  Units
DelimitedInputFormatBenchmark.baseline         false  avgt    5  1912.257 ± 39.227  us/op [master]
DelimitedInputFormatBenchmark.baseline          true  avgt    5  1953.915 ± 44.787  us/op [master]
JsonLineReaderBenchmark.baseline                      avgt    5  2055.294 ± 28.688  us/op [master]

DelimitedInputFormatBenchmark.baseline         false  avgt    5  1321.142 ± 10.115  us/op [patch]
DelimitedInputFormatBenchmark.baseline          true  avgt    5  1506.412 ± 15.892  us/op [patch]
JsonLineReaderBenchmark.baseline                      avgt    5  1734.426 ± 38.518  us/op [patch]

Three changes:

1) Reworked FastLineIterator to optionally avoid generating Strings
   entirely, and reduce copying somewhat. Benefits the line-oriented
   JSON, CSV, delimited (TSV), and regex formats.

2) In the delimited (TSV) format, when the delimiter is a single byte,
   split on UTF-8 bytes directly.

3) In CSV and delimited (TSV) formats, use list-based input rows when
   the column list is provided upfront by the user.
@github-actions github-actions Bot added Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Jan 14, 2024
* given a particular {@link InputRowSchema}. Note that {@link RowAdapters#standardRow()} always works, but the
* one returned by this method may be more performant.
*/
default RowAdapter<InputRow> createRowAdapter(InputRowSchema inputRowSchema)

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'inputRowSchema' is never used.
@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Jan 16, 2024

The only failure is IncrementalIndexIngestionTest.testMultithreadAddFactsUsingExpressionAndJavaScript, which is flaky now, and fixed by #15697. (By removing the test, as it's testing something we don't need.)

Copy link
Copy Markdown
Member

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asdf2014 asdf2014 merged commit d3d0c1c into apache:master Jan 18, 2024
@adarshsanjeev adarshsanjeev added this to the 30.0.0 milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants