Skip to content

Commit

Permalink
Improve performance of parsing unknown fields in Java
Browse files Browse the repository at this point in the history
Credit should go to @elharo for most of these Java changes--I am just
cherry-picking them from our internal codebase. The one thing I did
change was to give the UTF-8 validation tests their own Bazel test
target. This makes it possible to give the other tests a shorter
timeout, which is important for UnknownFieldSetPerformanceTest in
particular.
  • Loading branch information
acozzette committed Jan 5, 2022
1 parent b17c8ca commit 624452b
Show file tree
Hide file tree
Showing 5 changed files with 498 additions and 214 deletions.
24 changes: 23 additions & 1 deletion java/core/BUILD
Expand Up @@ -239,6 +239,7 @@ test_suite(
"conformance_test",
"core_build_test",
"core_tests",
"utf8_tests",
],
)

Expand All @@ -258,10 +259,12 @@ conformance_test(

junit_tests(
name = "core_tests",
size = "large",
size = "small",
srcs = glob(
["src/test/java/**/*.java"],
exclude = [
"src/test/java/com/google/protobuf/DecodeUtf8Test.java",
"src/test/java/com/google/protobuf/IsValidUtf8Test.java",
"src/test/java/com/google/protobuf/TestUtil.java",
"src/test/java/com/google/protobuf/TestUtilLite.java",
],
Expand All @@ -279,6 +282,24 @@ junit_tests(
],
)

# The UTF-8 validation tests are much slower than the other tests, so they get
# their own test target with a longer timeout.
junit_tests(
name = "utf8_tests",
size = "large",
srcs = [
"src/test/java/com/google/protobuf/DecodeUtf8Test.java",
"src/test/java/com/google/protobuf/IsValidUtf8Test.java",
"src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java",
],
deps = [
":core",
"@maven//:com_google_guava_guava",
"@maven//:com_google_truth_truth",
"@maven//:junit_junit",
],
)

java_lite_proto_library(
name = "generic_test_protos_java_proto_lite",
visibility = [
Expand Down Expand Up @@ -361,6 +382,7 @@ LITE_TEST_EXCLUSIONS = [
"src/test/java/com/google/protobuf/TypeRegistryTest.java",
"src/test/java/com/google/protobuf/UnknownEnumValueTest.java",
"src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java",
"src/test/java/com/google/protobuf/UnknownFieldSetPerformanceTest.java",
"src/test/java/com/google/protobuf/UnknownFieldSetTest.java",
"src/test/java/com/google/protobuf/WellKnownTypesTest.java",
"src/test/java/com/google/protobuf/WireFormatTest.java",
Expand Down

0 comments on commit 624452b

Please sign in to comment.