Skip to content

perf(util-endpoints): reduce temporary object allocations#1957

Open
trivikr wants to merge 10 commits intomainfrom
remove-object-allocation-evaluate-condition
Open

perf(util-endpoints): reduce temporary object allocations#1957
trivikr wants to merge 10 commits intomainfrom
remove-object-allocation-evaluate-condition

Conversation

@trivikr
Copy link
Copy Markdown
Contributor

@trivikr trivikr commented Apr 14, 2026

Issue

Internal JS-6645

Description

Remove rest spread destructuring that created a new object on every call, and replace conditional spread in the return with an early return branch to avoid temporary object allocation.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr requested a review from a team as a code owner April 14, 2026 21:44
@trivikr trivikr changed the title perf(util-endpoints): reduce allocations in evaluateCondition perf(util-endpoints): reduce object allocations Apr 14, 2026
@trivikr trivikr changed the title perf(util-endpoints): reduce object allocations perf(util-endpoints): reduce temporary object allocations Apr 14, 2026
@trivikr trivikr force-pushed the remove-object-allocation-evaluate-condition branch from b96ce29 to 6a00f07 Compare April 14, 2026 22:47
...options.referenceRecord,
...conditionsReferenceRecord,
},
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we confirm no edge case relied on this? the diff seems to result in a potentially different set of objects

if it can be proven this is all part of the same evaluation's lifecycle, maybe even the initial copy isn't necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing we could do is run the full AWS endpoint test suite

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not changing the behavior. The conditionOptions object was additive even before. We're just not creating new object for every call.

The test needs to check the first call received an empty referenceRecord at call time, but the spy only holds a reference that's since been mutated. That's why tests had to be updated.

@trivikr trivikr requested a review from kuhe April 15, 2026 01:10
@trivikr trivikr force-pushed the remove-object-allocation-evaluate-condition branch from ccc8015 to 78eb850 Compare April 15, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants