Skip to content

Add binary format for GeoNames indexing benchmark - #578

Open
neoremind wants to merge 1 commit into
mikemccand:mainfrom
neoremind:geo-binary
Open

Add binary format for GeoNames indexing benchmark#578
neoremind wants to merge 1 commit into
mikemccand:mainfrom
neoremind:geo-binary

Conversation

@neoremind

Copy link
Copy Markdown
Contributor

The existing src/extra/perf/IndexGeoNames.java reads the raw text geo names allCountries.txt file, every document construction has to pay the cost of string split, date format, int/long/double parsing and utf8->utf16-utf8 for string/keyword field. As a benchmarking tool that is supposed to measure indexing performance, it is a lot noise, for example, in apache/lucene#15990, Tim wants to validate the performance gains, but as Amdahl’s law plays here, the overall end-to-end improvement gets diminished.

This PR adds a pre-conversion step (similar to how we already do buildBinaryLineDocs.py for the wikipedia dataset) so that the indexing benchmark can read binary file instead of text file focusing more on what matters of indexing.

Here I introduce:

  • buildBinaryGeoNames.py: converts geo names allCountries.txt into a chunked binary format. No String split, date format, int/long/double parsing are needed during runtime anymore.

  • IndexGeoNamesBinary.java: reads the binary file into ByteBuffer chunks. Note that for non-tokenized fields (StringField/KeywordField), we pass BytesRef directly to avoid utf8->utf16-utf8 round-trip overhead.

Benchmark

Ran java perf.IndexGeoNamesBinary allCountries.bin /path/to/index 1 with OpenJDK 25.0.2, 1 indexing threads, no merge policy, 128MB RAM buffer. I validated that the output segments file numbers and sizes for correctness.

Mac (Apple M3 Pro, 12 cores, 36 GB)

Mode Time End-to-end indexing speedup Flamegraph
Text 71.161 sec link
Binary 55.648 sec ~22% faster link

Linux (m5.4xlarge, Intel Xeon 8175M, 16 vCPU, 64 GB)

Mode Time End-to-end indexing speedup Flamegraph
Text 182.128 sec link
Binary 158.333 sec ~13% faster link

Add a Python converter (buildBinaryGeoNames.py) that pre-converts the
GeoNames allCountries.txt to a chunked binary
format that IndexGeoNamesBinary.java reads.

This eliminates per-document overhead during indexing:
- No String.split("\t") on 19 fields per line
- No Integer.parseInt/Double.parseDouble/Long.parseLong from text
- No date string parsing
- StringField/KeywordField use BytesRef directly, avoiding the
  UTF-8 -> UTF-16 -> UTF-8 round-trip for non-tokenized fields
@mikemccand

Copy link
Copy Markdown
Owner

I love this idea, sorry I haven't made time yet to review it! We absolutely try to drive to near 0 the overhead of running a benchmark -- reading docs, deserializing, creating Document, etc., so this is a very welcome improvement. When we merge let's remember to add annot!

@neoremind

Copy link
Copy Markdown
Contributor Author

Thanks Mike! I noticed the geo file loading optimization can benefit the stored fields benchmark https://benchmarks.mikemccandless.com/stored_fields_benchmarks.html, but that would require conveting geonames.txt to geonames.py by the Python script in this PR. Would you prefer to merge this PR first then work on the stored fields benchmark in another thread, or combine them?

I'm not familiar with how the dataset is prepared for the nightly benchs, any hints on where to look or how it's set up?

And yes, once the one for the stored fields benchmark lands, I'll add to notation.py. Thanks for the reminder!

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution!

@github-actions github-actions Bot added the Stale label Jun 4, 2026
@neoremind

Copy link
Copy Markdown
Contributor Author

@mikemccand gentle nudge, would you mind taking a look of this PR?

As for the potential benefit to stored_fields_benchmarks, since this requires a conversion over the geo files, would you guide me how to prepare the dataset for https://benchmarks.mikemccandless.com/stored_fields_benchmarks.html so that it can be used in the bench?

@github-actions github-actions Bot removed the Stale label Jun 17, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution!

@github-actions github-actions Bot added the Stale label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants