JCTools, 場景特化的併發類庫,某些程度上能夠提高性能

同上一篇同樣,在jmap -histo中發現MpscChunkedArrayQueue類的實例比較多,javadoc看了下,其原來是出自JC Tools,https://github.com/JCTools/JCTools。java

經過官網,咱們能夠看到,它針對實際的場景對JDK自帶的併發隊列作了一些特定的優化,以下:git

Java Concurrency Tools for the JVM. This project aims to offer some concurrent data structures currently missing from the JDK:github

  • SPSC/MPSC/SPMC/MPMC variations for concurrent queues:併發

    • SPSC - Single Producer Single Consumer (Wait Free, bounded and unbounded)
    • MPSC - Multi Producer Single Consumer (Lock less, bounded and unbounded)
    • SPMC - Single Producer Multi Consumer (Lock less, bounded)
    • MPMC - Multi Producer Multi Consumer (Lock less, bounded)
  • SPSC/MPSC linked array queues offer a balance between performance, allocation and footprintless

  • An expanded queue interface (MessagePassingQueue):源碼分析

    • relaxedOffer/Peek/Poll: trade off conflated guarantee on full/empty queue state with improved performance.
    • drain/fill: batch read and write methods for increased throughput and reduced contention

不過總體瀏覽了下,文檔較少,benchmark提供了用例但沒有看到結果,真用到的時候,能夠看下到底性能能夠提高多少。有一文章對源碼進行了分析(http://blog.csdn.net/youaremoon/article/details/50351929),不過說實話,不知道如今爲何不少人喜歡share源碼分析,僅僅只是源碼分析,對場景化的適用條件以及原理和實現機制卻是考慮的不多。舉個例子,https://www.qcloud.com/community/article/904925001482373849?utm_source=Community&utm_medium=article904925001482373849&utm_campaign=kyzg就是一篇典型的文章,是爲了說明看過源碼了、仍是理解了。一般,我的認爲理解如何實現、適用場景及優缺點是同等重要的,不然就只顧趕路、卻不關心本身在哪裏了。性能

相關文章
相關標籤/搜索