1 Star 0 Fork 0

Veenxz/c-blosc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
README_THREADED.rst 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
Valentin Haenel 提交于 2012-03-12 19:04 . Refactor: rename txt to rst

Blosc supports threading

Threads are the most efficient way to program parallel code for multi-core processors, but also the more difficult to program well. Also, they has a non-negligible start-up time that does not fit well with a high-performance compressor as Blosc tries to be.

In order to reduce the overhead of threads as much as possible, I've decided to implement a pool of threads (the workers) that are waiting for the main process (the master) to send them jobs (basically, compressing and decompressing small blocks of the initial buffer).

Despite this and many other internal optimizations in the threaded code, it does not work faster than the serial version for buffer sizes around 64/128 KB or less. This is for Intel Quad Core2 (Q8400 @ 2.66 GHz) / Linux (openSUSE 11.2, 64 bit), but your mileage may vary (and will vary!) for other processors / operating systems.

In contrast, for buffers larger than 64/128 KB, the threaded version starts to perform significantly better, being the sweet point at 1 MB (again, this is with my setup). For larger buffer sizes than 1 MB, the threaded code slows down again, but it is probably due to a cache size issue and besides, it is still considerably faster than serial code.

This is why Blosc falls back to use the serial version for such a 'small' buffers. So, you don't have to worry too much about deciding whether you should set the number of threads to 1 (serial) or more (parallel). Just set it to the number of cores in your processor and your are done!

Francesc Alted

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/veenxz/c-blosc.git
git@gitee.com:veenxz/c-blosc.git
veenxz
c-blosc
c-blosc
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385