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就是一篇典型的文章,是为了说明看过源码了、仍是理解了。一般,我的认为理解如何实现、适用场景及优缺点是同等重要的,不然就只顾赶路、却不关心本身在哪里了。性能

相关文章
相关标签/搜索