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

Speed up writeGroupVInts #13203

Merged
merged 4 commits into from
Mar 26, 2024
Merged

Speed up writeGroupVInts #13203

merged 4 commits into from
Mar 26, 2024

Conversation

easyice
Copy link
Contributor

@easyice easyice commented Mar 23, 2024

This change uses VarHandles instead of BytesRefBuilder#append to speed up writeGroupVInts, which is more aligned with group-varint generally implementation.

Main:

Benchmark                                (size)   Mode  Cnt  Score   Error   Units
GroupVIntBenchmark.bench_writeGroupVInt      64  thrpt    5  1.050 ± 0.057  ops/us

PR:

Benchmark                                (size)   Mode  Cnt  Score   Error   Units
GroupVIntBenchmark.bench_writeGroupVInt      64  thrpt    5  2.924 ± 0.049  ops/us

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.

This looks like a good speedup!

return Integer.BYTES - (Integer.numberOfLeadingZeros(v | 1) >> 3);
}

public static void writeGroupVInts(DataOutput out, byte[] scratch, long[] values, int limit)
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 add some minimal javadocs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@easyice
Copy link
Contributor Author

easyice commented Mar 25, 2024

Thanks for reviewing!

# Conflicts:
#	lucene/CHANGES.txt
@easyice easyice merged commit 1f909ba into apache:main Mar 26, 2024
3 checks passed
asfgit pushed a commit that referenced this pull request Mar 26, 2024
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