-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use StringBuilder instead of String concat for startup code #45647
Conversation
a435fbf
to
4fc6d0c
Compare
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.
Isn't dangerous if we use somewhere it in the hot path?
In the hot path it save to copy twice the content of the string, passing it directly from the constructure array into the final String
...
See #45638 (comment) |
I think we'd want to do some measurements on this one to make sure we don't lose any run time performance (I don't think we would, but it'd be worth verifying). |
Makes sense |
This comment has been minimized.
This comment has been minimized.
Unfortunately the JDK's indyfied String concatenation has a slight performance penalty at startup, so for code we know will always be run at startup, let's not pay that unnecessary price. With this change we force javac to use the StringBuilder strategy
I did a basic stress test on a Hello World REST application and this change made no difference whatsoever |
4fc6d0c
to
ddb26ac
Compare
Status for workflow
|
Status | Name | Step | Failures | Logs | Raw logs | Build scan |
---|---|---|---|---|---|---|
✖ | Native Tests - Misc4 | Build |
Failures | Logs | Raw logs | 🔍 |
Full information is available in the Build summary check run.
You can consult the Develocity build scans.
Failures
⚙️ Native Tests - Misc4 #
- Failing: integration-tests/gradle
📦 integration-tests/gradle
✖ io.quarkus.gradle.nativeimage.BasicJavaNativeBuildIT.shouldBuildNativeImage
- History - More details - Source on GitHub
java.lang.AssertionError: Gradle build failed with exit code 137
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:140)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:57)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:52)
at app//io.quarkus.gradle.nativeimage.QuarkusNativeGradleITBase.runGradleWrapper(QuarkusNativeGradleITBase.java:36)
at app//io.quarkus.gradle.nativeimage.BasicJavaNativeBuildIT.shouldBuildNativeImage(BasicJavaNativeBuildIT.java:24)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
✖ io.quarkus.gradle.nativeimage.BasicJavaNativeBuildIT.shouldBuildNativeImageWithCustomName
- History - More details - Source on GitHub
java.lang.AssertionError: Gradle build failed with exit code 137
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:140)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:57)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:52)
at app//io.quarkus.gradle.nativeimage.QuarkusNativeGradleITBase.runGradleWrapper(QuarkusNativeGradleITBase.java:36)
at app//io.quarkus.gradle.nativeimage.BasicJavaNativeBuildIT.shouldBuildNativeImageWithCustomName(BasicJavaNativeBuildIT.java:53)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
✖ io.quarkus.gradle.nativeimage.BasicJavaNativeBuildIT.shouldBuildNativeImageWithCustomNameWithoutSuffix
- History - More details - Source on GitHub
java.lang.AssertionError: Gradle build failed with exit code 137
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:140)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:57)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:52)
at app//io.quarkus.gradle.nativeimage.QuarkusNativeGradleITBase.runGradleWrapper(QuarkusNativeGradleITBase.java:36)
at app//io.quarkus.gradle.nativeimage.BasicJavaNativeBuildIT.shouldBuildNativeImageWithCustomNameWithoutSuffix(BasicJavaNativeBuildIT.java:84)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
✖ io.quarkus.gradle.nativeimage.CustomNativeTestSourceSetIT.runNativeTests
- History - More details - Source on GitHub
java.lang.AssertionError: Gradle build failed with exit code 137
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:140)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:57)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:52)
at app//io.quarkus.gradle.nativeimage.QuarkusNativeGradleITBase.runGradleWrapper(QuarkusNativeGradleITBase.java:36)
at app//io.quarkus.gradle.nativeimage.CustomNativeTestSourceSetIT.runNativeTests(CustomNativeTestSourceSetIT.java:17)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
✖ io.quarkus.gradle.nativeimage.NativeIntegrationTestIT.nativeTestShouldRunIntegrationTest
- History - More details - Source on GitHub
java.lang.AssertionError: Gradle build failed with exit code 137
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:140)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:57)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:52)
at app//io.quarkus.gradle.nativeimage.QuarkusNativeGradleITBase.runGradleWrapper(QuarkusNativeGradleITBase.java:36)
at app//io.quarkus.gradle.nativeimage.NativeIntegrationTestIT.nativeTestShouldRunIntegrationTest(NativeIntegrationTestIT.java:24)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
✖ io.quarkus.gradle.nativeimage.NativeIntegrationTestIT.runNativeTestsWithOutputName
- History - More details - Source on GitHub
java.lang.AssertionError: Gradle build failed with exit code 137
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:140)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:57)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:52)
at app//io.quarkus.gradle.nativeimage.QuarkusNativeGradleITBase.runGradleWrapper(QuarkusNativeGradleITBase.java:36)
at app//io.quarkus.gradle.nativeimage.NativeIntegrationTestIT.runNativeTestsWithOutputName(NativeIntegrationTestIT.java:35)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
✖ io.quarkus.gradle.nativeimage.NativeIntegrationTestIT.runNativeTestsWithoutRunnerSuffix
- History - More details - Source on GitHub
java.lang.AssertionError: Gradle build failed with exit code 137
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:140)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:57)
at app//io.quarkus.gradle.QuarkusGradleWrapperTestBase.runGradleWrapper(QuarkusGradleWrapperTestBase.java:52)
at app//io.quarkus.gradle.nativeimage.QuarkusNativeGradleITBase.runGradleWrapper(QuarkusNativeGradleITBase.java:36)
at app//io.quarkus.gradle.nativeimage.NativeIntegrationTestIT.runNativeTestsWithoutRunnerSuffix(NativeIntegrationTestIT.java:45)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:569)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
So what do we think about this? |
Seems OK to me. |
Unfortunately the JDK's indyfied String concatenation has a slight performance penalty at startup, so for code we know will always be run at startup, let's not pay that unnecessary price.
With this change we force javac to use the
StringBuilder strategy