Repository navigation
perf(sw): the stored packet envelope is a header and the bytes, not a property list (AE#592) - #618
Merged
Conversation
… property list (AE#592) Every compressed packet on the software VOD route is encoded into the read-ahead spool. PropertyListEncoder's binary format uniques every object through a Set, so each packet's whole payload went through Hasher.combine on the way in. In a release profile of a 91.6 Mbit/s 4K HEVC session that was the largest active frame outside the decoder: 204 of 1583 active samples inside SoftwareStoredPacket.encoded(), 203 of them in the hasher. The envelope is now a fixed little-endian header (version, the eight scalars, side data count, payload count), the payload, and each side data entry as type, count and bytes. The spool lives only for its session, so the version byte carries no compatibility promise. decode throws on an unknown version, on truncation and on trailing bytes, and a slice decodes like the whole buffer. Measured on an M1 Air against Scripts/slowrange.py (1 Gbit/s, 20 ms), one FFmpeg-muxed 4K HEVC + AC-3 5.1 fixture at 91.6 Mbit/s, process CPU over seconds 20 to 110 of a 120 s --sw session, release aetherctl, arms alternated: 7.15.1 0.220 / 0.223 / 0.222 cores this 0.205 / 0.207 / 0.208 cores (-0.015, -6.8 %) No rebuffer and aLead >= 3.98 s on every run of both arms. The encode subtree fell from 204 to 2 samples and Hasher from 203 to 0. The envelope benchmark in Issue592PacketEnvelopeTests reads 375 -> 43 us per 425 KB packet to encode and 22 -> 18 us to decode. New tests pin the exact envelope size, truncation, a foreign version, trailing bytes and slice decoding. The standalone AVPacket check asserted the bplist00 magic and now asserts the version byte and the exact size. 3380 swift-testing and 629 XCTest tests green, the three software packet scripts PASS. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f
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.
Refs #592.
What
SoftwareStoredPacketno longer goes throughPropertyListEncoder. The binary property list encoder uniques every object through aSet, so the whole payload of every packet written to the software VOD read-ahead spool was hashed on the way in. In a release profile of a 91.6 Mbit/s 4K HEVC session, that was the largest active frame outside the decoder: 204 of 1583 active samples insideSoftwareStoredPacket.encoded(), 203 of them inHasher.combine(bytes:).The envelope is now:
All fields are little-endian. The spool lives only for its session, so the version byte makes no compatibility promise.
decodethrows on an unknown version, on truncation and on trailing bytes.Measured
M1 Air. Origin:
Scripts/slowrange.pyat 1 Gbit/s with 20 ms latency. Fixture: one FFmpeg-muxed 4K HEVC + AC-3 5.1 file at 91.6 Mbit/s. Method: releaseaetherctl play --sw, 120 s sessions, process CPU counted over seconds 20 to 110, arms alternated.That is -0.015 cores (-6.8 %). There was no rebuffer on any run of either arm, and
aLeadstayed at or above 3.98 s. In the profile, the encode subtree fell from 204 samples to 2, andHasherfrom 203 to 0. The envelope benchmark reads 375 -> 43 us per 425 KB packet to encode, and 22 -> 18 us to decode.For scale, on the same fixture and machine: the native route costs 0.154 to 0.161 cores in process.
VTDecoderXPCServicecosts the same on both routes (about 0.035). So this change closes roughly a quarter of the gap between the software and native routes. A Debug (-Onone) engine costs the software route about 8 % more than Release (0.227 / 0.230 against 0.210 / 0.210 / 0.219).Tests
Scripts/tests/SoftwareStoredPacketStandalone.swiftasserted thebplist00magic. It now asserts the version byte and the exact size.test-software-stored-packet.sh,test-software-packet-read-ahead.shandtest-software-packet-disk-fifo.shall PASS.🤖 Generated with Claude Code
https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f