Is there a way to improve performance of linux pipes?

前端 未结 2 2011
梦谈多话
梦谈多话 2021-02-07 09:56

I\'m trying to pipe extremely high speed data from one application to another using 64-bit CentOS6. I have done the following benchmarks using dd to discover that t

2条回答
  •  梦谈多话
    2021-02-07 10:21

    It seems that Linux pipes only yield up 4096 bytes at a time to the reader, regardless of how large the writer's writes were.

    So trying to stuff more than 4096 bytes into a already stuffed pipe per write(2) system call will just cause the writer to stall, until the reader can invoke the multiple reads needed to pull that much data out of the pipe and do whatever processing it has in mind to do.

    This tells me that on multi-core or multi-thread CPU's (does anyone still make a single core, single thread, CPU?), one can get more parallelism and hence shorter elapsed clock times by having each writer in a pipeline only write 4096 bytes at a time, before going back to whatever data processing or production it can do towards making the next 4096 block.

提交回复
热议问题