-
Notifications
You must be signed in to change notification settings - Fork 64
perf: prefetch dispatch buffers and inline timestamp reads #1243
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,6 +145,10 @@ void SchedulerContext::dispatch_subtask_to_core( | |
| uint32_t buf_idx = reg_task_id & 1u; | ||
| PTO2DispatchPayload &payload = payload_per_core_[core_id][buf_idx]; | ||
| DeferredCompletionSlab *deferred_slab = &deferred_slab_per_core_[core_id][buf_idx]; | ||
| // Pull ownership of the per-core dispatch buffers before the hot stores below. | ||
| __builtin_prefetch(reinterpret_cast<const char *>(&payload), 1, 3); | ||
| __builtin_prefetch(reinterpret_cast<const char *>(&payload) + 64, 1, 3); | ||
| __builtin_prefetch(reinterpret_cast<const char *>(deferred_slab), 1, 3); | ||
| deferred_slab->count = 0; | ||
| deferred_slab->error_code = PTO2_ERROR_NONE; | ||
| AsyncCtx async_ctx = AsyncCtx::make(slot_state.task->task_id, deferred_slab); | ||
|
Comment on lines
+149
to
155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The prefetch for Additionally, // Pull ownership of the per-core dispatch buffers before the hot stores below.
__builtin_prefetch(reinterpret_cast<const char *>(&payload), 1, 3);
__builtin_prefetch(reinterpret_cast<const char *>(&payload) + 64, 1, 3);
__builtin_prefetch(reinterpret_cast<const char *>(&payload) + 384, 1, 3);
__builtin_prefetch(reinterpret_cast<const char *>(deferred_slab), 1, 3);
// Construct AsyncCtx first to give prefetch instructions some cycles to run
AsyncCtx async_ctx = AsyncCtx::make(slot_state.task->task_id, deferred_slab);
deferred_slab->count = 0;
deferred_slab->error_code = PTO2_ERROR_NONE; |
||
|
|
||
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.
The prefetch for
payloadonly covers the first two cache lines (offsets 0 and 64). However,build_payloadunconditionally writes tolocal_context(offset 384+) andnot_ready(offset 504), which reside in cache lines 6 and 7. Prefetching these tail cache lines prevents RFO cache misses on these hot stores.Additionally,
deferred_slabis written to immediately after its prefetch instruction, leaving no execution cycles to hide memory latency. Moving the construction ofasync_ctxbefore the writes provides a small execution window to overlap the prefetch.