Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
7d6d192 to
684dbf6
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@benchmark/src/libfork_benchmark/fib/fib.hpp`:
- Around line 86-90: The pop() method currently calls work.back() and
work.pop_back() unconditionally which is undefined if the member vector work is
empty; update lf::work_handle pop() noexcept to defensively check work.empty()
(or assert) before accessing: either add an assertion (e.g.,
assert(!work.empty())) and keep behavior, or return a defined sentinel
lf::work_handle (or std::nullopt-equivalent) when empty; ensure the chosen
approach adjusts the noexcept/specifier and callers of pop() to handle the
sentinel or rely on the assert.
In `@benchmark/src/libfork_benchmark/fib/lf_parts.cpp`:
- Around line 125-127: The leak check currently only compares tls_bump_ptr
against buf.get(), so benchmarks that use the global allocator (e.g.,
no_await<global_bump>, await<global_bump>) that manipulate bump_ptr can leak
undetected; update the check in lf_parts.cpp to verify both tls_bump_ptr and
bump_ptr equal buf.get(), and call LF_TERMINATE("Stack leak detected") (or a
similar error) if either pointer != buf.get() so both thread-local and global
bump allocators are validated.
🧹 Nitpick comments (1)
src/core/context.cxx (1)
17-21: Consider constrainingpushreturn type for consistency.The
contextconcept constrainspop()to returnwork_handle, butpushhas no return type constraint. Ifpushshould always returnvoid, consider making that explicit for stricter concept checking.♻️ Optional: Add explicit return type constraint
template <typename T> concept context = requires (T &ctx, work_handle h) { - { ctx.push(h) }; + { ctx.push(h) } -> std::same_as<void>; { ctx.pop() } noexcept -> std::same_as<work_handle>; };
There was a problem hiding this comment.
Pull request overview
This PR introduces foundational “fork” infrastructure for libfork v4 by adding new core module partitions (ops/context), expanding frame metadata, and updating promise final-suspend logic and benchmarks/tests to exercise the new behavior.
Changes:
- Add
libfork.core:ops(call/fork packaging) andlibfork.core:context(work handles + TLS context) and wire them intolibfork.core/promise. - Extend coroutine frame metadata (
category, cancellation, merge/steal bookkeeping) and update tuple accessor implementation. - Update benchmarks and tests to use the new root/fork mechanics and new allocators/contexts.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| test/src/tuple.cpp | Adds forced instantiation of tuple accessors; introduces an any helper and extra get<0>() calls. |
| src/core/utility.cxx | Adds safe_cast, not_null, and a defer scope guard utility. |
| src/core/tuple.cxx | Adjusts tuple::get implementation to use an explicit cast for cvref propagation. |
| src/core/promise.cxx | Major update: introduces fork/call awaitables, context integration, and new final_suspend logic. |
| src/core/ops.cxx | New partition defining exported call()/fork() helpers and internal packages. |
| src/core/frame.cxx | Adds category enum and expands frame_type with fork-related bookkeeping fields. |
| src/core/core.cxx | Reorders/tiers module exports and exports new partitions (ops, context). |
| src/core/context.cxx | New partition defining work_handle, context concept, polymorphic context, and TLS thread_context. |
| src/core/concepts.cxx | Updates task forward declaration to include a Context parameter. |
| include/libfork/__impl/assume.hpp | Renames LF_ASSERT to LF_ENSURE and adjusts LF_ASSUME debug behavior. |
| benchmark/src/libfork_benchmark/fib/lf_parts.cpp | Updates fib benchmarks to mark tasks as root, adds fork/call benchmark variants, and wires TLS context pointers. |
| benchmark/src/libfork_benchmark/fib/fib.hpp | Replaces old bump allocator with TLS/global bump allocators and adds a vector-backed context implementation. |
| benchmark/src/libfork_benchmark/fib/baremetal.cpp | Updates baremetal coroutine benchmark to use the new TLS bump allocator pointer. |
| CMakeUserPresets.json | Enables CMAKE_COLOR_DIAGNOSTICS for dev/bench presets. |
| CMakeLists.txt | Adds new module sources (ops.cxx, context.cxx) to the build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary by CodeRabbit
New Features
Improvements
Refactoring
Tests