Skip to content

features: speed up large feature responses by removing event-buffer auto boxing#534

Open
cportele wants to merge 1 commit into
masterfrom
opt-event-buffer
Open

features: speed up large feature responses by removing event-buffer auto boxing#534
cportele wants to merge 1 commit into
masterfrom
opt-event-buffer

Conversation

@cportele

Copy link
Copy Markdown
Contributor

FeatureEventBuffer tracked per-position buffer offsets and lengths in a Vector<Integer>. Every offset update in plus()/increase() boxed and unboxed an Integer and took the Vector's monitor, and plus() does this in a loop over all following positions for every token appended. On wide features and large result sets this dominated CPU.

Store the offsets in a primitive int[] of the same fixed size instead: plus() now does plain int[] arithmetic, start()/length() read by index, and reset() uses Arrays.fill. No behavioral change; the feature-pipeline tests pass unchanged.

Profiling a large response: Integer.valueOf dropped from ~15% of CPU to 0, the buffer's share fell from ~35% to ~14%, streaming throughput rose ~40%, and wall-clock dropped ~30%.

…utoboxing

FeatureEventBuffer tracked per-position buffer offsets and lengths in a
Vector<Integer>. Every offset update in plus()/increase() boxed and unboxed
an Integer and took the Vector's monitor, and plus() does this in a loop over
all following positions for every token appended. On wide features and large
result sets this dominated CPU.

Store the offsets in a primitive int[] of the same fixed size instead:
plus() now does plain int[] arithmetic, start()/length() read by index, and
reset() uses Arrays.fill. No behavioral change; the feature-pipeline tests
pass unchanged.

Profiling a large response: Integer.valueOf dropped from ~15% of CPU to 0,
the buffer's share fell from ~35% to ~14%, streaming throughput rose ~40%,
and wall-clock for large areas dropped ~30%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant