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

db: use atomic for versionSet.nextFileNum #3986

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

itsbilal
Copy link
Member

Currently, we have the nextFileNum counter protected by db.mu, which is pretty unnecessary and results in us grabbing the db mutex just for being able to generate a new filenum. This change moves that to an atomic.

Currently, we have the nextFileNum counter protected by db.mu,
which is pretty unnecessary and results in us grabbing the db
mutex just for being able to generate a new filenum. This change
moves that to an atomic.
@itsbilal itsbilal requested a review from a team as a code owner September 30, 2024 18:53
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 5 files reviewed, all discussions resolved (waiting on @sumeerbhola)

@RaduBerinde
Copy link
Member

OOC, what motivated this change? I'd think generating a new file happens much too rarely for lock vs atomic to matter?

@itsbilal
Copy link
Member Author

@RaduBerinde the motivation was #3926, where the only difference between the multiple callers to db.excise is whether they have db.mu held or not

@itsbilal
Copy link
Member Author

TFTR!

@itsbilal itsbilal merged commit eb9d37a into cockroachdb:master Sep 30, 2024
12 checks passed
@RaduBerinde
Copy link
Member

Nice, that makes a lot of sense!

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