perf(msgs): cache TurboJPEG per thread — ctor costs ~2ms per call - #3248
Draft
spomichter wants to merge 1 commit into
Draft
perf(msgs): cache TurboJPEG per thread — ctor costs ~2ms per call#3248spomichter wants to merge 1 commit into
spomichter wants to merge 1 commit into
Conversation
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 Report❌ Patch coverage is
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
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.