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

[7.2.0] Update blake3 to v1.5.1.bcr.1 #22161

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update blake3 to v1.5.1.bcr.1
This brings AVX-512 support on Linux.

Also adds a JMH benchmark pitting BLAKE3 against SHA2-256.

Results with `-f 1` (single JVM fork) and for `hashBytesOneShot` only:
<details>
<summary>Intel Core i5-8520U, Linux: BLAKE3 has ~8x the throughput on large inputs</summary>
<pre>
Benchmark                                      (size)    (type)   Mode  Cnt        Score        Error  Units
BazelHashFunctionsBenchmark.hashBytesOneShot        1    BLAKE3  thrpt    5  3897193.109 ± 104089.759  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot        1  SHA2_256  thrpt    5  9773250.840 ± 919565.969  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot       16    BLAKE3  thrpt    5  4058401.127 ±  69345.382  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot       16  SHA2_256  thrpt    5  9338184.696 ± 575903.627  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      128    BLAKE3  thrpt    5  3883335.405 ± 197131.021  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      128  SHA2_256  thrpt    5  3931746.804 ± 111963.068  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      512    BLAKE3  thrpt    5  3165886.130 ± 105001.405  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      512  SHA2_256  thrpt    5  1689377.092 ±  67006.025  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     1024    BLAKE3  thrpt    5  2137151.012 ±  71425.961  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     1024  SHA2_256  thrpt    5   971335.403 ±  43622.796  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     4096    BLAKE3  thrpt    5  1266551.855 ±  77312.865  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     4096  SHA2_256  thrpt    5   271217.035 ±  15770.310  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot    16384    BLAKE3  thrpt    5   562124.458 ±  47243.736  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot    16384  SHA2_256  thrpt    5    72281.652 ±  10734.186  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot  1048576    BLAKE3  thrpt    5     9800.524 ±    230.269  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot  1048576  SHA2_256  thrpt    5     1124.542 ±     40.938  ops/s
</pre>
</details>
<details>
<summary>MacBook Pro with M3 Max, macOS: BLAKE3 has ~0.75x the throughput on large inputs</summary>
<pre>
Benchmark                                      (size)    (type)   Mode  Cnt         Score        Error  Units
BazelHashFunctionsBenchmark.hashBytesOneShot        1    BLAKE3  thrpt    5   9262824.819 ±  12194.067  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot        1  SHA2_256  thrpt    5  76557346.275 ± 548738.127  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot       16    BLAKE3  thrpt    5   9254500.192 ±  22138.081  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot       16  SHA2_256  thrpt    5  81029076.629 ± 748425.519  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      128    BLAKE3  thrpt    5   8304084.839 ±  20398.724  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      128  SHA2_256  thrpt    5  4146027.256 ± 106648.234  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     1024    BLAKE3  thrpt    5   3092086.580 ±   1301.806  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     1024  SHA2_256  thrpt    5   9355426.285 ±   7352.032  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     4096    BLAKE3  thrpt    5   1670833.346 ±   1809.726  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     4096  SHA2_256  thrpt    5   2562509.914 ±  29303.110  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot    16384    BLAKE3  thrpt    5    484960.116 ±    146.961  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot    16384  SHA2_256  thrpt    5    658392.748 ±   3364.324  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot  1048576    BLAKE3  thrpt    5      7987.472 ±     19.194  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot  1048576  SHA2_256  thrpt    5     10380.444 ±      8.804  ops/s
</pre>
</details>
<details>
<summary>AMD Ryzen 7 PRO 5850U, Windows: BLAKE3 has ~1.5x the throughput on large inputs</summary>
<pre>
BazelHashFunctionsBenchmark.hashBytesOneShot        1    BLAKE3  thrpt    5   5569003,683 ± 125621,794  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot        1  SHA2_256  thrpt    5  21202138,257 ± 458127,205  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot       16    BLAKE3  thrpt    5   5539298,273 ±  77378,097  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot       16  SHA2_256  thrpt    5  21618815,496 ± 208338,556  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      128    BLAKE3  thrpt    5   5047579,827 ± 118690,537  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      128  SHA2_256  thrpt    5  15806244,512 ± 258848,826  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      512    BLAKE3  thrpt    5   3300538,392 ±  53754,778  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot      512  SHA2_256  thrpt    5   8353887,852 ±  47076,094  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     1024    BLAKE3  thrpt    5   2062144,084 ±  14557,116  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     1024  SHA2_256  thrpt    5   5120693,705 ±  30640,599  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     4096    BLAKE3  thrpt    5   1437595,889 ±  34088,637  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot     4096  SHA2_256  thrpt    5   1552307,356 ±  25584,819  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot    16384    BLAKE3  thrpt    5    558955,757 ±   8647,716  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot    16384  SHA2_256  thrpt    5    411619,868 ±   1179,203  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot  1048576    BLAKE3  thrpt    5      9576,940 ±    460,875  ops/s
BazelHashFunctionsBenchmark.hashBytesOneShot  1048576  SHA2_256  thrpt    5      6470,682 ±     41,223  ops/s
</pre>
</details>

