Skip to content

perf(msgs): cache TurboJPEG per thread — ctor costs ~2ms per call - #3248

Draft
spomichter wants to merge 1 commit into
mainfrom
perf/turbojpeg-thread-cache
Draft

perf(msgs): cache TurboJPEG per thread — ctor costs ~2ms per call#3248
spomichter wants to merge 1 commit into
mainfrom
perf/turbojpeg-thread-cache

Conversation

@spomichter

Copy link
Copy Markdown
Contributor

Every jpeg encode/decode in Image.to_jpeg_bytes, the lcm jpeg decode path, and person_follow constructed a fresh TurboJPEG() per frame — measured ~1.9ms/call, roughly 30-50% of total jpeg codec time at 720p. Replaces them with a lazy threading.local cache (native handles are not thread-safe across threads, so a module singleton would be wrong); zero behavior change. CompressedImage.decode in #2814 can adopt the same helper once both land.

to_jpeg_bytes, lcm jpeg decode, and person_follow paid a fresh TurboJPEG()
per frame (~30-50% of jpeg codec time). Handles are not thread-safe across
threads, so the cache is threading.local, not a module singleton.
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
dimos/agents/skills/person_follow.py 50.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3248      +/-   ##
==========================================
- Coverage   74.90%   74.89%   -0.01%     
==========================================
  Files        1114     1114              
  Lines      106086   106092       +6     
  Branches     9665     9666       +1     
==========================================
+ Hits        79461    79462       +1     
- Misses      23816    23820       +4     
- Partials     2809     2810       +1     
Flag Coverage Δ
OS-ubuntu-24.04-arm 68.50% <71.42%> (+<0.01%) ⬆️
OS-ubuntu-latest 70.51% <71.42%> (-0.01%) ⬇️
Py-3.10 70.51% <71.42%> (+<0.01%) ⬆️
Py-3.11 70.51% <71.42%> (+<0.01%) ⬆️
Py-3.12 70.51% <71.42%> (+<0.01%) ⬆️
Py-3.13 70.51% <71.42%> (-0.01%) ⬇️
Py-3.14 70.52% <71.42%> (+<0.01%) ⬆️
Py-3.14t 70.51% <71.42%> (-0.01%) ⬇️
SelfHosted-Large 29.33% <28.57%> (+<0.01%) ⬆️
SelfHosted-Linux 35.92% <25.00%> (-0.01%) ⬇️
SelfHosted-macOS 35.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
dimos/msgs/sensor_msgs/Image.py 58.72% <100.00%> (+0.85%) ⬆️
dimos/agents/skills/person_follow.py 28.33% <50.00%> (-0.40%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant