Skip to content

Check for last chunk before acquiring lock #3066

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

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

SirYwell
Copy link
Member

@SirYwell SirYwell commented Jan 7, 2025

Overview

Description

Acquiring/releasing the lock in getOrCreateChunk takes a fair amount of time, even with no contention involved. By simplifying from two volatile variables to one, we can already have a fast path before the lock, This cuts the time spent in the method in half in my measurements.

One downside is the scenario where many calls result in NullChunk.getInstance() being returned, as we can't check for the coordinates there. If that is a problem, it might make sense to just create multiple NullChunk objects with their actual coordinates.

### Submitter Checklist
- [x] Make sure you are opening from a topic branch (**/feature/fix/docs/ branch** (right side)) and not your main branch.
- [x] Ensure that the pull request title represents the desired changelog entry.
- [x] New public fields and methods are annotated with `@since TODO`.
- [x] I read and followed the [contribution guidelines](https://github.com/IntellectualSites/.github/blob/main/CONTRIBUTING.md).

@SirYwell SirYwell requested a review from a team as a code owner January 7, 2025 07:39
Copy link
Member

@dordsor21 dordsor21 left a comment

Choose a reason for hiding this comment

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

I don't think there's any reason for NullChunk to be an issue

@dordsor21 dordsor21 requested a review from a team January 7, 2025 20:45
@dordsor21 dordsor21 merged commit cdd0dc8 into main Jan 11, 2025
9 checks passed
@dordsor21 dordsor21 deleted the perf/STQE-fastpath-before-lock branch January 11, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants