Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.12.3
Description
Profiling of a Spark application revealed a performance issue in production:
CapacityByteArrayOutputStream.setByte consumed 2.2% of total CPU time and made up 4.6% of total allocations. However, in normal case, this method should allocate nothing at all.
Here is an excerpt from async-profiler report.
CPU profile:
Allocation profile:
The reason is a checkArgument() call with an unconditionally constructed dynamic String:
The suggested fix is to move String construction under the condition:
if (index >= bytesUsed) { throw new IllegalArgumentException("Index: " + index + " is >= the current size of: " + bytesUsed); }