-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
19, 21
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Garbage is being generated when you call method StringBuilder.append(double).
I found that issue when I migrated from Java 17 to 21. We use LOGJ2 with garbage free configuration and now when you append double value append method generates garbage. It;s a problem because I see gc pauses every 1 second.
REGRESSION : Last worked in version 17.0.9
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
create any test when you call many times StringBuilder.append(dobule)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no gc
ACTUAL -
generate garbage
---------- BEGIN SOURCE ----------
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Measurement(iterations = 5, time = 1)
@Warmup(iterations = 5, time = 1)
@Fork(1)
public class StringBuilderDoublePerf {
private final StringBuilder b = new StringBuilder(128);
@Benchmark
@Threads(value = 1)
public StringBuilder appendDouble() {
b.setLength(0);
return b.append(123.d);
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(StringBuilderDoublePerf.class.getSimpleName())
.jvmArgs("-server",
"-XX:+UseG1GC",
"-Xmx2G",
"-XX:+AlwaysPreTouch"
)
// warmup
.addProfiler(GCProfiler.class)
.build();
new Runner(opt).run();
}
}
---------- END SOURCE ----------
FREQUENCY : always
Garbage is being generated when you call method StringBuilder.append(double).
I found that issue when I migrated from Java 17 to 21. We use LOGJ2 with garbage free configuration and now when you append double value append method generates garbage. It;s a problem because I see gc pauses every 1 second.
REGRESSION : Last worked in version 17.0.9
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
create any test when you call many times StringBuilder.append(dobule)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no gc
ACTUAL -
generate garbage
---------- BEGIN SOURCE ----------
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Measurement(iterations = 5, time = 1)
@Warmup(iterations = 5, time = 1)
@Fork(1)
public class StringBuilderDoublePerf {
private final StringBuilder b = new StringBuilder(128);
@Benchmark
@Threads(value = 1)
public StringBuilder appendDouble() {
b.setLength(0);
return b.append(123.d);
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(StringBuilderDoublePerf.class.getSimpleName())
.jvmArgs("-server",
"-XX:+UseG1GC",
"-Xmx2G",
"-XX:+AlwaysPreTouch"
)
// warmup
.addProfiler(GCProfiler.class)
.build();
new Runner(opt).run();
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-4511638 Double.toString(double) sometimes produces incorrect results
- Resolved