Bump cuvis.swig to develop for the GIL release and string fixes - #39
Merged
Conversation
Not a merge candidate. Carries cuvis.swig poc/gil-release, which releases the GIL around calls into cuvis so the SDK's blocking waits can be awaited rather than polled. Without this bump the binding still holds the GIL for the duration of every wait, and the awaitables in cuvis.python poc/real-awaitable block the interpreter instead of freeing it.
Was pinned to the poc/gil-release branch tip; cuvis.swig#15 landed as 0ccf8ca on develop with identical content.
birkholz-cubert
marked this pull request as ready for review
August 20, 2026 07:19
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.
Submodule bump only. No changes to this repo's own sources.
cuvis.swiggoes from280b487to0ccf8ca, picking up cuvis.swig#15, which is merged ondevelop. Content at0ccf8cais byte identical to the8997137branch tip everything below was measured against.What the bump brings in
%exceptionblock, at 311 call sites, behind#ifdef SWIGPYTHONso the C# target keeps the original body.%inlinestring helpers returnstd::stringby value instead ofchar const*. They previously returned.c_str()from a function-localstatic, one buffer shared by every thread in the process; the GIL was the only thing serialising it.cuvis_measurement_get_data_string_swigis sized fromcuvis_measurement_get_data_string_lengthinstead of a fixed 2048 byte buffer.No API change: the helpers still yield
str, socuvis.pythonneeds no edits.Why this repo cares
Two reasons beyond carrying the pointer.
It unblocks threaded consumers. Nothing in this binding released the GIL, so any blocking cuvis call froze the whole interpreter for its duration. Measured on the
cuvis-ai-dataloadercu3s read path, GPU processing, 20 cores / RTX 4070:Before, throughput slightly degrades with threads, because the extra threads add scheduling cost and can contribute no work. Single thread is unchanged, so the extra save/restore pair per call costs nothing at these rates.
It is the prerequisite for the real-awaitable work. A completion callback arriving from an SDK thread would deadlock against a Python thread blocked inside cuvis while holding the GIL. See the
poc/real-awaitablebranch incuvis.python.Verification against this bump
Built from this branch with the SDK at
C:\Program Files\Cuvis(3.5.3), Python 3.12:cuvis.pythonsuite: 134 passed.PyEval_SaveThreadsites, zerostatic std::string.KeyError: 0out ofMeasurement.refresh.settings_recreturns its full 3231 characters as well-formed XML, against 2054 bytes ending in uninitialised stack before.Measurement.nameand.comment.Linux,
cubertgmbh/cuvis_pyil:3.5.3-ubuntu24.04: 134 tests pass, GIL release emitted at the same sites.Pitfalls
SDKExceptioncan report another thread's message: 0.9% of reads at 3 threads, and 0.2% already before this change. Only the message text is affected, never the status code. Real fix isthread_localin the SDK'sErrorHandler, which is a cuvis.c change.Measurementacross threads is now a hard crash, against anAttributeErrorand lost calls before. Sessions and processing contexts survive sharing. Callers need a thread-affinity contract, which is acuvis.pythonconcern.Measurement._refreshstill ignores the status ofcuvis_measurement_get_data_image,_gpsand_sensor_info. That is what turned the string race into aKeyErrorthree frames from its cause.cuvis.pythonchange.num_workersis multiprocessing only, socuvis-ai-dataloaderneeds a thread pool prefetcher before any of the numbers above reach training.