Repository navigation
ports: result_job, node keys, generic intrinsics, T7 harness, pycvc jobs (P0b, part 2) - #1113
Merged
Merged
Conversation
The first of the VolumeRover ports' shared pieces (VOLROVER-LIBRARY-PORTS-ROADMAP.md §1.5, §7 P0b). A params struct is declared once, as a constexpr table of its fields (name, member, unit, range, doc; an enum's choices from BOOST_DESCRIBE_ENUM), and generic code gives: - params_validate(): a list of what is wrong (range, NaN, choices, the table's own check); - params_to_state / params_from_state: one key per field, missing keys seeded with their defaults, a value that does not parse reported (not replaced), and the properties written on each key (comment, doc, unit, min, max, choices, default, type, access); - param_cli.h: the CLI flags and their help on boost::program_options; - param_dsl.h: the DSL dict an intrinsic takes, and the app's registry of tables behind (params.defaults name) and (params.check name dict), held in the app's data map; - pycvc_params.i: PYCVC_PARAM_TABLE, keywords (an unknown one raises TypeError naming the valid ones), validate(), from_state / to_state, from_dict / to_dict; - params_markdown(): the table for a port's docs. Numbers are written in their shortest round-trip form, so struct -> tree -> struct is exact. compute_contour_tree's options get the first real table (contour_tree_params.h), which pycvc wraps as contour_tree_options. Tests: param_table_test (T8 for the piece itself: every field round-trips through text, the tree, the CLI and the DSL; defaults seeded, properties written, bad values named; two apps keep their own registries) and test_pycvc_params.py. src/cvc/tests/port_tests.cmake lists the ports' googletest binaries. CVC_BUILD_PORT_TESTS builds only those (with CVC_BUILD_TESTS off), and the new `ports (wasm-mt, node)` CI lane builds them for wasm-mt and runs each under node (T14). param_table_test also joins the sanitizer lanes.
…obs (P0b, part 2) The VolumeRover ports' job pieces (VOLROVER-LIBRARY-PORTS-ROADMAP.md §1.4, §1.6, §1.9, §7 P0b), proved on libcvc's own steppers, since no port exists yet. - cvc::result_job<R> (cvc/core/result_job.h): any resumable stepper as a sliced_job that owns its result. step(budget) takes the result and destroys the stepper once done; cancel() from any thread ends it at the next step with nothing; a throwing step fails the job (status "failed: <message>", result() rethrows); phase/progress/status for UIs; step timings. make_result_job takes the stepper by value or unique_ptr, with take() or a taker. cvc/volume/volume_jobs.h: contour_tree_job and resize_job. - cvc::job_keys and schedule_published_job (cvc/core/job_keys.h): fe_lab's node keys (busy, stoppable, status, progress 0-100, phase "<phase> 42%", stats.work_ms, pid) published from a task's hooks. fe_lab now writes its job keys through it (its own WorkTimer still times stats.work_ms). sliced_task gains on_cancelled (a job stopped through its own cancel()) and stop_sliced_job (safe from another process's step). - cvc/core/job_intrinsics.h: a port registers an op from its stepper factory and parameter table and gets (<op> ...) (parks on the task), (<op>-async ...) (a future), (<op>-start ... target) (the pid at once; keys under target, the result at target.result), plus (job.cancel pid) and params.defaults / params.check. Tasks carry the caller's owner tag; killing the caller or the task cancels the job. - The T7 harness (src/cvc/tests/resumable_harness.h): budgets 1, 64, seeded random and 0 against the blocking result bit for bit; monotone progress and named phases; a cancel in each phase leaves no result and destroys the stepper; the slowest step at the default budget and the stepping overhead recorded; a cooperative frame-time run on an app's scheduler. - pycvc_jobs.i: PYCVC_RESULT_JOB wraps result_job<R> generically (step, done, cancel, progress, phase, status, result, take_result, run), with the GIL released inside each step; pycvc.contour_tree_job, pycvc.resize_job, pycvc.compute_contour_tree and the tree. Tests: result_job_test (the job on fake steppers; T7 on contour_tree_builder, resize_stepper and, with libigl, fem::stepped_solve; the node keys cooperative and threaded) and job_intrinsics_test (T10: each form cooperative and threaded, bad parameters and inputs, failures, job.cancel, kills, owner tags, and an Ariadne button's on: action starting a job with -start under the default action limits while its progress keys rise frame by frame). Both join the ports (wasm-mt, node) lane and the sanitizer lanes; test_pycvc_jobs.py joins pycvc's.
The T7 harness's fem::stepped_solve case (result_job_test, built where libigl is) found that a budget-0 step returned three times before the solve was done. fem.h, like every stepper's contract, says budget 0 runs to the end. The builder and the factorization stages spend whatever budget they are handed, so even an unbounded budget ended run() after each of them. With budget 0, step() now calls run() until the solve is done. A budgeted step is unchanged, and so are its results: the harness's bit-for-bit comparisons across budgets 1, 64, random and 0 already passed.
#1110 merged as ed2e0d5, a squash of this branch's first commit (cc48acd). This merge's tree is master plus this PR's own changes (cc48acd..49eb2cd), so the PR's diff against master is only part 2. The conflicts were only where part 2's lines sit next to part 1's (ci.yml's sanitizer and path-filter lines, port_tests.cmake, src/cvc/CMakeLists.txt, pycvc's CMakeLists.txt and pycvc_contour_tree.i, docs/PORT_SHARED_PIECES.md).
transfix
enabled auto-merge (squash)
November 10, 2026 07:47
Changing a PR's base doesn't start the pull_request workflow, and this branch's last push came while its base was #1110's branch, which CI/CD skips. This empty commit starts it.
The clang-tsan lane found a heap-use-after-free in test_pycvc_jobs.py. result() returned a reference into the job, so `pycvc.contour_tree_job(vol).run()`, which drops its job at once, left the tree pointing at freed memory (dims_list, nodes.__len__). A reference would dangle the same way once the result is taken. pycvc_jobs.i now declares result() by value, so SWIG copies it and Python owns the copy; take_result() still moves it out. New test: a result outlives its job and a take.
transfix
disabled auto-merge
November 10, 2026 20:07
Two failures at 55da976: - clang-tsan: test_pycvc_jobs.py still read freed memory. tree.nodes was a view into the tree that does not keep the tree alive, so len(pycvc.compute_contour_tree(vol).nodes) read it after the temporary tree was collected. %naturalvar makes nodes and arcs copies Python owns. The test now checks that nodes outlive their tree. - ports (wasm-mt, node): job_intrinsics_test reaches Ariadne, which links cvc::net's fetch backend, and an executable must add -sFETCH=1 for it (src/cvc/CMakeLists.txt). The port tests now link with it.
…e OpenMP thread %naturalvar left tree.nodes a view into the tree (the sanitizers caught len(pycvc.compute_contour_tree(vol).nodes) reading the freed tree): nodes and arcs are now properties over getters that return the vectors by value, which Python owns. The tsan lanes configure CVC_ENABLE_OPENMP=OFF, yet voxels.cpp's parallel regions arrive compiled with -fopenmp; libgomp is not built with TSan, so result_job_test's ResizeStepper reference (voxels::resize) reported the main thread racing its workers. run.sh sets OMP_NUM_THREADS=1 for tsan and clang-tsan.
…h once ImageMagick's own build flags no longer turn OpenMP on. CMake's FindImageMagick copies pkg-config's CFLAGS_OTHER into the ImageMagick::* targets' INTERFACE_COMPILE_OPTIONS, and cvcpkg's Linux ImageMagick (built with configure's default OpenMP) lists -fopenmp there. Linked PUBLIC, it compiled every cvc source with OpenMP whatever CVC_ENABLE_OPENMP said, so the sanitizer lanes' OFF still built voxels.cpp's parallel regions, run on a libgomp TSan cannot see into. src/cvc/CMakeLists.txt drops the OpenMP flags (with an -Xpreprocessor or -Xclang that introduces one) from those targets. The previous commit's OMP_NUM_THREADS=1 in .github/sanitizers/run.sh goes again. The parallel writers that still wrote through operator(), and so called preWrite() on every voxel from every thread, now detach the buffer and dirty the histogram once before the region and write with setValueRaw, as fillsub and map do: resizeTrilinearCPU (newvox), composite (whose threads raced to detach a shared buffer) and anisotropicDiffusion (tempt). preWrite() writes the histogram flag only when it is clean, so gdtvFilter's gradient (a fresh voxels, already dirty) is written in parallel without a race on it.
This was referenced Nov 11, 2026
Merged
transfix
added a commit
that referenced
this pull request
Nov 11, 2026
Master's #1137 makes the action-intrinsic providers each app's own (an app.slot table, with a keyed form that replaces in place), and this branch gives each provider a kind (any / host_proxied / host_only). Both are kept: - ariadne.h: register_action_intrinsics takes the app, with or without a key, and with or without a kind; the forms without a kind register host_only. - ariadne.cpp: the app's table holds this branch's registered_provider (key, provider, kind). install_providers, the placement generation and host_only_bindings read the app's table. A keyed registration replaces both the provider and its kind. - The stream (any) and room (host_proxied) providers keep their kinds under master's keys. net, AppRuntime's seven providers, nav_compute and the tests pass the app. - Tests: the guards that cleared the process-wide list (isolated_providers_ cleared, StreamActionGuard, ari_providers_reset) are gone, since each test's providers now go with its app; use_host_in_contexts and register_thread_probe take the app. Master's job_intrinsics_test (#1113) still called the pre-#1137 forms, which do not compile at master's head; it passes the app. - ci.yml's sanitizer list keeps both sides' tests. The allowlist is the three-way merge of both sides (802 lines, cvc 453), rendered by scan.py: #1137 dropped the registry's and room_calls.cpp's statics. - Docs name the app-taking forms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of phase P0b, the VolumeRover ports' shared pieces (docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md §1.4, §1.6, §1.9, §7). Stacked on #1110: merge that first, and this one retargets to master. Additive and non-breaking.
No port exists yet, so each piece is proved on libcvc's own steppers:
contour_tree_builder,resize_stepper, and, where libigl is built in,fem::stepped_solve.What it adds
cvc::result_job<R>(cvc/core/result_job.h) runs any resumable stepper as asliced_jobthat owns its result.step(budget)andprogress().phase(),status(),done(), a thread-safecancel()andtake()are optional.cancel()works from any thread: the next step ends the job with nothing.status()is"failed: <message>", andresult()rethrows the stepper's own exception.cvc/volume/volume_jobs.haddscontour_tree_jobandresize_job.The node keys (
cvc/core/job_keys.h) are fe_lab's keys, published from a task's hooks byschedule_published_job:busy,stoppable,status;progress(0–100),phase("sorting 42%");stats.work_ms,pid.fe_lab now writes its job keys through
job_keys. Its own WorkTimer still timesstats.work_ms, because that spans a chain of commands.sliced_taskgains two additive pieces:on_cancelledhook, for a job stopped through its owncancel();stop_sliced_job(app, pid), which is safe from inside another process's step.The generic intrinsic forms (
cvc/core/job_intrinsics.h): a port registers an op from its stepper factory and parameter table, and gets:(<op> ...), which parks the caller on the task (an async function whose work runs by itself, STATE_EXEC_EXCEPTIONS.md 3.12);(<op>-async ...), which returns a future;(<op>-start ... target), which returns the pid at once, publishes the keys undertarget, and puts the result attarget.result;(job.cancel pid),params.defaultsandparams.check.Inputs are data objects or state paths. Parameters are read through the table, and every problem raises
ValueError. Tasks carry the caller's owner tag.The T7 harness (
src/cvc/tests/resumable_harness.h), for ports to reuse:pycvc (
pycvc_jobs.i):PYCVC_RESULT_JOBwrapsresult_job<R>once, generically:step,done,cancel,progress,phase,status,result,take_resultandrun. The GIL is released inside each step. It addspycvc.contour_tree_job,pycvc.resize_job,pycvc.compute_contour_treeand the tree type.Tests
result_job_test:job_intrinsics_test(T10):job.cancel, killing the caller or the task, owner tags;on:action calls-startunder the default action limits (not raised). Its progress keys rise frame by frame, and the result lands atjob.result.test_pycvc_jobs.py, including a check that another Python thread runs during a step.Both C++ tests join the
ports (wasm-mt, node)lane (added in #1110, whereparam_table_testpasses 20/20 under node 22) and the sanitizer lanes. The Python test joinsSAN_PY_TESTS.Checked locally on Windows (MSVC 2022, Release):
param_table_test20/20,result_job_test18/18,job_intrinsics_test21/21;pycvc_jobs,pycvc_params,pycvc_smoke,pycvc_algorithmandpycvc_statepass;cvcgl_fe_intervalandcvcgl_ariadne_realizepass.The local deps have no libigl, so the fem T7 case and fe_lab's mesh and solve paths are first exercised here in CI. clang-format 18 reports no changes.
T7 numbers measured locally (Release, desktop):
Notes for review
cvc exec, pycvc'sExec, Ariadne) belongs to P0a's per-app provider list (§1.3). Until then a host registers them itself; the test usesregister_action_intrinsics.result_job.h, sopycvc_jobs.ideclares the class's members as the header has them. It is the real type, not a facade.