Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce allocation rate in HNSW concurrent merge #14011

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

viliam-durina
Copy link
Contributor

The PR removes the allocation of a new LockedRow for each locking operation in HnswLock. Even though the object was very quickly released, and JIT supports on-stack allocation, it didn't happen in my experiments on OpenJDK 21 - it's easy to avoid the allocation, rather than rely on the JIT.

Comparison of the change processing the same workload. The effect on overall execution time was negligible.

Before:
image

After:
image

The PR removes the allocation of a new `LockedRow` for each locking operation in `HnswLock`. Even though the object was very quickly released, and JIT supports on-stack allocation, it didn't happen in my experiments on OpenJDK 21 - it's easy to avoid the allocation, rather than rely on the JIT.
@msokolov
Copy link
Contributor

Thanks @villam-durina! This looks good. I guess we were trying to enforce access to the rows, requiring that callers acquire a lock to obtain them, but it was really just a fig leaf anyway, since you could still just get the row through the normal unlocked API anyway, so this doesn't really eliminate any safety. I'll merge

@msokolov msokolov merged commit 532d267 into apache:main Nov 22, 2024
3 checks passed
@benwtrent
Copy link
Member

@msokolov we should have CHANGES for this & it could be back ported to 10.1. Its a nice optimization that we should track.

@viliam-durina
Copy link
Contributor Author

@benwtrent #14018

viliam-durina added a commit to viliam-durina/apache-lucene that referenced this pull request Dec 2, 2024
The PR removes the allocation of a new `LockedRow` for each locking operation in `HnswLock`. Even though the object was very quickly released, and JIT supports on-stack allocation, it didn't happen in my experiments on OpenJDK 21 - it's easy to avoid the allocation, rather than rely on the JIT.

(cherry picked from commit 532d267)
viliam-durina added a commit to viliam-durina/apache-lucene that referenced this pull request Dec 4, 2024
The PR removes the allocation of a new `LockedRow` for each locking operation in `HnswLock`. Even though the object was very quickly released, and JIT supports on-stack allocation, it didn't happen in my experiments on OpenJDK 21 - it's easy to avoid the allocation, rather than rely on the JIT.

(cherry picked from commit 532d267)
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.

3 participants