Skip to content

Avoid lambda allocation in AtomicInteger max update in MutablePQVectors#639

Open
michaeljmarshall wants to merge 1 commit intodatastax:mainfrom
michaeljmarshall:reduce-alloc
Open

Avoid lambda allocation in AtomicInteger max update in MutablePQVectors#639
michaeljmarshall wants to merge 1 commit intodatastax:mainfrom
michaeljmarshall:reduce-alloc

Conversation

@michaeljmarshall
Copy link
Member

This is a minor optimization to reduce object allocations on the hot path when we're adding vectors to MutablePQVectors. The object allocation happens when we have a capturing lambda, which is different on every call to this method. Instead, we can use the accumulateAndGet method, which takes the value we want to offer and then takes a non-capturing lambda Math::max, which means we won't allocate an object per call.

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