Skip to content

README: scaling notes, and an accurate comparison with Dunkels' - #27

Merged
LarryRuane merged 5 commits into
masterfrom
doc-scale
Oct 19, 2026
Merged

LarryRuane merged 5 commits into
masterfrom
doc-scale

Conversation

@LarryRuane

@LarryRuane LarryRuane commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Five doc commits:

  • The broadcast-cost paragraph no longer ties the cost to microcontrollers, and the PT_NWAIT entry says to raise it for large numbers of protothreads. With 1M waiters and the default 1024 buckets, a handoff took 67 us, against 117 ns with 2^20 buckets.
  • Links Dunkels' protothreads site instead of the PDF. The site is friendlier and links the paper.
  • The "Why another protothreads implementation?" list leads with the scheduler and wait channels. Nesting is no longer listed as a difference, since Dunkels' PT_SPAWN() nests the same way. Also fixes two related claims: only blocking inside a switch needs labels-as-values, and the bytes per thread over Dunkels' buy the wait lists, not nesting.
  • Says what Dunkels' scheduling looks like: no list of threads, with the application's loop calling every thread, blocked or not.
  • Explains why pt_wait() takes no condition, unlike Dunkels' PT_WAIT_UNTIL().

Also adds a TODO entry for growing the wait table at runtime.

The timer heap is a separate branch on top of this one, and will be its own PR once this is merged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs

LarryRuane and others added 5 commits October 19, 2026 09:05
The broadcast-cost paragraph framed the cost as small because
microcontrollers have few protothreads. The real point is how many
waiters share one channel, which holds on any hardware.

The PT_NWAIT entry only covered shrinking the table. With many more
waiters than buckets each wakeup walks a long list (measured: 67 us
per handoff with 1M waiters and 1024 buckets, 117 ns with 2^20), so
say to raise it.

Link Dunkels' protothreads site, which is friendlier and links the
paper, instead of the PDF.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
Wait channels and nesting are the two main differences from Dunkels'
protothreads. Put the scheduler first, since nesting's difference is
explained in terms of it, and say that a blocked thread takes no CPU
time however long it waits.

Add a TODO entry for growing the wait table at runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
Dunkels' PT_SPAWN() nests blocking functions the same way pt_call()
does: the parent re-calls the child on resume, at any depth, with
arguments. The difference is when the chain is re-entered, which is the
scheduler's doing, so say that in the scheduler bullet and drop the
separate nesting bullet.

Nesting works with Dunkels' switch-based version too, so only blocking
inside a switch needs labels-as-values. Likewise, the bytes per thread
over Dunkels' buy the wait lists, not nesting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
Dunkels' PT_WAIT_UNTIL() takes the condition as an argument, and a reader
may ask why pt_wait() doesn't. A bare wait can sit deep inside nested
control flow, with the code re-evaluating everything from the top after
it wakes, which is how some UTS kernel code was written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
"Leaves scheduling to the application" didn't say what that means.
His library has no list of threads; the application's loop calls each
one in turn, which acts like a single run list holding every thread,
blocked or not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
@LarryRuane
LarryRuane merged commit 236b520 into master Oct 19, 2026
31 checks passed
@LarryRuane
LarryRuane deleted the doc-scale branch October 19, 2026 17:06
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