← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 5381.b.1

持锁读写形成串行瓶颈

理解等级:高级

同步原语保护共享结构或等待其他线程,但持锁线程若再做I/O、申请其他同步资源或从池里等待对象,就让所有等待者间接等待这些慢操作。应尽量减少共享和持有时间,用锁剖析找出阻塞最大的点,再考虑其他微优化。tryAcquire可避免立即阻塞,却需要显式重试与异步控制,不能把忙重试当作免费并行。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 服务端架构 · 查看原书依据

      We must reduce the time execution spends with synchronization by releasing the lock or synchronization primitive as soon as possible. Consider a thread on which other threads are blocking. We should be extra careful if such a thread is doing I/O operations, performing synchronized operations, or acquiring objects from a pool.

    参考来源

    - 位置:《Software Architecture and Decision-Making》第11章《Server Architectures》(来源项目:book-sources;源文件:extracted/Software Architecture and Decision-Making Leveraging Leadership, Technology, and Product Management to Build Great Products… (Srinath Perera)/_epub-src/ch11.xhtml) - 结论依据:摘录说明同步原语保护共享结构或等待其他线程,但持锁线程若再做I/O、申请其他同步资源或从池里等待对象,就让所有等待者间接等待这些慢操作。其余条件结合本章相邻例子与取舍说明,数字示例不作当前性能承诺。 - 原始内容:We must reduce the time execution spends with synchronization by releasing the lock or synchronization primitive as soon as possible. Consider a thread on which other threads are blocking. We should be extra careful if such a thread is doing I/O operations, performing synchronized operations, or acquiring objects from a pool.