Skip to content

TLS13-C13: cut the guest stack cost of signature verification by 17 KiB - #1321

Merged
drawmeanelephant merged 1 commit into
mainfrom
agent/autocoder/tls13-c13
Sep 15, 2026
Merged

drawmeanelephant merged 1 commit into
mainfrom
agent/autocoder/tls13-c13

Conversation

@drawmeanelephant

Copy link
Copy Markdown
Owner

Follow-up to #1299, which is where the class-B gate first ran and measured a 79,856-byte stack frame in FETCHS.BIN against the guest's 32,768-byte stack.

The contributor was the certificate-signature path, inlined end-to-end into the handshake frame: chain validation → RSA/ECDSA verify → bigint modexp, each carrying its working sets, all summed into one frame.

A hard call boundary on the three verification entry points:

largest frame in FETCHS.BIN   79,856 B  ->  62,784 B   (-21%)
second largest                34,032 B  ->  34,032 B

noinline here is a stack-budget statement, not a performance one — these run a handful of times per handshake, and the alternative was a frame no guest task can hold.

This does not close the gap. 62,784 B still exceeds 32,768 B. It is committed because it is a strict improvement with no semantic change, and because it is the measured starting point for the remaining decision:

  • restructure the client further, or
  • raise the per-task stack — kernel-wide, and visible to the verify-bss-budget gate.

zig build test: 200/200 steps, 3599/3599 tests.

Measured, not guessed. The class-B gate's fault pointed at a 79,856-byte stack
frame in FETCHS.BIN against the guest's 32,768-byte stack. The contributor was
the certificate-signature path, inlined end-to-end into the handshake frame:
chain validation -> RSA/ECDSA verify -> bigint modexp, each carrying its working
sets, all summed into one frame.

A hard call boundary on the three verification entry points:

  largest frame in FETCHS.BIN   79,856 B  ->  62,784 B   (-21%)
  second largest                34,032 B  ->  34,032 B

`noinline` here is a stack-budget statement, not a performance one: these run a
handful of times per handshake, and the alternative was a frame no guest task
can hold.

Stated plainly: this does NOT close the gap. 62,784 B still exceeds 32,768 B.
It is committed because it is a strict improvement with no semantic change, and
because it is the measured starting point for the remaining decision -- a
further client restructure, or a larger per-task stack (kernel-wide, and
visible to the verify-bss-budget gate).

zig build test: 200/200 steps, 3599/3599 tests.
@drawmeanelephant
drawmeanelephant merged commit c7974d6 into main Sep 15, 2026
9 checks passed
@drawmeanelephant
drawmeanelephant deleted the agent/autocoder/tls13-c13 branch September 15, 2026 12:49
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