-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add optional MurmurHash support #142
base: develop
Are you sure you want to change the base?
Conversation
1a11e95
to
a5747d2
Compare
a5747d2
to
d15a68c
Compare
d15a68c
to
bad9b9a
Compare
private static final String SELECTED_ALGORITHM_PROP = "hash.algorithm"; | ||
private static final HashAlgorithm DEFAULT_ALGORITHM = HashAlgorithm.MD5; | ||
private static final HashAlgorithm SELECTED_ALGORITHM = | ||
HashAlgorithm.valueOf(System.getProperty(SELECTED_ALGORITHM_PROP, DEFAULT_ALGORITHM.name()).toUpperCase()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We read the chosen hashing algorithm from the system property here
Scavenger Test Results166 files 166 suites 1m 31s ⏱️ Results for commit 7554c09. ♻️ This comment has been updated with latest results. |
b804064
to
f465a85
Compare
private static String from(String signature) { | ||
MessageDigest md = callWithCheckedExceptionWrapping(() -> MessageDigest.getInstance("MD5")); | ||
md.update(signature.getBytes(StandardCharsets.UTF_8)); | ||
// Ideally should be "%032x" to avoid confusion from leading zeros being dropped, do not change now, avoid compat issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this peculiarity whilst testing - the returned String won't always be 32 characters. This shouldn't cause issues but noted it in a comment. We obviously can't change it now anyway as it would cause backwards compatibility issues.
f465a85
to
7554c09
Compare
@@ -17,12 +22,19 @@ dependencies { | |||
implementation("io.grpc:grpc-kotlin-stub:${property("grpcKotlinVersion")}") | |||
implementation("io.grpc:grpc-protobuf:${property("grpcVersion")}") | |||
implementation("javax.annotation:javax.annotation-api:1.3.2") | |||
implementation("commons-codec:commons-codec:1.18.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the MurmurHash implementation from the commons-codec
library dependency - it will increase the size of the agent JAR slightly (~300 kB)
The changes encompassed in this PR were originally included with those in #134. I extracted these change into this separate PR following a discussion in the former PR.
This PR introduces support for MurmurHash as an alternative to the default MD5. In my experience it is over 4x faster at hashing (rough benchmarks below).
MurmurHash can be activated by providing the following argument to the agent
-Dhash.algorithm=murmur
. The argument must be supplied to the collector instead if using the legacy agent.Benchmark:
MethodRegistry#getHash
Scenario:
ConcurrentHashMap
cache disabled