Closed scottlamb closed 8 months ago
Thanks!
I am not sure of the meaning of number on the left in the "4232=928 bytes" notation you used :sweat_smile:
The size optimisation looks good nonetheless.
I am not sure of the meaning of number on the left in the "4232=928 bytes" notation you used 😅
Oops, markdown *
fail. Edited my comment above. Thanks for the review!
The new example is useful e.g. here: https://github.com/scottlamb/moonfire-nvr/issues/302#issuecomment-1892796704
Use a private helper to represent param set maps that impls
Debug
.Along the way, switch the representation to let the alloc grow as necessary, rather than pre-allocating 32 slots. In the common case when only SPS 0 and PPS 0 are filled, the
Vec
capacity seems to be size 4, which means the allocations are4*232=928
bytes and4*72=288
bytes rather than32*232=7,424
bytes and32*72=2,304
bytes, which seems like a worthwhile savings for no real effort.I played with a
Box<[Option[T]]>
to haveContext
be 32 bytes rather than 48, butresize_with
overallocates capacity, and theninto_boxed_slice
does an extra copy to undo that, and writing more code to avoid that felt like premature optimization.I also considered an
[Option<Box<T>>; 32]
but havingContext
take2*32*8=512
bytes on the stack struck me as potentially problematic.