Skip to content

Conversation

@sususu5
Copy link

@sususu5 sususu5 commented Dec 9, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 9, 2025 15:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an async task executor to the axtask module, enabling asynchronous task execution alongside the existing synchronous task system. The implementation adds a global ready queue for async tasks with spawn, polling, and execution control functions.

Key changes:

  • New async executor module with task spawning and execution control (run_once, run_for, run_until_idle)
  • Integration with existing block_on to drive executor tasks during synchronous future polling
  • Comprehensive test coverage for executor fairness, self-wake, and execution control

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
modules/axtask/src/executor.rs New async executor implementation with ready queue, AsyncTask wrapper, and execution control functions
modules/axtask/src/lib.rs Adds executor module to the crate's public API
modules/axtask/src/api.rs Initializes executor during scheduler initialization
modules/axtask/src/task.rs Changes TaskId::new() visibility from private to pub(crate) for executor use
modules/axtask/src/future/mod.rs Integrates executor into block_on by polling up to 3 async tasks per iteration
modules/axtask/src/tests.rs Adds comprehensive test suite for executor functionality including completion, self-wake, fairness, and run_for tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AsakuraMizu
Copy link

Good job 👍

@sususu5
Copy link
Author

sususu5 commented Dec 11, 2025

Good job 👍

What should be the focus of the next optimization? Scaling the async task queue to per-CPU, or optimizing the Waker implementation?

@sususu5 sususu5 force-pushed the feat-async-executor branch from 7891b07 to de8ea45 Compare December 11, 2025 14:30
Copilot AI review requested due to automatic review settings December 11, 2025 14:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 74 to 76
// Polling the executor to run up to three async tasks
// (may run fewer if the queue has fewer ready tasks).
let _ = executor::run_for(3);
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 3 for max async tasks to run is unexplained. Consider extracting this as a named constant (e.g., MAX_ASYNC_TASKS_PER_POLL) to clarify why this specific value was chosen and make it easier to tune if needed.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings December 13, 2025 05:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sususu5 sususu5 force-pushed the feat-async-executor branch from 806ca9d to 290b4a3 Compare December 21, 2025 12:11
Copilot AI review requested due to automatic review settings December 22, 2025 16:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +116 to +118
pub fn find_area(&self, vaddr: VirtAddr) -> Option<&MemoryArea<Backend>> {
self.areas.find(vaddr)
}
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new find_area method is identical to the existing find_area_mut method on line 113 (which also calls self.areas.find(vaddr)). The only difference is that find_area_mut returns a mutable reference. This creates duplicate logic. Consider whether this new method is necessary, or if callers should use find_area_mut and simply not mutate the result.

Copilot uses AI. Check for mistakes.
READY_QUEUE.with_current(|q| q.is_empty())
}

pub fn run_until_idle() {
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 64 for SPIN_LIMIT lacks explanation. Consider adding a comment explaining why this specific value was chosen and what trade-offs it represents between spinning and yielding.

Suggested change
pub fn run_until_idle() {
pub fn run_until_idle() {
// Number of consecutive spin iterations before yielding the CPU.
// 64 is a small power-of-two chosen as a compromise: it allows short-lived
// bursts of wakeups to be handled without an expensive scheduler yield,
// while still bounding the time spent busy-waiting when the system is idle.

Copilot uses AI. Check for mistakes.
@sususu5
Copy link
Author

sususu5 commented Dec 23, 2025

Per-CPU Async Architecture

  • Implemented AxExecutor with per-CPU ready queues: Localizes task scheduling to reduce lock contention and improve cache locality on multi-core systems.

Optimized block_on Logic

  • Refactored block_on: Efficiently drives async tasks while waiting for a future. The new flow ensures the current thread blocks (parks) only when:
    1. The main future is still Pending.
    2. The local run queue is fully drained.
    3. No new wakeups occurred during the drain phase (preventing lost wakeups).

Tests

  • Added unit tests covering the executor's lifecycle, queue operations, and per-CPU scheduling behavior to ensure correctness.

@AsakuraMizu AsakuraMizu marked this pull request as draft December 25, 2025 10:39
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.

2 participants