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

Enable single-tree transactional concurrency #56

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

ecton
Copy link
Member

@ecton ecton commented May 30, 2022

This introduces a third ActiveState that is managed on a
per-committing-transaction basis. Rather than wait to release the locks
on trees until after the transaction is fully synchronized, these
changes release the locks after the file is fsynced but before the
transaction log is synced.

Before the transaction log is synced and the locks are released, the
write state is cloned. After the transaction is confirmed, the state is
published (taking care to ensure an older state doesn't overwrite a
newer state since the OS controls waking threads).

This works, but doesn't really offer parallelism due to the inability to
batch the fsync operations. To complete this work, I need to figure out
a good way to let the transaction manager issue the fsync commands, but
be smart enough to only do it once per tree per batched commit.
@ecton ecton marked this pull request as draft May 30, 2022 00:08
ecton added 2 commits May 30, 2022 10:59
The limiting factor of the last commit was that each write operation on
each tree still had its own fsync operation. This change moves the
responsibility of fsyncing to the transaction manager, which supports
batching multiple transactions together already.

Now the transaction manager keeps a unique list of paths that need to be
synchronized as part of the batch. This allows multiple pending
transactions for a single tree to pile up while waiting on the current
batch to be fsynced.

This is safe because when opening a file with a transaction manager, the
file is automatically rolled back to the last confirmed transaction id.
The transaction manager ensures each tree is fsynced before writing the
transaction log entry and fsyncing the transaction. All new data written
by pending transactions will be rolled back if a power loss occurs while
the next batch is being fsynced unless the transaction log is fully
synced.

These changes allowed a significant speedup to BonsaiDb's commerce
benchmark, and the new bottleneck is the reliance on two fsyncs.
Now returns the current read sequence rather than write.
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.

1 participant