← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 3086.a.2.a.2

缓冲合并减少IO开销

理解等级:中级

I/O常按块处理,小写入未必比满块便宜。把多个小写入先缓冲再批量发送,可摊薄操作与系统调用成本。块大小需依据实际平台;原文8KB只作示例,不能视为所有Linux接口统一默认值。缓冲减少次数,也会引入等待填满或刷新时机的取舍。

相关:[[操作层级指导资源交换]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 理解性能的心智模型 · 查看原书依据

      I/O happens as blocks, and the cost of reading and writing each block is about the same; for example, the Linux default buffer size is 8KB. Whether you write 1KB or 8KB, the cost is about the same. We can save a lot by buffering the writes (Java-buffered streams do this automatically).

    参考来源

    - 位置:《Software Architecture and Decision-Making》第3章《理解性能的心智模型》(来源项目:book-sources;源文件:extracted/Software Architecture and Decision-Making Leveraging Leadership, Technology, and Product Management to Build Great Products… (Srinath Perera)/_epub-src/ch03.xhtml) - 结论依据:原文的定义、比较或例子支持“I/O常按块处理,小写入未必比满块便宜”;正文据此说明用途和边界。 - 原始内容:I/O happens as blocks, and the cost of reading and writing each block is about the same; for example, the Linux default buffer size is 8KB. Whether you write 1KB or 8KB, the cost is about the same. We can save a lot by buffering the writes (Java-buffered streams do this automatically).