Skip to content

Conversation

@jpountz
Copy link
Contributor

@jpountz jpountz commented Oct 21, 2024

This comes from observations on https://tantivy-search.github.io/bench/ for exhaustive evaluation like TOP_100_COUNT. collect() is often inlined, but other methods that we'd like to see inlined like PostingsEnum#nextDoc() are not always inlined. This PR decreases the compiled size of collect() to make more room for other methods to be inlined.

It does so by moving an assertion to AssertingScorable and extracting an uncommon code path to a method.

…ctor`.

This comes from observations on https://tantivy-search.github.io/bench/ for
exhaustive evaluation like `TOP_100_COUNT`. `collect()` is often inlined, but
other methods that we'd like to see inlined like `PostingsEnum#nextDoc()` are
not always inlined. This PR decreases the compiled size of `collect()` to make
more room for other methods to be inlined.

It does so by moving an assertion to `AssertingScorable` and extracting an
uncommon code path to a method.
@jpountz jpountz added this to the 10.1.0 milestone Oct 21, 2024
@jpountz
Copy link
Contributor Author

jpountz commented Oct 21, 2024

For reference, luceneutil shows no difference.

Copy link
Member

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

LGTM, I think this makes sense. The benchmarks tend to show collectCompetitiveHit as a cold path and in fact on one of my benchmarking machines (faster Threadripper), I get a slight reproducible win for TermDTSort which afaik is one of the tasks that exercise this logic the hardest. No such win on a weaker i7 with less cache, but maybe we can take that as an indication that we can push this further by making other code smaller :)

@jpountz jpountz merged commit f8ea130 into apache:main Oct 22, 2024
@jpountz jpountz deleted the reduce_compiled_size_of_top_score_doc_collector_collect branch October 22, 2024 14:32
jpountz added a commit that referenced this pull request Oct 22, 2024
…ctor`. (#13939)

This comes from observations on https://tantivy-search.github.io/bench/ for
exhaustive evaluation like `TOP_100_COUNT`. `collect()` is often inlined, but
other methods that we'd like to see inlined like `PostingsEnum#nextDoc()` are
not always inlined. This PR decreases the compiled size of `collect()` to make
more room for other methods to be inlined.

It does so by moving an assertion to `AssertingScorable` and extracting an
uncommon code path to a method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants