-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Add RLE encoding #149
Conversation
…re queued makes the locking more robust by: unlocking only when queue is empty, aborting transfers when an unexpected unlock occurs, but not when a transfer is queued between sending the unlocking LockStateCommand and receiving LockStateUpdateCommand back
Nice, this is one of things that I have been wondering about, but the benefit was too much of an unknown for me to be able to motivate. I'll give this and your other PR a proper read next week.
I think it would be good to make it opt out. Perhaps always disabled when running in single-threaded mode, as that 30-40ms of cpu time might be long enough for the connection to drop?
If we were to move the RGB->YUV into that too then WASM will probably be beneficial. The problem with WASM is that the pixels will need to be copied from a nodejs buffer into a WASM buffer, and the inverse on the way out, so if not careful it could be more costly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you could make it opt-out as described in #149 (comment), then I am happy.
I am open to doing some wasm, that might be better as a follow up PR? I don't mind. (I am tempted to implement that myself)
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #149 +/- ##
==========================================
+ Coverage 86.23% 86.28% +0.05%
==========================================
Files 177 180 +3
Lines 5709 5813 +104
Branches 941 957 +16
==========================================
+ Hits 4923 5016 +93
- Misses 764 775 +11
Partials 22 22
☔ View full report in Codecov by Sentry. |
I have made this opt-out, and this is now released. I also started playing around with doing the RGBA->YUVA conversion in a native library in #152, we could look at moving the RLE to that too later on, once/if that gets merged |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Performance improvement for uploading stills and clips that benefit from RLE
What is the current behavior? (You can also link to an open issue here)
Frames are sent uncompressed, which consistently takes about 600ms per 1920x1080 frame
What is the new behavior (if this is a feature change)?
Encodes still and clip frames with Run-Length Encoding supported by ATEM switchers, making some frames (those that have lots of solid color areas) upload significantly faster (even down to 100ms).
Also increases
MAX_PACKETS_TO_SEND_PER_TICK
to 50 which seems to be the sweet spot.Other information:
This currently also includes changes from fix: prevent 'Lost lock mid-transfer' error with multiple transfers #147
On my 12th Gen Intel notebook CPU encoding takes about 30-40ms for a 1920x1080 frame, no matter how compressible it is. Should we try WASM with SIMD for the color space conversion and RLE to squeeze out some more performance? Should we make RLE optional? - I'm open for suggestions.
The code is ready for review, but some help is needed to fix existing tests that I believe have wrong hashes in them.