Pre-size StringBuilder in SequenceScanner::get_sub_sequence
On 282c3bb3, SequenceScanner::get_sub_sequence()
takes a StringBuilder to which sequence symbols are appended. JFR recordings show a significant amount of time is spent growing and recreating the StringBuilder's internal array:
(Verified result with two other recordings of identical runs, recordings cannot be attached due to size limitations)
Because the size of the resulting string is known at call time (the l
parameter denotes the length of the region), the StringBuilder should be pre-sized with ensureCapacity()
.
In addition, we should throw a RuntimeException if the position and length of the region would yield an invalid sequence, instead of failing silently.
Lastly, the performance impact should be assessed with replicated mapping runs.
Edited by Moed, Matthijs