On Thu, Jul 18, 2024 at 11:08:59AM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2024-07-18 00:42:05)
> > all the stuff should be put together close so its efficiently
> > using CPU caches
> 
> Which is why it shares its cacheline with PutBitContext, because the
> code benefits from having the both in the cache, right? And the 4-byte
> hole in PutBitContext is there presumably to aerate the cache for
> smoother data streaming.

thanks for spoting these, can you fix these ?


> 
> More seriously, this is not how caches work. Being close together
> matters mainly so long as your data fits in a cacheline, beyond that
> physical proximity matters little. On stack, the bitreader is likely to
> share the cacheline with other data that is currently needed, thus
> improving cache utilization.

caches are complex, and being close does matter.
having things in seperate allocations risks hitting aliassing cases
(that is things that cannot be in the cache at the same time)
so when you have the bitstream, the frame buffer, the context already
in 3 independant locations adding a few more increases the risk for hitting
these.
Also sequential memory access is faster than non sequential, it does
make sense to put things together in few places than to scatter them

Its years since ive done hardcore optimization stuff but i dont think
the principles have changed that much that random access is faster than
sequential and that caches work fundamentally differently


> 
> Another factor that matters in efficient cache use is e.g. not having
> multiple copies of the same constant data scattered around, which you're
> objecting to in my other patches.

copying the actually used small data together per slice
where its accessed per pixel should improve teh speed per pixel while
making the per slice code a little slower. now we have 4 slices maybe
and millions of pixels. Thats why this can give an overall gain

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to