Reduce default size of diagnostic buffer for FlightRecorderInputStream
from 1MiB to 1KiB
#770
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One of the main side effects of the bug fixed by jenkinsci/google-compute-engine-plugin#478 was that each failed connection caused a 1MiB buffer to be retained by a
FlightRecorderInputStream
, leading to high memory usage. This buffer is only used to print a hex dump of the stream contents in case of a stream corruption error, and so having it be a full 1MiB by default seems unnecessary, and if there is something interesting in the dump, it is probably right at the end.I considered disabling the buffer completely by making the default value 0, but that requires a few changes to avoid
ArrayIndexOutOfBoundsException
and improve the error messages, so it seemed more expedient to just reduce the default buffer size.In the real-world case we observed, there were around 600 instances of this class in memory, so this patch would have cut ~600MB of memory used by these buffers down to around ~600KB.
See jenkinsci/jenkins#9887 for the matching core PR.
Testing done
Only tested using the existing automated tests in
FlightRecorderInputStreamTest
andDiagnosedStreamCorruptionExceptionTest
.Submitter checklist