Repository navigation
perf: accelerate C906 WebSocket masking - #497
Conversation
dormancygrace
left a comment
There was a problem hiding this comment.
The assembly looks correct.
What I checked:
- Every
th.*WORD decodes to the instruction in its comment, and the generator's--checkpasses. - Key rotation by
pos&3is right, including forpos == 0and for fragmented payloads. - The tail
vsetvlinever reads past the slice. mask_other.gois the exact complement of the riscv64 build tag.- On the host,
go testfor the module passes in default andpuregomodes, riscv64go vetandgo test -care clean, andtests/test-websocket-c906.pypasses.
I could not run the device tests (XTheadVector).
The two comments below are about build maintenance.
dormancygrace
left a comment
There was a problem hiding this comment.
Reviewed masking dispatch, key rotation, slice bounds, scalar/vector tails and runtime gating, plus the staging/build changes. Fixed the absolute local replacement paths and added a binary reproducibility check covering Gorilla and the Pion forks in two output roots. Also excluded the source-pinned Gorilla fork from automatic version edits. Host/race/purego tests and vet pass; RISC-V tests compile and generated instructions match GNU binutils. The staged server passes storage/stream/ws race tests. The source/cache remain unchanged by preparation. Leaving the PR open because the build-layout correction is substantive; no new device measurements were performed for this revision.
dormancygrace
left a comment
There was a problem hiding this comment.
Rechecked the optimized masking dispatch and private build staging on current main, including the newly merged HTTP/browser ISO readers. Staging and two-root byte-for-byte binary reproducibility pass. Gorilla host race/purego tests (with its documented randseednop=0 fixture setting), staged-server storage/stream/ws race tests and RISC-V test compilation pass. Existing review fixes and the final-head CI remain green. No new hardware performance result is claimed.
Browser-originated WebSocket frames use Gorilla's generic word-at-a-time masking loop. Add a C906 path that keeps 0–7 bytes in Go, handles 8–127 bytes with scalar assembly, and uses XTheadVector from 128 bytes while preserving phase and exact buffer bounds.
The server builder stages the pinned Gorilla v1.5.3 package under its output and uses a private modfile. The shared module cache stays intact; the build verifies the linked assembly and records its source hashes. Runtime checks require XTheadVector, enabled vector state and fast misaligned accesses, with an explicit generic control.
Validation on SG2002/C906, Ethernet and video enabled, three processes with three repetitions and medians:
CI checks the generated instructions, module staging, fallback tests and target test compilation. The test-only CONNECT fixture uses a real tunnel for Go 1.27, and prepared-message tests retain their intended deterministic seeds; no assertions were removed.
Methodology, process medians and qualification hashes are in firmware/cpu/go-websocket-c906/. Memory clearing remains a separate investigation and is not changed by this PR.