Abstract


  • A buffer serves as a temporary storage area that consolidates multiple pieces of data before they are read from or written to an IO Device/Socket by the Kernel
  • Reducing the negative impact of System Call (系统调用) overhead and smoothen the data flow

Better performance

This consolidation helps optimize data transfer by minimizing the overhead associated with individual data transfers which requires System Call, and can also help smooth out disparities in data transfer rates between different components of the system.

Example

IO Device Buffering

  • In java, Scanner has a worse performance than BufferedReader, in terms of reading in a file.

Network Domain Socket Buffering

  • The white part of the progress indicates the data that is buffered. In this case, this data is basically part of the video that is ready to be watched without the need to fetch from the Server. If we don’t buffer and the data takes half a second to reach due to poor network connectivity, the user will feel the video isn’t playing smoothly, bad user experience!