Closes #22017.

PiperOrigin-RevId: 628330908
Change-Id: Ic635027d020d60b79d2e498fcebb0cc42fae712b
fmeum authored and iancha1992 committed Apr 26, 2024
commit da3cce074e0e7e1cbca6a601c8207eddb805c0f8
5 changes: 3 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_pkg", version = "0.9.1")
bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_skydoc")
bazel_dep(name = "zstd-jni", version = "1.5.2-3.bcr.1")
bazel_dep(name = "blake3", version = "1.3.3.bcr.1")
bazel_dep(name = "blake3", version = "1.5.1.bcr.1")
bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1")
bazel_dep(name = "zlib", version = "1.3")
bazel_dep(name = "rules_cc", version = "0.0.9")
@@ -31,6 +31,7 @@ bazel_dep(name = "rules_jvm_external", version = "6.0")
bazel_dep(name = "rules_python", version = "0.26.0")
bazel_dep(name = "rules_testing", version = "0.0.4")
bazel_dep(name = "googletest", version = "1.14.0", repo_name = "com_google_googletest")
bazel_dep(name = "with_cfg.bzl", version = "0.2.4")

# TODO(pcloudy): Add remoteapis and googleapis as Bazel modules in the BCR.
bazel_dep(name = "remoteapis", version = "")
@@ -97,7 +98,7 @@ maven.install(
"com.google.http-client:google-http-client-gson:1.42.0",
"com.google.http-client:google-http-client:1.42.0",
"com.google.j2objc:j2objc-annotations:1.3",
"com.google.turbine:turbine:0.4.0",
"com.google.turbine:turbine:0.5.0",
"com.ryanharter.auto.value:auto-value-gson-extension:1.3.1",
"com.ryanharter.auto.value:auto-value-gson-runtime:1.3.1",
"com.ryanharter.auto.value:auto-value-gson-factory:1.3.1",
135 changes: 83 additions & 52 deletions MODULE.bazel.lock
215 changes: 55 additions & 160 deletions maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": 126972392,
"__RESOLVED_ARTIFACTS_HASH": 1100189256,
"__INPUT_ARTIFACTS_HASH": 1516511089,
"__RESOLVED_ARTIFACTS_HASH": -1733639136,
"conflict_resolution": {
"com.google.code.gson:gson:2.8.9": "com.google.code.gson:gson:2.9.0",
"com.google.errorprone:error_prone_annotations:2.3.2": "com.google.errorprone:error_prone_annotations:2.22.0",
@@ -278,9 +278,9 @@
},
"com.google.turbine:turbine": {
"shasums": {
"jar": "1947490c23263ae1c0a95acceb7cb419724f236d14cfbbe5a558101e79842b28"
"jar": "3bb883977330ec99dd11d8bba0c9c9084b356189807920903984215a466c81ac"
},
"version": "0.4.0"
"version": "0.5.0"
},
"com.ryanharter.auto.value:auto-value-gson-extension": {
"shasums": {
@@ -731,9 +731,7 @@
"com.google.auto:auto-common",
"com.google.guava:guava"
],
"com.google.auto:auto-common": [
"com.google.guava:guava"
],
"com.google.auto:auto-common": ["com.google.guava:guava"],
"com.google.code.java-allocation-instrumenter:java-allocation-instrumenter": [
"com.google.guava:guava",
"javax.annotation:javax.annotation-api",
@@ -743,9 +741,7 @@
"org.ow2.asm:asm-tree",
"org.ow2.asm:asm-util"
],
"com.google.errorprone:error_prone_annotation": [
"com.google.guava:guava"
],
"com.google.errorprone:error_prone_annotation": ["com.google.guava:guava"],
"com.google.errorprone:error_prone_check_api": [
"com.github.ben-manes.caffeine:caffeine",
"com.github.kevinstern:software-and-algorithms",
@@ -771,16 +767,12 @@
"javax.inject:javax.inject",
"org.pcollections:pcollections"
],
"com.google.flogger:flogger": [
"org.checkerframework:checker-compat-qual"
],
"com.google.flogger:flogger": ["org.checkerframework:checker-compat-qual"],
"com.google.flogger:flogger-system-backend": [
"com.google.flogger:flogger",
"org.checkerframework:checker-compat-qual"
],
"com.google.flogger:google-extensions": [
"com.google.flogger:flogger"
],
"com.google.flogger:google-extensions": ["com.google.flogger:flogger"],
"com.google.guava:guava": [
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
@@ -816,9 +808,7 @@
"com.google.guava:guava",
"javax.inject:javax.inject"
],
"com.google.jimfs:jimfs": [
"com.google.guava:guava"
],
"com.google.jimfs:jimfs": ["com.google.guava:guava"],
"com.google.oauth-client:google-oauth-client": [
"com.google.guava:guava",
"com.google.http-client:google-http-client",
@@ -932,9 +922,7 @@
"com.google.guava:guava",
"io.grpc:grpc-api"
],
"io.netty:netty-buffer": [
"io.netty:netty-common"
],
"io.netty:netty-buffer": ["io.netty:netty-common"],
"io.netty:netty-codec": [
"io.netty:netty-buffer",
"io.netty:netty-common",
@@ -983,9 +971,7 @@
"io.netty:netty-common",
"io.netty:netty-transport"
],
"io.netty:netty-resolver": [
"io.netty:netty-common"
],
"io.netty:netty-resolver": ["io.netty:netty-common"],
"io.netty:netty-resolver-dns": [
"io.netty:netty-buffer",
"io.netty:netty-codec",
@@ -1100,19 +1086,13 @@
"io.netty:netty-common",
"io.netty:netty-transport"
],
"io.opencensus:opencensus-api": [
"io.grpc:grpc-context"
],
"io.opencensus:opencensus-api": ["io.grpc:grpc-context"],
"io.opencensus:opencensus-contrib-http-util": [
"com.google.guava:guava",
"io.opencensus:opencensus-api"
],
"io.reactivex.rxjava3:rxjava": [
"org.reactivestreams:reactive-streams"
],
"junit:junit": [
"org.hamcrest:hamcrest-core"
],
"io.reactivex.rxjava3:rxjava": ["org.reactivestreams:reactive-streams"],
"junit:junit": ["org.hamcrest:hamcrest-core"],
"org.apache.velocity:velocity": [
"commons-collections:commons-collections",
"commons-lang:commons-lang"
@@ -1122,17 +1102,13 @@
"net.bytebuddy:byte-buddy-agent",
"org.objenesis:objenesis"
],
"org.ow2.asm:asm-analysis": [
"org.ow2.asm:asm-tree"
],
"org.ow2.asm:asm-analysis": ["org.ow2.asm:asm-tree"],
"org.ow2.asm:asm-commons": [
"org.ow2.asm:asm",
"org.ow2.asm:asm-analysis",
"org.ow2.asm:asm-tree"
],
"org.ow2.asm:asm-tree": [
"org.ow2.asm:asm"
],
"org.ow2.asm:asm-tree": ["org.ow2.asm:asm"],
"org.ow2.asm:asm-util": [
"org.ow2.asm:asm",
"org.ow2.asm:asm-analysis",
@@ -1163,12 +1139,8 @@
"blogspot.software_and_algorithms.stern_library.optimization",
"blogspot.software_and_algorithms.stern_library.string"
],
"com.github.stephenc.jcip:jcip-annotations": [
"net.jcip.annotations"
],
"com.google.android:annotations": [
"android.annotation"
],
"com.github.stephenc.jcip:jcip-annotations": ["net.jcip.annotations"],
"com.google.android:annotations": ["android.annotation"],
"com.google.api-client:google-api-client": [
"com.google.api.client.googleapis",
"com.google.api.client.googleapis.apache",
@@ -1209,9 +1181,7 @@
"com.google.rpc.context",
"com.google.type"
],
"com.google.auth:google-auth-library-credentials": [
"com.google.auth"
],
"com.google.auth:google-auth-library-credentials": ["com.google.auth"],
"com.google.auth:google-auth-library-oauth2-http": [
"com.google.auth.http",
"com.google.auth.oauth2"
@@ -1256,9 +1226,7 @@
"com.google.auto.value.extension.serializable",
"com.google.auto.value.extension.toprettystring"
],
"com.google.auto:auto-common": [
"com.google.auto.common"
],
"com.google.auto:auto-common": ["com.google.auto.common"],
"com.google.code.findbugs:jsr305": [
"javax.annotation",
"javax.annotation.concurrent",
@@ -1306,9 +1274,7 @@
"com.google.monitoring.runtime.instrumentation.j2objc.annotations",
"com.google.thirdparty.publicsuffix"
],
"com.google.errorprone:error_prone_annotation": [
"com.google.errorprone"
],
"com.google.errorprone:error_prone_annotation": ["com.google.errorprone"],
"com.google.errorprone:error_prone_annotations": [
"com.google.errorprone.annotations",
"com.google.errorprone.annotations.concurrent"
@@ -1367,9 +1333,7 @@
"com.google.flogger:flogger-system-backend": [
"com.google.common.flogger.backend.system"
],
"com.google.flogger:google-extensions": [
"com.google.common.flogger"
],
"com.google.flogger:google-extensions": ["com.google.common.flogger"],
"com.google.guava:failureaccess": [
"com.google.common.util.concurrent.internal"
],
@@ -1439,12 +1403,8 @@
"com.google.inject.spi",
"com.google.inject.util"
],
"com.google.j2objc:j2objc-annotations": [
"com.google.j2objc.annotations"
],
"com.google.jimfs:jimfs": [
"com.google.common.jimfs"
],
"com.google.j2objc:j2objc-annotations": ["com.google.j2objc.annotations"],
"com.google.jimfs:jimfs": ["com.google.common.jimfs"],
"com.google.oauth-client:google-oauth-client": [
"com.google.api.client.auth.oauth",
"com.google.api.client.auth.oauth2",
@@ -1465,9 +1425,7 @@
"com.google.truth.extensions:truth-proto-extension": [
"com.google.common.truth.extensions.proto"
],
"com.google.truth:truth": [
"com.google.common.truth"
],
"com.google.truth:truth": ["com.google.common.truth"],
"com.google.turbine:turbine": [
"com.google.common.escape",
"com.google.turbine.binder",
@@ -1536,9 +1494,7 @@
"com.ryanharter.auto.value.gson",
"com.ryanharter.auto.value.gson.internal"
],
"com.squareup:javapoet": [
"com.squareup.javapoet"
],
"com.squareup:javapoet": ["com.squareup.javapoet"],
"commons-collections:commons-collections": [
"org.apache.commons.collections",
"org.apache.commons.collections.bag",
@@ -1622,37 +1578,19 @@
"com.github.difflib.text",
"com.github.difflib.unifieddiff"
],
"io.grpc:grpc-api": [
"io.grpc"
],
"io.grpc:grpc-auth": [
"io.grpc.auth"
],
"io.grpc:grpc-context": [
"io.grpc"
],
"io.grpc:grpc-api": ["io.grpc"],
"io.grpc:grpc-auth": ["io.grpc.auth"],
"io.grpc:grpc-context": ["io.grpc"],
"io.grpc:grpc-core": [
"io.grpc.inprocess",
"io.grpc.internal",
"io.grpc.util"
],
"io.grpc:grpc-netty": [
"io.grpc.netty"
],
"io.grpc:grpc-protobuf": [
"io.grpc.protobuf"
],
"io.grpc:grpc-protobuf-lite": [
"io.grpc.protobuf.lite"
],
"io.grpc:grpc-stub": [
"io.grpc.stub",
"io.grpc.stub.annotations"
],
"io.netty:netty-buffer": [
"io.netty.buffer",
"io.netty.buffer.search"
],
"io.grpc:grpc-netty": ["io.grpc.netty"],
"io.grpc:grpc-protobuf": ["io.grpc.protobuf"],
"io.grpc:grpc-protobuf-lite": ["io.grpc.protobuf.lite"],
"io.grpc:grpc-stub": ["io.grpc.stub", "io.grpc.stub.annotations"],
"io.netty:netty-buffer": ["io.netty.buffer", "io.netty.buffer.search"],
"io.netty:netty-codec": [
"io.netty.handler.codec",
"io.netty.handler.codec.base64",
@@ -1665,9 +1603,7 @@
"io.netty.handler.codec.string",
"io.netty.handler.codec.xml"
],
"io.netty:netty-codec-dns": [
"io.netty.handler.codec.dns"
],
"io.netty:netty-codec-dns": ["io.netty.handler.codec.dns"],
"io.netty:netty-codec-http": [
"io.netty.handler.codec.http",
"io.netty.handler.codec.http.cookie",
@@ -1679,9 +1615,7 @@
"io.netty.handler.codec.rtsp",
"io.netty.handler.codec.spdy"
],
"io.netty:netty-codec-http2": [
"io.netty.handler.codec.http2"
],
"io.netty:netty-codec-http2": ["io.netty.handler.codec.http2"],
"io.netty:netty-codec-socks": [
"io.netty.handler.codec.socks",
"io.netty.handler.codec.socksx",
@@ -1713,18 +1647,10 @@
"io.netty.handler.timeout",
"io.netty.handler.traffic"
],
"io.netty:netty-handler-proxy": [
"io.netty.handler.proxy"
],
"io.netty:netty-resolver": [
"io.netty.resolver"
],
"io.netty:netty-resolver-dns": [
"io.netty.resolver.dns"
],
"io.netty:netty-tcnative-classes": [
"io.netty.internal.tcnative"
],
"io.netty:netty-handler-proxy": ["io.netty.handler.proxy"],
"io.netty:netty-resolver": ["io.netty.resolver"],
"io.netty:netty-resolver-dns": ["io.netty.resolver.dns"],
"io.netty:netty-tcnative-classes": ["io.netty.internal.tcnative"],
"io.netty:netty-transport": [
"io.netty.bootstrap",
"io.netty.channel",
@@ -1739,15 +1665,9 @@
"io.netty.channel.socket.nio",
"io.netty.channel.socket.oio"
],
"io.netty:netty-transport-classes-epoll": [
"io.netty.channel.epoll"
],
"io.netty:netty-transport-classes-kqueue": [
"io.netty.channel.kqueue"
],
"io.netty:netty-transport-native-unix-common": [
"io.netty.channel.unix"
],
"io.netty:netty-transport-classes-epoll": ["io.netty.channel.epoll"],
"io.netty:netty-transport-classes-kqueue": ["io.netty.channel.kqueue"],
"io.netty:netty-transport-native-unix-common": ["io.netty.channel.unix"],
"io.netty:netty-transport-native-unix-common:jar:linux-aarch_64": [
"io.netty.channel.unix"
],
@@ -1783,9 +1703,7 @@
"io.opencensus.contrib.http",
"io.opencensus.contrib.http.util"
],
"io.perfmark:perfmark-api": [
"io.perfmark"
],
"io.perfmark:perfmark-api": ["io.perfmark"],
"io.reactivex.rxjava3:rxjava": [
"io.reactivex.rxjava3.annotations",
"io.reactivex.rxjava3.core",
@@ -1820,9 +1738,7 @@
"io.reactivex.rxjava3.subjects",
"io.reactivex.rxjava3.subscribers"
],
"io.sweers.autotransient:autotransient": [
"io.sweers.autotransient"
],
"io.sweers.autotransient:autotransient": ["io.sweers.autotransient"],
"it.unimi.dsi:fastutil": [
"it.unimi.dsi.fastutil",
"it.unimi.dsi.fastutil.booleans",
@@ -1836,17 +1752,13 @@
"it.unimi.dsi.fastutil.objects",
"it.unimi.dsi.fastutil.shorts"
],
"javax.activation:javax.activation-api": [
"javax.activation"
],
"javax.activation:javax.activation-api": ["javax.activation"],
"javax.annotation:javax.annotation-api": [
"javax.annotation",
"javax.annotation.security",
"javax.annotation.sql"
],
"javax.inject:javax.inject": [
"javax.inject"
],
"javax.inject:javax.inject": ["javax.inject"],
"junit:junit": [
"junit.extensions",
"junit.framework",
@@ -2117,28 +2029,13 @@
"org.objenesis.instantiator.util",
"org.objenesis.strategy"
],
"org.ow2.asm:asm": [
"org.objectweb.asm",
"org.objectweb.asm.signature"
],
"org.ow2.asm:asm-analysis": [
"org.objectweb.asm.tree.analysis"
],
"org.ow2.asm:asm-commons": [
"org.objectweb.asm.commons"
],
"org.ow2.asm:asm-tree": [
"org.objectweb.asm.tree"
],
"org.ow2.asm:asm-util": [
"org.objectweb.asm.util"
],
"org.pcollections:pcollections": [
"org.pcollections"
],
"org.reactivestreams:reactive-streams": [
"org.reactivestreams"
],
"org.ow2.asm:asm": ["org.objectweb.asm", "org.objectweb.asm.signature"],
"org.ow2.asm:asm-analysis": ["org.objectweb.asm.tree.analysis"],
"org.ow2.asm:asm-commons": ["org.objectweb.asm.commons"],
"org.ow2.asm:asm-tree": ["org.objectweb.asm.tree"],
"org.ow2.asm:asm-util": ["org.objectweb.asm.util"],
"org.pcollections:pcollections": ["org.pcollections"],
"org.reactivestreams:reactive-streams": ["org.reactivestreams"],
"org.threeten:threeten-extra": [
"org.threeten.extra",
"org.threeten.extra.chrono",
@@ -2178,9 +2075,7 @@
"org.yaml.snakeyaml.tokens",
"org.yaml.snakeyaml.util"
],
"tools.profiler:async-profiler": [
"one.profiler"
]
"tools.profiler:async-profiler": ["one.profiler"]
},
"repositories": {
"https://repo1.maven.org/maven2/": [
27 changes: 27 additions & 0 deletions src/test/java/com/google/devtools/build/lib/vfs/bazel/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_java//java:defs.bzl", "java_library", "java_test")
load(":java_opt_binary.bzl", "java_opt_binary")

package(
default_applicable_licenses = ["//:license"],
@@ -19,6 +20,9 @@ java_library(
[
"*.java",
],
exclude = [
"BazelHashFunctionsBenchmark.java",
],
),
deps = [
"//src/main/java/com/google/devtools/build/lib/vfs/bazel",
@@ -40,3 +44,26 @@ java_test(
"//src/test/java/com/google/devtools/build/lib:test_runner",
],
)

java_opt_binary(
name = "BazelHashFunctionsBenchmark",
srcs = ["BazelHashFunctionsBenchmark.java"],
main_class = "org.openjdk.jmh.Main",
deps = [
":jmh",
"//src/main/java/com/google/devtools/build/lib/vfs/bazel",
"//third_party:guava",
],
)

java_library(
name = "jmh",
exported_plugins = [":jmh_benchmark_processor"],
exports = ["@maven//:org_openjdk_jmh_jmh_core"],
)

java_plugin(
name = "jmh_benchmark_processor",
processor_class = "org.openjdk.jmh.generators.BenchmarkProcessor",
deps = ["@maven//:org_openjdk_jmh_jmh_generator_annprocess"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2024 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.devtools.build.lib.vfs.bazel;

import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import java.security.SecureRandom;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;

@BenchmarkMode(Mode.Throughput)
@State(Scope.Benchmark)
public class BazelHashFunctionsBenchmark {

static {
BazelHashFunctions.ensureRegistered();
}

public enum HashFunctionType {
BLAKE3(new Blake3HashFunction()),
SHA2_256(Hashing.sha256());

final HashFunction hashFunction;

HashFunctionType(HashFunction hashFunction) {
this.hashFunction = hashFunction;
}
}

public enum Size {
B,
KB,
MB,
GB;

final int bytes;

Size() {
bytes = 1 << (ordinal() * 10);
}
}

@Param({"BLAKE3", "SHA2_256"})
public HashFunctionType type;

@Param({"B", "KB", "MB", "GB"})
public Size size;

private byte[] data;

@Setup(Level.Iteration)
public void setup() {
data = new byte[size.bytes];
new SecureRandom().nextBytes(data);
}

@Benchmark
public HashCode hashBytesOneShot() {
return type.hashFunction.hashBytes(data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
A wrapper around java_binary that forces it to be built with `-c opt`.
This is useful for benchmark targets.
"""

load("@with_cfg.bzl", "with_cfg")

java_opt_binary, _java_opt_binary = with_cfg(native.java_binary).set("compilation_mode", "opt").build()