-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
DigestUtils: avoid throwing on invalid digest function name #20574
DigestUtils: avoid throwing on invalid digest function name #20574
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Ouch, 11% is pretty bad! Great find.
src/main/java/com/google/devtools/build/lib/remote/util/DigestUtil.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/remote/util/DigestUtil.java
Outdated
Show resolved
Hide resolved
@@ -43,12 +46,13 @@ public DigestUtil(XattrProvider xattrProvider, DigestHashFunction hashFn) { | |||
this.digestFunction = getDigestFunctionFromHashFunction(hashFn); | |||
} | |||
|
|||
private static final ImmutableSet<String> DIGEST_FUNCTION_NAMES = | |||
Arrays.stream(DigestFunction.Value.values()).map(v -> v.name()).collect(toImmutableSet()); |
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.
btw – I could not find a java style guide for the bazel source code, so I assume you use 4 space continuations based on other parts of the codebase
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.
What helped me for contributions: The style guide is https://google.github.io/styleguide/javaguide.html and you can use https://github.com/google/google-java-format and its IDE plugins for formatting.
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.
Oh of course it's the google Java style guide. Thanks @fmeum!
@tjgq can I assume those CI failures are flakes? |
@bazel-io flag |
@bazel-io fork 7.1.0 |
9% of samples in a profile of one of our builds were inside the `fillInStackTrace()` method. Collecting the valid names into a hashset avoids needing to construct errors every time an invalid digest function name is passed into this function. Tested with Bazel 6.4.0. Our codebase is not yet compatible with Bazel 7. I have not investigated why this function was receiving so many invalid names. Before: ![Screenshot 2023-12-15 at 2 39 01 pm](https://github.com/bazelbuild/bazel/assets/18002432/be4bd311-ca73-46ec-a06d-93bb0ca9c6ba) After: ![Screenshot 2023-12-15 at 2 43 10 pm](https://github.com/bazelbuild/bazel/assets/18002432/64b15739-538f-4752-aafd-6b2c94886595) My understanding is that this will not speed up builds directly, but it will allow BEP events to be processed more quickly. Closes bazelbuild#20574. PiperOrigin-RevId: 592094151 Change-Id: Ie23241c9ec40e59ba2aac1fc83e4830340260f45
…20650) 9% of samples in a profile of one of our builds were inside the `fillInStackTrace()` method. Collecting the valid names into a hashset avoids needing to construct errors every time an invalid digest function name is passed into this function. Tested with Bazel 6.4.0. Our codebase is not yet compatible with Bazel 7. I have not investigated why this function was receiving so many invalid names. Before: ![Screenshot 2023-12-15 at 2 39 01 pm](https://github.com/bazelbuild/bazel/assets/18002432/be4bd311-ca73-46ec-a06d-93bb0ca9c6ba) After: ![Screenshot 2023-12-15 at 2 43 10 pm](https://github.com/bazelbuild/bazel/assets/18002432/64b15739-538f-4752-aafd-6b2c94886595) My understanding is that this will not speed up builds directly, but it will allow BEP events to be processed more quickly. Closes #20574. Commit cb08d62 PiperOrigin-RevId: 592094151 Change-Id: Ie23241c9ec40e59ba2aac1fc83e4830340260f45 Co-authored-by: Christian Scott <christian.s@canva.com> Co-authored-by: Ian (Hee) Cha <heec@google.com> Co-authored-by: Yun Peng <pcloudy@google.com>
The changes in this PR have been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc. |
9% of samples in a profile of one of our builds were inside the
fillInStackTrace()
method. Collecting the valid names into a hashset avoids needing to construct errors every time an invalid digest function name is passed into this function.Tested with Bazel 6.4.0. Our codebase is not yet compatible with Bazel 7.
I have not investigated why this function was receiving so many invalid names.
Before:
After:
My understanding is that this will not speed up builds directly, but it will allow BEP events to be processed more quickly.