Skip to content

Feat/io wait#29

Draft
MikiEEE wants to merge 10 commits into
masterfrom
feat/io_wait
Draft

Feat/io wait#29
MikiEEE wants to merge 10 commits into
masterfrom
feat/io_wait

Conversation

@MikiEEE

@MikiEEE MikiEEE commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

This PR improves SmallOS I/O wait efficiency by keeping readiness registrations alive across scheduler iterations instead of rebuilding the complete polling set before every wait.

  • Adds optional Kernel.create_io_wait_set() support while preserving Kernel.io_wait() as the compatibility fallback.
  • Uses a persistent selector on Unix, with PollSelector on macOS based on benchmark results.
  • Reuses poll()/ipoll() registrations on supported MicroPython platforms.
  • Updates registrations only when read/write interests change.
  • Removes the duplicate zero-time wait before an idle blocking wait.
  • Adds OSList.has_ready() for checking runnable work without dequeuing it.
  • Includes deterministic lifecycle tests and an I/O benchmark.
  • Adds no runtime dependencies and preserves custom-kernel compatibility.

Performance

Local macOS benchmark results:

  • 256 idle descriptors: 91.62 μs → 35.45 μs (2.58x)
  • 256 descriptors, one ready: 80.85 μs → 26.46 μs (3.06x)
  • Runnable scheduler with one watcher: 20.26 μs → 14.29 μs (1.42x)

Validation

  • All 83 unit tests pass.
  • Unix and MicroPython-style persistent polling paths are covered.
  • Tests cover registration deltas, cancellation, restart, descriptor reuse,
    invalid descriptors, combined masks, error events, and snapshot fallback.
  • demos/unix_demo.py passes.
  • Package build, wheel smoke test, compilation, documentation indexing, and
    git diff --check pass.

Follow-up

The execution-adapter work lives on a separate branch. Once merged, adapter
completion sources should use the same first/last-source delta registration
path.

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