evidence · 11.4 KiB

sidestep-riscv64-assessment.md

Committed at docs/evidence/egui-sidestep/sidestep-riscv64-assessment.md. This is what grounds the requirements that cite it.

Open raw source

Sidestep on the K230: riscv64 port assessment and measurements

Subject: Sidestep, https://github.com/bitemyapp/sidestep at commit 626422b1fa52fc14af13976c5c90b4efd657b1d7 (2026-10-08, “Scroll tiles, animator drawing and toplevel geometry”). Rust edition 2024, MIT or Apache-2.0. About 239,000 lines of Rust in its crates. Wayland only, CPU rendering with tiny-skia.

Evidence classes in this file (kept apart on purpose):

Verdict

Go: the riscv64 port was bounded, was done, and passes its conformance suite apart from one missing optimisation. About 500 added lines of Rust and assembly plus a one-line patch to a third-party crate. All the Objective-C runtime semantics (classes, messaging through objc_msg_lookup, ARC, blocks, NSInvocation, forwarding, proxies) pass their conformance tests under QEMU user mode. The real obstacle is not the port but the speed: see the measurements.

Where the architecture lives

Hand-written assembly and calling-convention code exists only for aarch64 and x86_64. Counted at 626422b, items gated on target_arch:

Fileaarch64 linesx86_64 linesWhat it isriscv64 treatment
sidestep-runtime/src/trampoline.rs6171register-saving frame shared by objc_msgSend and forwardingnew macro arm (85 lines incl. docs)
sidestep-runtime/src/call.rs197211argument layout for NSInvocation/forwarding, sidestep_invoke asmnew Registers, LP64D Layout, asm, a test (282 lines)
sidestep-runtime/src/forward.rs3433forwarding trampoline entriesthree entries (46 lines)
sidestep-runtime/src/msgsend.rs37133objc_msgSend with an assembly cache probeslow-path-only objc_msgSend and objc_msgSend_stret (47 lines)
sidestep-runtime/src/block_imp.rs3524executable stubs for imp_implementationWithBlock5-instruction stub (plain and stret), instruction-cache flush (51 lines)
sidestep-runtime/src/arc.rs6052autorelease return-value handoffnot ported: the existing portable fallback is used
sidestep-runtime/src/message.rs07struct-return selector shiftone cfg (4 lines)
sidestep-foundation/src/cf/bundle.rs, sidestep-appkit/src/workspace.rs1 eachan Apple constantuntouched

objc2 sends every message through objc_msg_lookup (portable Rust), so the common path never touches assembly. What the assembly serves is C callers of objc_msgSend, NSInvocation and message forwarding, blocks used as methods, and a speed-up for autoreleased return values.

One more obstacle was outside Sidestep: the third-party crate objc2-encode 4.1.0 has no arm for the size of long double on riscv64 (16 bytes, IEEE quad), so nothing compiles. A one-line patch through [patch.crates-io] fixes it: nix/sidestep-riscv64/objc2-encode-4.1.0-riscv64.patch.

The port itself is nix/sidestep-riscv64/sidestep-riscv64.patch (526 added, 21 changed lines, nine files, runtime plus conformance-test cfgs).

ABI details the port had to get right (LP64D)

Results

Conformance (QEMU user mode, riscv64)

Command and environment: nix/sidestep-riscv64/README.md. Logs: sidestep-conformance-riscv64-qemu-user.txt (final run, 2026-10-30) and sidestep-conformance-x86_64-control.txt (x86_64 control for the failing files).

Final run of the whole conformance crate: 610 tests passed, 3 reported failures, plus four AppKit binaries (appkit_autolayout, appkit_split, appkit_stack, appkit_views) that abort on a layout rounding assertion.

FailureCausePort-related?
autorelease::claimed_return_is_handed_overthe return-value handoff is not portedYes, a known gap (below)
appkit_autolayout, appkit_split, appkit_stack, appkit_viewslayout rounding differs by fractions of a pointNo: the same four fail identically on the x86_64 control in the same environment
coregraphics::fonts, services::home_temporary_and_userthe test needs system fonts / the real HOME; the run used a 3-font directory in a user namespaceNo: same two fail on the x86_64 control
rich_text::rtf_default_fontHelvetica and Times stand-ins resolve to the same font in the 3-font directoryProbably not; it passed on the x86_64 control, whose font lookup can load the host’s fontconfig, which a riscv64 process under QEMU cannot. Not isolated.

