Erik de Castro Lopo
2008-Feb-13 00:02 UTC
[ogg-dev] OggPCM: support for little-endianness only?
Jean-Marc Valin wrote:> Really? How low does it take to swap bytes vs. the time it takes to read > from disk?In CPU cycles? The difference is enormous. If no byte swapping is required the vast majority of the work is done by the DMA engine, from disk straight into user space memory and while the read is underway, the CPU can do other work. For the byte swapping case, every sample needs to be loaded into the cache and CPU, byte swapped and then written back to memory. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- I have now spent two days debugging C# on dotnot and all I can say is OMFG!!!! The MS tools are completely fucking abysmal. Its the most developer hostile environment I've ever worked on. The fact that people are actually able to release software that sort of works using these tools completely boggles my mind.
Jean-Marc Valin
2008-Feb-13 02:01 UTC
[ogg-dev] OggPCM: support for little-endianness only?
>> Really? How low does it take to swap bytes vs. the time it takes to read >> from disk? > > In CPU cycles? The difference is enormous. > > If no byte swapping is required the vast majority of the work is done by > the DMA engine, from disk straight into user space memory and while the > read is underway, the CPU can do other work. > > For the byte swapping case, every sample needs to be loaded into the cache > and CPU, byte swapped and then written back to memory.Come on. Given a disk bandwidth of 40 MB/s and a memory bandwidth (that's the bottleneck here) of 4 GB/s, you can saturate the disk with just one percent CPU. Not to mention the fact that if you're doing anything useful with the data, you're already paying for the memory bandwidth. I'm pretty sure the overhead of the context switches and libogg both dwarf the amount of CPU it takes to swap bytes (you can swap 4 16-bit samples per cycle with SSE). I'd be quite interested if you could provide a benchmark that really shows by swapping to make a difference. Jean-Marc
Erik de Castro Lopo
2008-Feb-13 02:20 UTC
[ogg-dev] OggPCM: support for little-endianness only?
Jean-Marc Valin wrote:> I'd be quite interested if you could provide a benchmark that really > shows by swapping to make a difference.Yes, I agree that the speed difference between the swapping and the no-swapping case is negligible, but I'm talking about CPU cycles. With libsndfile people do stream 10, 20 or more channels of audio off disk at once, with soft realtime requirements. In situations like this, avoiding the CPU cycles of end swapping is probably a good idea. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "You can have quality software, or you can have pointer arithmetic; but you cannot have both at the same time." -- Bertrand Meyer, 1989