Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce singleton for PackedInts.NullReader of size 256 #13232

Merged
merged 5 commits into from Mar 29, 2024

Conversation

original-brownbear
Copy link
Contributor

@original-brownbear original-brownbear commented Mar 28, 2024

Size 256 is very common here through the monotonic long values default page size. In ES we're seeing many MB O(10M) of duplicate instances of this size relatively quickly.
=> adding a singleton for it to save some heap

Size 256 is very common here throguh the monotonic long values default
page size. In ES we're seing many MB O(10M) of duplicate instances of this
size relatively quickly.
=> adding a singleton for it to save some heap
Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

Thanks, it looks pretty straightforward. Can you add a CHANGES entry?

@@ -566,10 +566,20 @@ public String toString() {
/** A {@link Reader} which has all its values equal to 0 (bitsPerValue = 0). */
public static final class NullReader extends Reader {

private static final NullReader DEFAULT_MONOTONIC_LONG_VALUES_PAGE_SIZE =
new NullReader(MonotonicLongValues.DEFAULT_PAGE_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use PackedLongValues.DEFAULT_PAGE_SIZE instead (the parent class)? (and rename the constant)

Separately I wonder if we should override #ramBytesUsed() to return 0 on this instance now that it's a singleton.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed + made it return 0 now. Makes sense to me :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm this causes an annoying test failure .. let me see what I can do about it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

95fb423 is pretty much the best I could come up with for the test, wdyt? I don't have a good intuition if the accuracy gain on the ram bytes method is worth the test noise I must admit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm agreed. Sorry for the suggestion. Let's not tweak ramBytesUsed then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries! ++ not worth the hassle :) -> Reverted the change

@original-brownbear
Copy link
Contributor Author

Thanks for taking a look Adrien!

Can you add a CHANGES entry?

Done :) Hope 9.11.0 was correct?

@jpountz jpountz merged commit c41eb22 into apache:main Mar 29, 2024
3 checks passed
@jpountz jpountz added this to the 9.11.0 milestone Mar 29, 2024
jpountz pushed a commit that referenced this pull request Mar 29, 2024
Size 256 is very common here throguh the monotonic long values default
page size. In ES we're seing many MB O(10M) of duplicate instances of this
size relatively quickly.
=> adding a singleton for it to save some heap
@original-brownbear original-brownbear deleted the dedup-common-null-reader branch March 29, 2024 17:19
original-brownbear added a commit to original-brownbear/lucene that referenced this pull request Mar 29, 2024
Correct estimate for singleton to return `0` and use custom accumulator in tests to
fix assertions. Tried not doing this in apache#13232 but turns out we need a little complexity here
since the singleton is recognized by the `RamUsageTester` in so far that is only counted
once if it shows up repeatedly in an array or so.

fixes apache#13249
benwtrent pushed a commit that referenced this pull request Apr 1, 2024
…3250)

Correct estimate for singleton to return `0` and use custom accumulator in tests to
fix assertions. Tried not doing this in #13232 but turns out we need a little complexity here
since the singleton is recognized by the `RamUsageTester` in so far that is only counted
once if it shows up repeatedly in an array or so.

fixes #13249
benwtrent pushed a commit that referenced this pull request Apr 1, 2024
…3250)

Correct estimate for singleton to return `0` and use custom accumulator in tests to
fix assertions. Tried not doing this in #13232 but turns out we need a little complexity here
since the singleton is recognized by the `RamUsageTester` in so far that is only counted
once if it shows up repeatedly in an array or so.

fixes #13249
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.

None yet

3 participants