Skip to content

perf: add in-place fast path for ScalarValue::add#20959

Open
kumarUjjawal wants to merge 2 commits intoapache:mainfrom
kumarUjjawal:perf/scalar_add
Open

perf: add in-place fast path for ScalarValue::add#20959
kumarUjjawal wants to merge 2 commits intoapache:mainfrom
kumarUjjawal:perf/scalar_add

Conversation

@kumarUjjawal
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Issue #20933 called out that ScalarValue::add was doing unnecessary work in hot paths such as statistics merging.

The original suggestion was to mutate the lhs accumulator rather than alwaysbuilding a new scalar. This patch follows that direction and keeps the optimization in ScalarValue itself, which is a better long-term fit than duplicating specialized addition logic only in the stats code.

What changes are included in this PR?

This change adds an in-place fast path for ScalarValue::add / add_checked for same-type numeric and decimal values.

The patch also updates statistics merging to reuse the existing sum_value accumulator instead of creating a new ScalarValue for each addition.

Are these changes tested?

Yes

Are there any user-facing changes?

@github-actions github-actions bot added the common Related to common crate label Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve performance of ScalarValue::add

1 participant