README_THREADED.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. Blosc supports threading
  2. ========================
  3. Threads are the most efficient way to program parallel code for
  4. multi-core processors, but also the more difficult to program well.
  5. Also, they has a non-negligible start-up time that does not fit well
  6. with a high-performance compressor as Blosc tries to be.
  7. In order to reduce the overhead of threads as much as possible, I've
  8. decided to implement a pool of threads (the workers) that are waiting
  9. for the main process (the master) to send them jobs (basically,
  10. compressing and decompressing small blocks of the initial buffer).
  11. Despite this and many other internal optimizations in the threaded
  12. code, it does not work faster than the serial version for buffer sizes
  13. around 64/128 KB or less. This is for Intel Quad Core2 (Q8400 @ 2.66
  14. GHz) / Linux (openSUSE 11.2, 64 bit), but your mileage may vary (and
  15. will vary!) for other processors / operating systems.
  16. In contrast, for buffers larger than 64/128 KB, the threaded version
  17. starts to perform significantly better, being the sweet point at 1 MB
  18. (again, this is with my setup). For larger buffer sizes than 1 MB,
  19. the threaded code slows down again, but it is probably due to a cache
  20. size issue and besides, it is still considerably faster than serial
  21. code.
  22. This is why Blosc falls back to use the serial version for such a
  23. 'small' buffers. So, you don't have to worry too much about deciding
  24. whether you should set the number of threads to 1 (serial) or more
  25. (parallel). Just set it to the number of cores in your processor and
  26. your are done!
  27. Francesc Alted