An earlier run of the same suite failed in four more places, each a real port bug that was fixed and re-run: the stack-argument offset in the forwarding frame (invocation), a missing objc_msgSend_stret entry (msgsend, proxy), and a missing struct-return stub kind for blocks (block_imp).

Known gaps in the port

Board measurements (no display), K230, 2026-10-30

Single C908 core online at 1.6 GHz class clock (cpu_freq was not exposed), under the board lock, on the normal booted system with the shell running. Raw outputs are in sidestep-board/. Medians of seven runs as printed by each bench. These are from the same msgbench, eventbench, controlbench and drawing-gallery sources the Sidestep project publishes for macOS and Linux comparisons; no x86 or Apple numbers are quoted here because none were measured on this board.

CaseK230 riscv64
baseline: indirect call to a Rust function7.3 ns
msg_send! instance method23.4 ns
msg_send! class method23.1 ns
generated binding -[NSObject hash]27.8 ns
retain + release38.8 ns
objc_msgSend called directly (slow path)59.9 ns
forwarded message (forwardingTargetForSelector:)115 ns
forwarded message (forwardInvocation:)2,930 ns
NSInvocation invoke, one object argument755 ns
alloc + init + release NSObject187 ns
alloc + init + release, class with ivars354 ns
autorelease pool push/pop, one object162 ns
autoreleased return not kept, own pool209 ns
NSString from_str("hello") + release520 ns
weak load + release98 ns
weak reference create + destroy437 ns
view frame change, unobserved (eventbench)3.1 us
view frame change, observed4.7 us
post and take an event1.6 us
key event to first responder0.45 us
idle run-loop pass3.7 us
pointer move reaching a tracking loop12.7 us
label made and sized (controlbench)28-55 us
button made24.6 us
label setStringValue + intrinsic size, new text11.2 us
drawing-gallery bench frame (2,000 rounded fills, 1,000 strokes, 300 images) into a bitmap, 1x888 ms
same at 2x2,005 ms

Further msgbench cases: associated object get 142 ns, set+get+remove 1,054 ns, four threads reading associated objects 624 ns each. “Autoreleased return, retained by the caller” run at 100,000 iterations (the memory-bounded setting): 532 ns median (379 ns best), against the unbounded 10 million that was killed.

textbench (an 11 MB, 200,000-line NSTextView) did not complete a single case: it grew to its 380 MB memory limit on a 927 MB board and was stopped by hand after about 17 minutes (the EXIT 0 in its output file is systemd’s code for that stop, not completion). That workload is out of reach on this hardware as configured.

Board, window: the demo apps run

Both controls-gallery and drawing-gallery mapped a 1232x568 window in the normal session (unit stopped afterwards; compositor, system closure and sway PID unchanged) and drew correctly through tiny-skia into shared memory (captures/). In the controls gallery the button and label text did not render (blank controls); the cause was not investigated (fonts or text path). Resident memory 24 MB (controls) and 20 MB (drawing), proportional 19 and 17 MB. Over 20 idle seconds the drawing gallery used 0 CPU ticks, but the controls gallery used 3.2 s of a core, 16% of the core while showing static controls (it animates spinners and progress bars; Sway used 1.4 s over the same period). Startup time was not recorded (the window poll was 1 s and its timer failed).

Reading these: the runtime itself is fast enough for UI work (tens to hundreds of nanoseconds per message, microseconds per event or property change). What is slow is drawing: one bench frame of 3,300 operations took 888 ms. A real app draws far less per frame (the scene in the egui and Qt trials is a few dozen rounded rectangles and glyph runs), so per-frame cost at that scale is not measured here; the scene-matched Sidestep client (task 4.1) was not written, so there is no Sidestep number to put next to egui’s or Qt’s.