ReleaseMicrosoftMicrosoftpublished May 5, 2026seen 4d

microsoft/bocpy v0.5.0

microsoft/bocpy

Open original ↗

Captured source

source ↗
published May 5, 2026seen 4dcaptured 13hhttp 200method plain

v0.5.0

Repository: microsoft/bocpy

Tag: v0.5.0

Published: 2026-05-05T10:28:05Z

Prerelease: no

Release notes:

Highlights

This release delivers a Verona-RT-style work-stealing scheduler, a global noticeboard (shared key-value store), removal of the central scheduler thread in favour of direct dispatch, and a major C source refactor into per-subsystem translation units with a portable atomics layer.

---

New Features

  • Work-stealing scheduler — the single behavior queue is replaced with a distributed scheduler. Each worker owns an MPMC behavior queue, pops locally first, and steals from peers when idle. Idle workers park on per-worker condition variables and are signalled directly by producer/victim.
  • Per-worker fairness tokens — a token node advances through each worker's queue so long-running behaviors cannot monopolise dispatch slots; also drives cooperative shutdown.
  • Noticeboard — a shared key-value store (up to 64 keys) readable/writable without acquiring cowns. Writes are non-blocking; reads return a cached per-behavior snapshot. Includes notice_write, notice_read, notice_update, notice_delete, notice_sync, noticeboard_version, and the REMOVED sentinel.
  • Distributed scheduler — two-phase locking, request linking, and dispatch run directly on the caller's thread in C; cown release runs on the executing worker. MCS-style intrusive linked list per cown for zero-bounce handoff.
  • `Cown.exception` property — indicates whether the held value is from an unhandled exception.
  • `compat.h` / `compat.c` portability layer — uniform BOCMutex, BOCCond, boc_atomic_*_explicit, monotonic-time, and sleep primitives across MSVC, pthreads, and C11 ``.
  • `xidata.h` cross-interpreter shim — centralised _PyXIData_* / _PyCrossInterpreterData_* version ladders for CPython 3.12–3.15 (including free-threaded builds).
  • `fanout_benchmark` example — fan-out/fan-in benchmark exercising scheduler throughput under heavy producer load.
  • Prime factor example (examples/prime_factor.py) — parallel factorisation via Pollard's rho with noticeboard-coordinated early termination.
  • Benchmark harness (examples/benchmark.py) — micro-benchmarks for scheduling throughput, message-queue latency, and noticeboard contention.

Bug Fixes

  • Transpiler aliased importsvisit_Import / visit_ImportFrom now track alias names (import X as Y), preventing spurious "name not found" errors and duplicate whencall injection.
  • Global variable capture@when closure capture falls back to frame.f_globals when a name is not in any local scope, fixing NameError for module-level variables.

Improvements

  • In-memory transpiled-module loading — workers exec the transpiled source from a string literal instead of writing to disk, eliminating filesystem round-trips and leftover .py files.
  • Nested `@when` capture — the transpiler recurses into nested @when-decorated functions when computing outer captures, so child behaviors can close over the outer frame.
  • C extension split_core.c reduced from ~5,000 to ~3,500 lines by extracting sched.{c,h}, noticeboard.{c,h}, terminator.{c,h}, tags.{c,h}, cown.h, compat.{c,h}, and xidata.h.
  • Direct dispatch on cown releasebehavior_release_all hands resolved successors directly to workers via boc_sched_dispatch, removing one queue hop per handoff.
  • Cooperative worker shutdownboc_sched_worker_request_stop_all / boc_sched_unpause_all provide a clean stop/drain protocol.
  • Matrix docstrings — all Matrix C methods now carry built-in docstrings.
  • Examples package relocated — moved to top-level examples/ directory (still importable as bocpy.examples).
  • Filtered PyPI READMEsetup.py strips `` regions before publishing.
  • Documentation refresh — expanded coverage of noticeboard, distributed scheduler, and new APIs.

Internal Test Modules (opt-in via BOCPY_BUILD_INTERNAL_TESTS=1)

  • _internal_test_atomics — correctness tests for compat.h typed-atomics.
  • _internal_test_bq — torture tests for the MPMC behavior queue.
  • _internal_test_wsq — tests for work-stealing primitives (fast pop, slow pop, steal, park/unpark).

Test Suite

  • test_noticeboard.py — snapshot semantics, notice_update atomicity, REMOVED, notice_sync, version monotonicity.
  • test_scheduler_integration.py, test_scheduler_stats.py, test_scheduler_steal.py — end-to-end and per-primitive scheduler tests.
  • test_compat_atomics.py — portable atomics smoke tests.
  • test_stop_retry_composition.pystop()/start()/wait() retry composition.
  • test_scheduling_stress.py — expanded with fan-out, work-stealing, and shutdown stress scenarios.
  • test_transpiler.py — AST extraction, capture rewriting, aliased imports, module export.

---

Full changelog: v0.3.1...v0.5.0

Notability

notability 3.0/10

Minor library version update.