Repository navigation
Conversation
da20910 to
fbff475
Compare
| // The getLogger function is called on each panic to retrieve the current logger. | ||
| // The stop function performs a graceful shutdown: it signals the worker to stop | ||
| // accepting new tasks, drains remaining tasks, and waits for completion. | ||
| func spawnTaskRunner(buf int, getLogger func() log.Logger) (enqueue func(func()), stop func()) { |
There was a problem hiding this comment.
This section appears more complex than necessary. Could you consider streamlining it?
Also, it's not relevant to the consensus state and should be moved outside of this package
There was a problem hiding this comment.
Hi @swift1337 Thanks for the feedback, I don't know the testing scenario when the dev implement this feature, But I think the general idea is the move the critical path of the block execution to another executing thread. When a block has several hundred txs inside, it will create a lot of events which may increase some millisecond level's latency, for we are targeting the block time under 1 sec even lower, say 300~500ms, it might be a significant portion of it.
For the spawnTaskRunner, I will try to rework it in a better way.
There was a problem hiding this comment.
Just did some simple benchmark, assuming 1000txs in a block and 250 bytes per tx. The buffered eventBus consumes 1.4ms in a fireEvents call. Run with Apple m1 pro chip.
* Problem: async fireEvents could overlap follow up on cometbft#5 Solution: - create a task runner to run async tasks * don't wait for quit * cleanup
0da511e to
cc05df9
Compare
087a359 to
1b9b522
Compare
5240307 to
e94c7f9
Compare
…cosmos-sdk compatibility
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| tr.Enqueue(func() { | ||
| resultsCh <- i | ||
| }) | ||
| } |
There was a problem hiding this comment.
Test captures loop variable by reference in closure
Low Severity
The test "executes tasks in order" captures the loop variable i by reference inside the closure passed to Enqueue. In Go versions prior to 1.22, all closures share the same i variable, so by the time tasks execute, i will be 5 for all of them. The assertion require.Equal(t, []int{0, 1, 2, 3, 4}, results) would fail on older Go versions. While Go 1.22+ scopes loop variables per-iteration, this pattern is error-prone and the test may not actually verify FIFO ordering correctly on all supported Go versions.
|
I think this PR went off track. Closing |
Description
fireEventsis heavy in large block size. Consider to fire it async.crypto-org-chain#4 (comment)
Changes
Add an asyncRunner in
state/execution, it can be enabled by enable theasync_fire_eventsin config file.PR checklist
.changelog(we use unclog to manage our changelog)docs/orspec/) and code commentsNote
Enables asynchronous event dispatch during block execution to reduce blocking on large blocks, guarded by
consensus.async_fire_events(defaultfalse).libs/async.TaskRunnerand wires it intoconsensus/stateandstate/BlockExecutorto enqueuefireEventswhen enabled, with creation onStart, cleanup onStop, and recovery on failureconsensus.async_fire_events; defaults and tests added (consensus/state_test.go,libs/async/task_runner_test.go)eventBusisNopEventBusand preserves FIFO ordering with panic recoverycrypto/sr25519(priv/pub key types, batch verifier, JSON type registration) and dependency updatesproxy.NewConsensusSyncLocalClientCreatorfor consensus-serialized local ABCI interactionsWritten by Cursor Bugbot for commit 21eb886. This will update automatically on new commits. Configure here.