-
Notifications
You must be signed in to change notification settings - Fork 12
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
abci: use a semaphore for commit/apply/beginblock #196
Conversation
417efb2
to
a1f5814
Compare
Note for the inevitable cometbft v0.38 upgrade: we'll probably switch to the "connection-synchronized local client" using |
Let's try this now that kwild is running again |
a1f5814
to
ce20b1a
Compare
Consensus method requests from cometbft are synchronous, but a portion of the work of Commit is launched in a goroutine, so we block a subsequent BeginBlock from starting new changes. We do this by acquiring a semaphore with max concurrency of 1 at the start of BeginBlock, and releasing it when the changes from Commit have finished applying. A mutex is rarely held for longer than the duration of a local function, while a waitgroup does not provide atomic Wait/Add semantics that fit here.
ce20b1a
to
083bfdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Consensus method requests from cometbft are synchronous, but a portion of the work of Commit is launched in a goroutine, so we block a subsequent BeginBlock from starting new changes. We do this by acquiring a semaphore with max concurrency of 1 at the start of BeginBlock, and releasing it when the changes from Commit have finished applying. A mutex is rarely held for longer than the duration of a local function, while a waitgroup does not provide atomic Wait/Add semantics that fit here. Co-authored-by: Brennan Lamey <[email protected]>
Consensus method requests from cometbft are synchronous, but a portion of the work of Commit is launched in a goroutine, so we block a subsequent BeginBlock from starting new changes. We do this by acquiring a semaphore with max concurrency of 1 at the start of BeginBlock, and releasing it when the changes from Commit have finished applying. A mutex is rarely held for longer than the duration of a local function, while a waitgroup does not provide atomic Wait/Add semantics that fit here. Co-authored-by: Brennan Lamey <[email protected]>
Consensus method requests from cometbft are synchronous, but a portion of the work of Commit is launched in a goroutine, so we block a subsequent BeginBlock from starting new changes. We do this by acquiring a semaphore with max concurrency of 1 at the start of BeginBlock, and releasing it when the changes from Commit have finished applying. A mutex is rarely held for longer than the duration of a local function, while a waitgroup does not provide atomic Wait/Add semantics that fit here. Co-authored-by: Brennan Lamey <[email protected]>
Consensus method requests from cometbft are synchronous, but a portion of the work of Commit is launched in a goroutine, so we block a subsequent BeginBlock from starting new changes. We do this by acquiring a semaphore with max concurrency of 1 at the start of BeginBlock, and releasing it when the changes from Commit have finished applying. A mutex is rarely held for longer than the duration of a local function, while a waitgroup does not provide atomic Wait/Add semantics that fit here. Co-authored-by: Brennan Lamey <[email protected]>
Consensus method requests from cometbft are synchronous, but a portion of the work of Commit is launched in a goroutine, so we block a subsequent BeginBlock from starting new changes. We do this by acquiring a semaphore with max concurrency of 1 at the start of BeginBlock, and releasing it when the changes from Commit have finished applying. A mutex is rarely held for longer than the duration of a local function, while a waitgroup does not provide atomic Wait/Add semantics that fit here. Co-authored-by: Brennan Lamey <[email protected]>
Consensus method requests from cometbft are synchronous, but a portion of the work of Commit is launched in a goroutine, so we block a subsequent BeginBlock from starting new changes. We do this by acquiring a semaphore with max concurrency of 1 at the start of BeginBlock, and releasing it when the changes from Commit have finished applying. A mutex is rarely held for longer than the duration of a local function, while a waitgroup does not provide atomic Wait/Add semantics that fit here. Co-authored-by: Brennan Lamey <[email protected]>
This replaces the WaitGroup that was being use to block
BeginBlock
calls until the asynchronous portion of a previousCommit
is applied. This is better than either a mutex or a waitgroup for this use case.I'm still not certain what is gained by having a portion of the Commit operation being asynchronous however. I can't identify what we are unblocking in CometBFT by having
Commit
return earlier. AFAICT, the four "connections" that Comet establishes with our application are generally independent. The "local client" does have a single mutex for all for connections, but in general these are independent, and the "connection synchronized" local client and all the remote client options have independent connections for the different contexts. SeeNewConnSyncLocalClientCreator
in cometbft code.