Skip to content

perf: compact coroutine and I/O state member layouts - #13

Open
thweetkomputer wants to merge 1 commit into
mainfrom
perf/compact-member-layouts
Open

thweetkomputer wants to merge 1 commit into
mainfrom
perf/compact-member-layouts

Conversation

@thweetkomputer

@thweetkomputer thweetkomputer commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Coroutine promises, cross-worker awaiters, and I/O state currently place small fields between pointer-aligned members. Group those fields to reduce padding while preserving member types, ownership, and execution behavior.

Measured on AArch64 with GCC 13.3 and Clang 18, with cross-core latency tracing disabled:

Type Before After
RemoteWork 40 B 24 B
SubmitAwaiter with one pointer capture 56 B 40 B
SubmitTaskAwaiter with one pointer capture 64 B 48 B
Task<absl::Status>::promise_type 48 B 40 B
Task<absl::StatusOr<size_t>>::promise_type 56 B 48 B
SizeIoAwaitable 96 B 88 B
OpenFixedFileAwaitable 96 B 88 B
Connection 240 B 232 B

Keep RemoteWork's trace timestamps before its small bookkeeping fields so derived awaiters can reuse base tail padding with tracing enabled as well. Update the storage awaitable constructors to match declaration order. Promise savings depend on the result type; Task<int> is unchanged.

Validation:

  • Actual-header size probes pass with GCC 13.3 and Clang 18, with cross-core latency tracing both disabled and enabled.
  • Existing task_transfer_check independently built and passed with both compilers in Debug mode, including its 512 KiB stack, cancellation ownership, and reentrant callback cases.
  • storage.cpp passes -Werror=reorder syntax checking.
  • Embedded Lavik Debug build passed, all 856 Lavik unit tests passed, and all nine selected CTest regressions passed, including all four bycorf_* checks. Exact build/test commands are recorded in the companion Lavik PR.
  • pre-commit run --files include/bycorf/io/storage.h include/bycorf/net/connection.h include/bycorf/runtime/cross_core.h include/bycorf/runtime/task.h src/io/storage.cpp and git diff --check pass.

These are public C++ layout changes, so consumers must rebuild together. No wire format, persistent format, cache-line isolation contract, or architecture flow changes. Local layout intent is documented near the affected members. The coroutine frame pool rounds allocations to size classes; smaller sizeof alone does not establish an RSS or throughput improvement. Performance comparison is the follow-up.

The benchmark baseline is the Lavik-pinned Bycorf commit 7904686; this branch intentionally excludes the unrelated newer DPDK transmit change.

Companion integration and benchmark PR: eloqdata/lavik#317.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a9bc042-329f-4494-a68e-f01c29d99cd4

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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