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

Optimize ObjectID sort and serdes #1582

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Edarke
Copy link

@Edarke Edarke commented Dec 11, 2024

Ticket: JAVA-5388

Change in-memory representation of ObjectId to minimize number of comparisons for sorting.

This representation also has a side effect of improving methods relating to serialization/deserialization and saving 2 bytes/object. The behavior of this class should remain unchanged except for trivial differences in hashCode()

Below are results of some JMH benchmarks measured by throughput

Benchmark Mode Master Mine Error Speedup
compareTo thrpt 144.99 ops/us 1098.05 ops/us ± 18.08 7.57x
putToByteBuffer thrpt 143.41 ops/us 418.72 ops/us ± 7.69 2.91x
fromByteBuffer thrpt 141.40 ops/us 270.32 ops/us ± 5.14 1.91x
byteArrayConstructor thrpt 258.79 ops/us 487.36 ops/us ± 10.77 1.89x
toByteArray thrpt 268.19 ops/us 416.34 ops/us ± 4.38 1.55x
dateConstructor thrpt 135.37 ops/us 138.61 ops/us ± 1.00 1.02x
toHexString thrpt 20.75 ops/us 21.25 ops/us ± 0.36 1.02x
noArgConstructor thrpt 40.56 ops/us 40.48 ops/us ± 0.81 0.999x
equals (same Date) thrpt 1356.20 ops/us 1097.49 ops/us ± 22.30 0.80x

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.

1 participant