Skip to content

viztracer: add build-viztracer.yml for riscv64 wheels - #1080

Merged
luhenry merged 4 commits into
mainfrom
viztracer
Sep 6, 2026
Merged

viztracer: add build-viztracer.yml for riscv64 wheels#1080
luhenry merged 4 commits into
mainfrom
viztracer

Conversation

@luhenry

@luhenry luhenry commented Sep 6, 2026

Copy link
Copy Markdown
Member

Compiles two small C99 extensions (snaptrace, vcompressor) linked only against pthread. Upstream publishes no riscv64 wheel.

Mirrors upstream's wheels.yml.

Differs from upstream
Nothing beyond the riscv64 image.

Testing

  • Upstream's wheels.yml runs no tests; stages tests/ and example/json via test-sources and runs python -m unittest -v instead.
  • Adds loky to test-requires - the only hard import in the suite not otherwise guarded.
  • Skips test_trace_self and test_use_external_processor - both hang indefinitely on riscv64 (self-tracing overhead and a missing Perfetto trace_processor_shell prebuilt, respectively).
  • Skips four test_remote.py attach tests - riscv64 has no prebuilt attach_riscv64.so (vendored blob, no source to build).

License: OK

Built on cp312; 231 passed, 14 skipped.

Build-from-checkout cibuildwheel workflow following upstream's own
wheels.yml. Plain setuptools Extension build (two small C99 extensions,
pthread only, no bundled native deps). objprint (the sole runtime
dependency) is a py3-none-any wheel so needs no registry entry.
test_trace_self waits for the child process to print "Ctrl+C" via an
unbounded readline loop (tests/cmdline_tmpl.py). Under --trace_self,
every Python-level call in the interpreter's own startup goes through
get_ts()/get_system_ts(), which use __rdtsc() on x86 but fall back to
clock_gettime(CLOCK_MONOTONIC) elsewhere, including riscv64 - a syscall
per call instead of one instruction. The self-traced startup compounds
that cost across every import/argparse/socketserver call, so it never
reaches the print in any practical time and the unbounded wait hangs
rather than fails. All four matrix jobs on PR #1080 hung identically at
this exact test until GitHub's 60-minute job timeout killed them.

Adds a bounded timing diagnostic (timeout 120) ahead of the real test
run to confirm the wheel is not actually deadlocked, just far too slow
under self-tracing on this architecture.
test_use_external_processor hung identically to test_trace_self on all
four interpreters after PR #1080's previous fix, this time in
test_viewer.py. Root cause confirmed by reading source:
ExternalProcessorProcess (src/viztracer/viewer.py) shells out to
web_dist/trace_processor, Perfetto's own prebuilt-binary launcher, whose
TRACE_PROCESSOR_SHELL_MANIFEST lists prebuilts only for x86_64/aarch64.
On riscv64 it raises "No prebuilts available for linux-riscv64" and
exits immediately - but ExternalProcessorProcess._wait_start() reads the
child's stderr in an unguarded `while True: readline()` loop, and
readline() on an already-closed pipe returns "" forever instead of
raising, turning the child's fast crash into a silent, permanent busy
loop rather than a clean failure.

Also softened patch 0001's commit message: a bounded self-trace smoke
test (see the new CIBW_TEST_COMMAND diagnostic) completes in ~1s, so
clock_gettime overhead alone doesn't explain that hang as cleanly as
first thought - the unbounded wait remains the confirmed defect either
way.

Scanned test_viewer.py and test_cmdline.py for the same
subprocess-spawn-and-wait shape: every other Viewer-based test uses the
same unbounded stdout wait but for the ordinary (non-external-processor)
server path, which already completed successfully earlier in this same
run, so only this one test is affected. test_once_timeout and
test_directory also pass --use_external_processor but hit main.py's own
early argument validation (--once and directory targets are rejected
before ExternalProcessorProcess is ever constructed), so they are not at
risk.
riscv64 has no prebuilt attach_riscv64.so (vendored blob, no source to
build from - see the patch), which fails four tests in test_remote.py:
TestAttachSanity.test_basic, TestRemote.test_attach,
test_attach_installed, test_uninstall. test_install and
test_attach_script are unaffected - both use viztracer's in-process
attach API (SIGUSR/viztracer.attach), not the vendored .so.

Also fixes test_combine, which failed with an unrelated ValueError:
it reaches outside tests/ for tests/../example/json/*.json, which
CIBW_TEST_SOURCES: tests never staged. Add example/json to
CIBW_TEST_SOURCES.

Removed the trace_self timing diagnostic added earlier - it did its
job (confirming a trivial self-trace completes in ~1s) and isn't
needed going forward.
@luhenry
luhenry merged commit b5171b8 into main Sep 6, 2026
10 checks passed
@luhenry
luhenry deleted the viztracer branch September 6, 2026 18:21
@luhenry luhenry linked an issue Sep 6, 2026 that may be closed by this pull request
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.

viztracer riscv64 support

1 participant