Repository navigation
perf(webos): prefer AES-GCM on CPUs with AES instructions - #318
zampierilucas wants to merge 2 commits into
Conversation
Enable the aes-aws-lc-rs backend and advertise VIDEO_CAP_CHACHA20 only when AT_HWCAP2 lacks HWCAP2_AES. TVs with ARMv8 AES get the host's AES-GCM default; older ones keep ChaCha20. Signed-off-by: Lucas Zampieri <lcasmz54@gmail.com>
|
It is also possible to get hardware AES on older models, but it requires extra work on the pf-core side, and the returns are not big, so I dropped it in favor of ChaCha. However, this change looks like a low-hanging fruit. I will need to confirm that the switch works on the older webOS. |
|
tbh this is an unconventional setup, external network adapter to get 1GB networking, plus custom pyrowave decoder, and thats why I have to take every performance gain I can get to reach 4k60. |
|
I don’t think 1Gbps is possible on LG hardware with USB 2.0. It has a limit of around 300 Mbps, which is far too low for the Pyrowave. I’m also not sure whether we can get the Vulkan decoder to work on LG, and that is why we do not aim to support it on WebOS. Otherwise the CPU capacity for ChaCha decoding is more than enough for even the oldes TVs, but you change seems minimal and safe to merge it. |
|
@dyptan-io thats true, the most I was able to get is 300mbp on the usb 2.0, but better then the 100mbps nic build in on my c5. |
|
Oh, I was not aware of your work on Pyrowave. We may need to raise the bandwidth limit to 300 Mbps for Pyrowave if you manage to do it. My experience with Pyrowave on other devices is that 300 Mbps doesn't meet my 1440@120 quality requirements. With a lower framerate, I'm not sure, does it reduce the perceptible input latency at 60 fps? |
|
On raising the limit, it's not needed so far as upstream has its own control for it, Again, as I state on the pr header, the pr is only open so we can discuss this things, and not that I think this should be merged as it. |
|
@zampierilucas would you please fix merge conflict before I merge it? |
The client advertised ChaCha20 unconditionally because 32-bit ARM has no fast AES in RustCrypto. The aws-lc backend does use the ARMv8 AES and PMULL instructions from a 32-bit process, and the LG C5 reports them, so AES-GCM is faster there.
This enables the
aes-aws-lc-rsfeature on punktfunk-core and advertisesVIDEO_CAP_CHACHA20only whenAT_HWCAP2lacksHWCAP2_AES. When the bit is absent the host keeps picking ChaCha20 as before, so older webOS TVs without AES are unchanged. The speed test probe uses the same helper so it negotiates the cipher a real stream does. docs/NOTES.md is updated to match.On a C5 (4x Cortex-A at 1.4 GHz, 32-bit userland) decrypt dropped from about 12 us to about 4.5 us per packet, roughly 10% of one core at 300 Mbps. The host log showed session cipher aes-128-gcm with client_wants_chacha=false. That measurement came from an earlier fork build carrying the same change, not from this exact branch.
Tested with the armv7 release build and the unit tests on the host (113 pass). This branch was not run on a TV. The in-place decrypt change that also helped is in punktfunk core and is not part of this PR.