JCTools - Concurrency tools currently missing from the JDK.

Overview

Total alerts Coverage Status Build Status

JCTools

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

  • 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 (bounded and unbounded) offer a balance between performance, allocation and footprint

  • MPSC/MPMC XAdd based, unbounded linked array queues offer reduced contention costs for producers (using XADD instead of a CAS loop), and pooled queue chunks for reduced allocation.

  • 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

There's more to come and contributions/suggestions are most welcome. JCTools has enjoyed support from the community and contributions in the form of issues/tests/documentation/code have helped it grow. JCTools offers excellent performance at a reasonable price (FREE! under the Apache 2.0 License). It's stable and in use by such distinguished frameworks as Netty, RxJava and others. JCTools is also used by commercial products to great result.

Get it NOW!

Add the latest version as a dependency using Maven:

        <dependency>
            <groupId>org.jctools</groupId>
            <artifactId>jctools-core</artifactId>
            <version>3.3.0</version>
        </dependency>

Or use the awesome, built from source, https://jitpack.io/ version, you'll need to add the Jitpack repository:

        <repository>
          <id>jitpack.io</id>
           <url>https://jitpack.io</url>
        </repository>

And setup the following dependency:

        <dependency>
            <groupId>com.github.JCTools.JCTools</groupId>
            <artifactId>jctools-core</artifactId>
            <version>v3.3.0</version>
        </dependency>

You can also depend on latest snapshot from this repository (live on the edge) by setting the version to '3.1.1-SNAPSHOT'.

Build it from source

JCTools is maven built and requires an existing Maven installation and JDK8 (only for building, runtime is 1.6 compliant).

With 'MAVEN_HOME/bin' on the path and JDK8 set to your 'JAVA_HOME' you should be able to run "mvn install" from this directory.

But I have a zero-dependency/single-jar project

While you are free to copy & extend JCTools, we would much prefer it if you have a versioned dependency on JCTools to enable better support, upgrade paths and discussion. The shade plugin for Maven/Gradle is the preferred way to get JCTools fused with your library. Examples are available in the ShadeJCToolsSamples project.

Benchmarks

JCTools is benchmarked using both JMH benchmarks and handrolled harnesses. The benchmarks and related instructions can be found in the jctools-benchmarks module README. Go wild and please let us know how it did on your hardware.

Concurrency Testing

mvn package
cd jctools-concurrency-test
java -jar target/concurrency-test.jar -v

Come up to the lab...

Experimental work is available under the jctools-experimental module. Most of the stuff is developed with an eye to eventually porting it to the core where it will be stabilized and released, but some implementations are kept purely for reference and some may never graduate. Beware the Jabberwock my child.

Have Questions? Suggestions?

The best way to discuss JCTools is on the GitHub issues system. Any question is good, and GitHub provides a better platform for knowledge sharing than twitter/mailing-list/gitter (or at least that's what we think).

Thanks!!!

We have kindly been awarded IntelliJ IDEA licences by JetBrains to aid in the development of JCTools. It's a great suite of tools which has benefited the developers and ultimately the community.

It's an awesome and inspiring company, BUY THEIR PRODUCTS NOW!!!

JCTools has enjoyed a steady stream of PRs, suggestions and user feedback. It's a community! Thank you all for getting involved!

Comments
  • Draft of Blocking Queue

    Draft of Blocking Queue

    Hi Nitsan,

    This is not for merge - just to open the discussion about efficient BlockingQueue implementations.

    The SpscArrayQueueBlocking here is hand-crafted by inheritance of SpscArrayQueue but ultimately I would prefer to have the BlockingQueue Implementations dynamically generated on demand by the QueueFactory.

    Let me know your thoughts before I push it too far.

    Cheers Georges

    opened by georges-gomes 82
  • Transfer array queue

    Transfer array queue

    In Februrary, I found your MpmcArrayQueue, and was very impressed with the performance and lack of generated heap objects (for offer/poll). Being interested in having a similar capability to LinkedTransferQueue (but without any heap allocation), I modified your MpmcArrayQueue to create the "MpmcTransferArrayQueue", using a similar technique that Doug Lea used in the LinkedTransferQueue with regards to park/unpark rules. Since one of the requirements for your library is that it can run on java6, I did not depend on the TransferQueue interface -- I'm not sure the best way to resolve this, perhaps to have offer/poll block instead of having transfer/take?? I'm up for whatever suggestions you may have on this topic.

    Here are my handrolled benchmarks for this queue (based on your spsc benchmark code), and I hope that this queue can find a home in your tools. The bechmarks were run on an i7-4700HQ CPU @ 2.40GHz w/ 16gigs of ram, running Linux 3.13.0-49-generic, x86_64. I did not pin the process to CPUs.

    The non-blocking test results are based on your MpmcArrayQueue implementation, with a small (1024) queue size and a busy-spin on a full queue.

    | Blocking | LBQ | LTQ | MTAQ | | --- | --- | --- | --- | | 1x1 Threads | 3,7m op/s | 6,3m op/s | 3,6m op/s | | 2x2 Threads | 1,9m op/s | 2,4m op/s | 2,9m op/s | | 3x3 Threads | 1,4m op/s | 1,8m op/s | 2,0m op/s | | 4x4 Threads | 0,8m op/s | 1,4m op/s | 1,5m op/s |

    | Non-Blocking | LBQ | LTQ | MTAQ | | --- | --- | --- | --- | | 1x1 Threads | 5,8m op/s | 8,1m op/s | 30,7m op/s | | 2x2 Threads | 1,4m op/s | 3,4m op/s | 6,4m op/s | | 3x3 Threads | 1,2m op/s | 2,3m op/s | 3,8m op/s | | 4x4 Threads | 0,8m op/s | 1,8m op/s | 2,4m op/s |

    opened by dorkbox 29
  • RFE: Add NonBlockingHashMap and friends (formerly known as high-scale-lib)

    RFE: Add NonBlockingHashMap and friends (formerly known as high-scale-lib)

    It seems that this project would an ideal place to have NonBlockingHashMap created by @cliffclick. Unfortunately original project that was hosted on SourceForge (https://sourceforge.net/projects/high-scale-lib/) is dead and has been for quite a while. Also it is buggy, see stephenc/high-scale-lib#5 for one such example.

    The current version of NonBlockingHashMap and supporting classes is available in the https://github.com/h2oai/h2o-3/ project under water.nbhm package.

    The problem with those classes being part of https://github.com/h2oai/h2o-3 project is that it is hard to consumer this project as library since one needs to always exclude transitive dependencies and consume full jar with other classes. Another much bigger problem is that recently NBHM classes become more and more specialized for H2O use cases. In fact it seems that it is no longer possible to use those classes standalone (see https://github.com/h2oai/h2o-3/commit/6ef6f834e67585c55ed6c8b48817749d2643607e).

    Hence this feature request asks to add awesome NBHM classes to this awesome JCTools project.

    /cc @cliffclick

    duplicate enhancement 
    opened by vyazelenko 20
  • Bring in latest Cliff's NHBM to JCTools

    Bring in latest Cliff's NHBM to JCTools

    Up-to-date copy of NonBlockingHashMap and friends. JUnits for all tests, including performance tests. No integration into maven, just the code and tests.

    opened by cliffclick 19
  • MpscBlockingConsumerArrayQueue poll with timeout fix

    MpscBlockingConsumerArrayQueue poll with timeout fix

    Reorder offerAndWakeup() to fix race. Previously the following sequence was possible:

    Consumer                            Provider
    
    poll(timeout)
                                      offerAndWakeup()
    time out
                                      soRefElement(, offset,)
    consume from offset
    offset -> offset'
    poll(timeout)
                                      soBlocked(null)
                                      unpark(consumerThread)
    // Spin for ever
    spinWaitForElement(, offset')
    
    bug 
    opened by philipa 17
  • Batch consuming an MpscLinkedQueue?

    Batch consuming an MpscLinkedQueue?

    Would it be possible/feasible to batch consume the contents of an MpscLinkedQueue? I.e., have a method taking a callback which then traverses the links via plain loads until it reaches the producer's node. So instead of polling one by one, it would move the consumer pointer once and not bother nulling out every node's value.

    question 
    opened by akarnokd 17
  • NonBlockingHashMap remove bug

    NonBlockingHashMap remove bug

    Hi. I was playing with NonBlockingHashMap and found that removes can return one items more than once when executed concurrently. Here is the test sample:

    @Test
    public void testMap() throws Exception {
        final ExecutorService executor = Executors.newFixedThreadPool(32);
    
        final ConcurrentMap<String, String> map = new NonBlockingHashMap<>();
        final String key = UUID.randomUUID().toString();
    
        final int numberOfIterations = 10_000;
        final CountDownLatch latch = new CountDownLatch(numberOfIterations);
    
        CopyOnWriteArrayList<String> addedList = new CopyOnWriteArrayList<>();
        CopyOnWriteArrayList<String> removedList = new CopyOnWriteArrayList<>();
    
        for (int i = 0; i < numberOfIterations; i++) {
            if (i % 2 == 0) {
                executor.submit(() -> {
                    String added = UUID.randomUUID().toString();
                    map.put(key, added);
    
                    addedList.add(added);
    
                    latch.countDown();
                });
            } else {
                executor.submit(() -> {
                    String removed = map.remove(key);
    
                    if (removed != null) {
                        removedList.add(removed);
                    }
    
                    latch.countDown();
                });
            }
        }
    
        assertTrue(latch.await(5, TimeUnit.SECONDS));
    
        assertEquals(addedList.size(), Sets.newHashSet(addedList).size());
        assertEquals(removedList.size(), Sets.newHashSet(removedList).size());
    }
    

    My last assertEquals fails with number of actual removed items more than unique items.

    bug 
    opened by fvlad 16
  • XADD MultiProducer SingleConsumer Array Queue

    XADD MultiProducer SingleConsumer Array Queue

    The mechanics of this queue is similar on how Aeron's Publication (aka the LogBuffer) works, but using only 2 partitions and without background cleaning of the consumed elements. When hit by a single producer the offer and poll has the same semantics of the MpscArrayQueue, otherwise there is the chance that more than the configured capacity will be written (without element losses), exactly as the Aeron's LogBuffer. Benchmarks shows (throughput-wise) perf similar to MpscArrayQueue with Single Producer and a better scalability otherwise (mainly due to XADD).

    opened by franz1981 15
  • AssertionError in NonBlockingHashMap$CHM.copy_check_and_promote(NonBlockingHashMap.java:1082)

    AssertionError in NonBlockingHashMap$CHM.copy_check_and_promote(NonBlockingHashMap.java:1082)

    I'm seeing AssertionErrors from time to time in our CI environment. Here are two stacktraces that show where error is generated:

    java.lang.AssertionError
    	at org.jctools.maps.NonBlockingHashMap$CHM.copy_check_and_promote(NonBlockingHashMap.java:1082)
    	at org.jctools.maps.NonBlockingHashMap$CHM.help_copy_impl(NonBlockingHashMap.java:1036)
    	at org.jctools.maps.NonBlockingHashMap$CHM.access$500(NonBlockingHashMap.java:796)
    	at org.jctools.maps.NonBlockingHashMap.help_copy(NonBlockingHashMap.java:789)
    	at org.jctools.maps.NonBlockingHashMap.putIfMatch(NonBlockingHashMap.java:701)
    	at org.jctools.maps.NonBlockingHashMap.putIfMatch(NonBlockingHashMap.java:378)
    	at org.jctools.maps.NonBlockingHashMap.put(NonBlockingHashMap.java:327)
    

    and

    java.lang.AssertionError
    	at org.jctools.maps.NonBlockingHashMap$CHM.copy_check_and_promote(NonBlockingHashMap.java:1082)
    	at org.jctools.maps.NonBlockingHashMap$CHM.help_copy_impl(NonBlockingHashMap.java:1036)
    	at org.jctools.maps.NonBlockingHashMap$CHM.access$500(NonBlockingHashMap.java:796)
    	at org.jctools.maps.NonBlockingHashMap.help_copy(NonBlockingHashMap.java:789)
    	at org.jctools.maps.NonBlockingHashMap.putIfMatch(NonBlockingHashMap.java:701)
    	at org.jctools.maps.NonBlockingHashMap.putIfMatch(NonBlockingHashMap.java:378)
    	at org.jctools.maps.NonBlockingHashMap.remove(NonBlockingHashMap.java:343)
    

    Here is the line in question NonBlockingHashMap.java#L1082:

    assert (copyDone+workdone) <= oldlen;
    

    While debugging this issue locality I saw the following values that lead to exception:

    copyDone=32	
    workdone=1	
    oldlen=32
    

    Unfortunate I don't have a standalone reproducer but in the test several threads are banging on the map (some add entries and some remove entries). And this test fails sometimes for adders and sometimes for removers.

    The problem is only reproducible with -ea flag. Without it test runs green every time. So what is the purpose of such assertions if actual code run fine even when assertions fail? Maybe @cliffclick knows?

    bug 
    opened by vyazelenko 15
  • SpscLinkedQueue#offer implementation bugs

    SpscLinkedQueue#offer implementation bugs

    Recently, I decided to add Chinese comments to JCTools. When I read the source code of SpscLinkedQueue, the implementation of the offer caused me some confusion, because it may cause consumerNode newer than producerNode and cause bugs. Therefore, I wrote SpscLinkedQueueTest for verification, and an exception occurred.

    The producer should publish the new producerNode first, and then ensure that it is reachable from the consumerNode.

            // final LinkedQueueNode<E> nextNode = newNode(e);
            // final LinkedQueueNode<E> preNode = lpProducerNode();
            // spProducerNode(nextNode);
            // preNode.soNext(nextNode);
    
            final LinkedQueueNode<E> nextNode = newNode(e);
            lpProducerNode().soNext(nextNode);
            spProducerNode(nextNode);
    
    public class SpscLinkedQueueTest {
    
        private static volatile boolean stop = false;
    
        public static void main(String[] args) throws InterruptedException {
            SpscLinkedQueue<String> messageQueue = new SpscLinkedQueue<>();
    
            new Producer(messageQueue).start();
            new Consumer(messageQueue).start();
    
            try {
                Thread.sleep(10 * 1000);
            } finally {
                stop = true;
            }
        }
    
        private static class Producer extends Thread {
    
            final SpscLinkedQueue<String> messageQueue;
    
            long sequence = 0;
    
            Producer(SpscLinkedQueue<String> messageQueue) {
                this.messageQueue = messageQueue;
            }
    
            @Override
            public void run() {
                try {
                    while (!stop) {
                        messageQueue.offer(Long.toString(sequence++));
                        Thread.sleep(1);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    
        private static class Consumer extends Thread {
    
            final SpscLinkedQueue<String> messageQueue;
    
            private Consumer(SpscLinkedQueue<String> messageQueue) {
                this.messageQueue = messageQueue;
            }
    
            @Override
            public void run() {
                while (!stop) {
                    messageQueue.poll();
    
                    if (!messageQueue.isEmpty()) {
                        final String e = messageQueue.poll();
                        if (null == e) {
                            throw new Error("MessageQueue.isEmpty() is false, messageQueue.poll() return null!");
                        }
                    }
                }
            }
    
        }
    }
    

    Exception in thread "Thread-1" java.lang.Error: MessageQueue.isEmpty() is false, messageQueue.poll() return null! at com.wjybxx.fastjgame.concurrenttest.SpscLinkedQueueTest$Consumer.run(SpscLinkedQueueTest.java:84)

    opened by hl845740757 14
  • Add JMH benchmark for concurrent maps.

    Add JMH benchmark for concurrent maps.

    This is pretty much a straight up port of the existing perf_hash_test to JMH, per #108. I moved SimpleRandom out of perf_hash_test.

    Result of running both on the same machine:

    jctools-benchmarks git:(nbhm-jmh)% for t in 2 4 6 8; do java -jar target/microbenchmarks.jar ConcurrentMapsThroughput.rand -t $t -f 1; done
    
    # Threads: 2 threads, will synchronize iterations
    # Benchmark: org.jctools.maps.nhbm_test.jmh.ConcurrentMapsThroughput.randomGetPutRemove
    # Parameters: (implementation = NonBlockingHashMap, readRatio = 50, tableSize = 100000)
    
    Benchmark                                      (implementation)  (readRatio)  (tableSize)   Mode  Cnt         Score         Error  Units
    ConcurrentMapsThroughput.randomGetPutRemove  NonBlockingHashMap           50       100000  thrpt    6  17923933.571 ±  912895.637  ops/s
    ConcurrentMapsThroughput.randomGetPutRemove   ConcurrentHashMap           50       100000  thrpt    6  23668440.241 ± 5684267.690  ops/s
    
    ###
    
    # Threads: 4 threads, will synchronize iterations
    # Benchmark: org.jctools.maps.nhbm_test.jmh.ConcurrentMapsThroughput.randomGetPutRemove
    # Parameters: (implementation = NonBlockingHashMap, readRatio = 50, tableSize = 100000)
    
    Benchmark                                      (implementation)  (readRatio)  (tableSize)   Mode  Cnt         Score         Error  Units
    ConcurrentMapsThroughput.randomGetPutRemove  NonBlockingHashMap           50       100000  thrpt    6  44864770.568 ± 1202113.075  ops/s
    ConcurrentMapsThroughput.randomGetPutRemove   ConcurrentHashMap           50       100000  thrpt    6  43945366.601 ± 3180110.185  ops/s
    
    ###
    
    # Threads: 6 threads, will synchronize iterations
    # Benchmark: org.jctools.maps.nhbm_test.jmh.ConcurrentMapsThroughput.randomGetPutRemove
    # Parameters: (implementation = NonBlockingHashMap, readRatio = 50, tableSize = 100000)
    
    Benchmark                                      (implementation)  (readRatio)  (tableSize)   Mode  Cnt         Score         Error  Units
    ConcurrentMapsThroughput.randomGetPutRemove  NonBlockingHashMap           50       100000  thrpt    6  57554032.876 ±  335786.149  ops/s
    ConcurrentMapsThroughput.randomGetPutRemove   ConcurrentHashMap           50       100000  thrpt    6  56251688.387 ± 3140116.465  ops/s
    
    ###
    
    # Threads: 8 threads, will synchronize iterations
    # Benchmark: org.jctools.maps.nhbm_test.jmh.ConcurrentMapsThroughput.randomGetPutRemove
    # Parameters: (implementation = NonBlockingHashMap, readRatio = 50, tableSize = 100000)
    
    Benchmark                                      (implementation)  (readRatio)  (tableSize)   Mode  Cnt         Score         Error  Units
    ConcurrentMapsThroughput.randomGetPutRemove  NonBlockingHashMap           50       100000  thrpt    6  64094875.527 ± 2180806.338  ops/s
    ConcurrentMapsThroughput.randomGetPutRemove   ConcurrentHashMap           50       100000  thrpt    6  62433923.436 ± 2661512.313  ops/s
    
    
    jctools-benchmarks git:(nbhm-jmh)% java -cp ... org.jctools.maps.nhbm_test.perf_hash_test
    50% gets, 25% inserts, 25% removes, table_size=100000 Best
    Threads from 2 to 8 by 2
    Warmup -variance:
    ===     CHM_16    2  cnts/sec=   22514871
    ===  NBHashMap    2  cnts/sec=   16893822 size=1048578
    ==== HashMap  Threads   Trial:    0          1          2          3          4          5          6          Avg      Stddev
    ===     CHM_16    2  cnts/sec=   17159725   24732722   24932298   25377222   23633198   25029976   25464857   24898332 (+/- 0%)  65377
    ===  NBHashMap    2  cnts/sec=   17281654   18891777   17008697   17564187   19901123   19047840   19239117   18501268 (+/- 4%)  65841 size=1048578
    ===     CHM_16    4  cnts/sec=   45679183   45948000   45803727   45934142   45873051   45820472   45274057   45967458 (+/- 0%)  65452
    ===  NBHashMap    4  cnts/sec=   45759998   46562757   46239087   46287162   46085904   45991481   46322006   46204051 (+/- 0%)  65443 size=1048578
    ===     CHM_16    6  cnts/sec=   57408141   58173032   58174207   58186218   58161588   58219358   58191284   58177819 (+/- 0%)  65507
    ===  NBHashMap    6  cnts/sec=   57648986   58911525   59107223   58633843   58790711   58970249   58758884   58820373 (+/- 0%)  65471 size=1048578
    ===     CHM_16    8  cnts/sec=   64764567   64139703   64566574   64774410   65508813   65302646   65318703   64947207 (+/- 0%)  65630
    ===  NBHashMap    8  cnts/sec=   65516278   63649737   65449784   66149245   65772432   65584908   65647868   65583018 (+/- 0%)  65458 size=1048578
    

    Bonus: now supports HashMap as a baseline (this is not enabled by default). If run in a single- threaded mode, the HashMap will not be synchronized.

    opened by pcholakov 14
  • Fixes #367: generate a JPMS module descriptor

    Fixes #367: generate a JPMS module descriptor

    Until now jctools-core used the Apache Felix Maven Bundle Plugin to generate its OSGI descriptor.

    This PR:

    • moves the internal classes to the org.jctools.util.internal. If needed this package can be exported to other JCTools artifacts using the @ExportTo annotation from BND.
    • exports only explicitly annotated packages (i.e. all except org.jctools.util.internal). The OSGI descriptor becomes:
    Export-Package: 
     org.jctools.queues.atomic;version="4.0.2";uses:="org.jctools.queues",
     org.jctools.queues.unpadded;version="4.0.2";uses:="org.jctools.queues",
     org.jctools.queues;version="4.0.2",
     org.jctools.maps;version="4.0.2",
     org.jctools.util;version="4.0.2",
     org.jctools.counters;version="4.0.2"
    Import-Package: sun.misc;resolution:=optional
    Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
    
    • automatically generates a module-info.class JPMS descriptor, which is in sync (cf. JPMS libraries) with the OSGI descriptor:
    module [email protected] {
      requires java.base;
      requires static jdk.unsupported;
      exports org.jctools.queues;
      exports org.jctools.queues.atomic;
      exports org.jctools.queues.unpadded;
      exports org.jctools.maps;
      exports org.jctools.util;
      exports org.jctools.counters;
    }
    

    This descriptor can be generated by JDK 8.

    opened by ppkarwasz 0
  • Add a parallel `forEach()` method in `NonBlockingHashMap`

    Add a parallel `forEach()` method in `NonBlockingHashMap`

    Feature Request

    Add a method to NonBlockingHashMap similar to the parallel forEach method in ConcurrentHashMap.

    Background

    In Bazel we currently use Guava's interners, but we are looking at other strategies for interning in order to reduce storage cost. Our estimate is that > 6% of Bazel's memory cost is from the interning data structures (not including the elements, just the storage).

    We are interested in switching from ConcurrentHashMap to NonBlockingHashMap primarily for the getk() method, which would allow Bazel's main graph map to double as an interner for its keys, replacing Guava interners and the storage cost they entail. A parallel iteration method would close the gap vs our current usage of ConcurrentHashMap.

    enhancement 
    opened by justinhorvitz 0
  • Add CodeQL workflow for GitHub code scanning

    Add CodeQL workflow for GitHub code scanning

    Hi JCTools/JCTools!

    This is a one-off automatically generated pull request from LGTM.com :robot:. You might have heard that we’ve integrated LGTM’s underlying CodeQL analysis engine natively into GitHub. The result is GitHub code scanning!

    With LGTM fully integrated into code scanning, we are focused on improving CodeQL within the native GitHub code scanning experience. In order to take advantage of current and future improvements to our analysis capabilities, we suggest you enable code scanning on your repository. Please take a look at our blog post for more information.

    This pull request enables code scanning by adding an auto-generated codeql.yml workflow file for GitHub Actions to your repository — take a look! We tested it before opening this pull request, so all should be working :heavy_check_mark:. In fact, you might already have seen some alerts appear on this pull request!

    Where needed and if possible, we’ve adjusted the configuration to the needs of your particular repository. But of course, you should feel free to tweak it further! Check this page for detailed documentation.

    Questions? Check out the FAQ below!

    FAQ

    Click here to expand the FAQ section

    How often will the code scanning analysis run?

    By default, code scanning will trigger a scan with the CodeQL engine on the following events:

    • On every pull request — to flag up potential security problems for you to investigate before merging a PR.
    • On every push to your default branch and other protected branches — this keeps the analysis results on your repository’s Security tab up to date.
    • Once a week at a fixed time — to make sure you benefit from the latest updated security analysis even when no code was committed or PRs were opened.

    What will this cost?

    Nothing! The CodeQL engine will run inside GitHub Actions, making use of your unlimited free compute minutes for public repositories.

    What types of problems does CodeQL find?

    The CodeQL engine that powers GitHub code scanning is the exact same engine that powers LGTM.com. The exact set of rules has been tweaked slightly, but you should see almost exactly the same types of alerts as you were used to on LGTM.com: we’ve enabled the security-and-quality query suite for you.

    How do I upgrade my CodeQL engine?

    No need! New versions of the CodeQL analysis are constantly deployed on GitHub.com; your repository will automatically benefit from the most recently released version.

    The analysis doesn’t seem to be working

    If you get an error in GitHub Actions that indicates that CodeQL wasn’t able to analyze your code, please follow the instructions here to debug the analysis.

    How do I disable LGTM.com?

    If you have LGTM’s automatic pull request analysis enabled, then you can follow these steps to disable the LGTM pull request analysis. You don’t actually need to remove your repository from LGTM.com; it will automatically be removed in the next few months as part of the deprecation of LGTM.com (more info here).

    Which source code hosting platforms does code scanning support?

    GitHub code scanning is deeply integrated within GitHub itself. If you’d like to scan source code that is hosted elsewhere, we suggest that you create a mirror of that code on GitHub.

    How do I know this PR is legitimate?

    This PR is filed by the official LGTM.com GitHub App, in line with the deprecation timeline that was announced on the official GitHub Blog. The proposed GitHub Action workflow uses the official open source GitHub CodeQL Action. If you have any other questions or concerns, please join the discussion here in the official GitHub community!

    I have another question / how do I get in touch?

    Please join the discussion here to ask further questions and send us suggestions!

    opened by lgtm-com[bot] 0
  • Missing `Automatic-Module-Name` in 4.0.1 (regression)

    Missing `Automatic-Module-Name` in 4.0.1 (regression)

    Version 4.0.1 on Maven Central does not contain an Automatic-Module-Name (introduced in #289) in the manifest. I am not able to reproduce the problem compiling the v4.0.1 tag from sources, but it must be caused by the maven-jar-plugin configuration on the host that built the released artifact.

    Remark that the currently used maven-bundle-plugin version supports the automatic generation of JPMS module descriptors (even on JDK 8) through the <_jpms-module-info/> instruction. The generated module descriptor is functionally equivalent to the generated OSGI bundle descriptor. I can provide a PR that modularizes jctools-core, jctools-channels and jctools-experimental.

    bug 
    opened by ppkarwasz 2
  • any plans on fitting virtual threads

    any plans on fitting virtual threads

    since jdk19 has released,any plans on fitting the new virtual threads model? I noticed many implementation depends on keeping the thread spinning, might not so efficient?

    enhancement 
    opened by microhardsmith 1
  • Publish test jar as part of the release

    Publish test jar as part of the release

    Sometimes projects may need to embed part of JCTool's and can benefit by reusing some of the test infrastructure. This is a use at your own risk type of option, but is very low effort to offer with that expected caveat. By following the Maven's Guide to using attached tests, an additional artifact is available with the tests classifier. For example, this way Caffeine could reuse your QueueSanityTest rather than copying it in locally.

    enhancement 
    opened by ben-manes 0
Releases(v4.0.1)
  • v4.0.1(Sep 8, 2022)

    This is a major release, following the removal of the QueueFactory, AtomicQueueFactory and org.jctools.queues.spec package(deprecated since 3.0). These classes are still used for testing, but are not part of the release artifacts anymore. New unpadded queue variants are also included in this release. Further changes included:

    And many improvements to testing and code generation.

    Source code(tar.gz)
    Source code(zip)
  • v3.3.0(Mar 4, 2021)

    3.3.0

    This is a minor release with new features and several bug fixes.

    Bug fixes:

    • #334 NBHMLong iterators do not remove NO_KEY (thanks @matteobertozzi)
    • #335 NBHM/Long/Identity iterators only removes keys if values have not changed. Now follow JDK convention.
    • #336 MpscBlockingConsumerArrayQueue: fix race writing to blocked field (thanks @philipa)
    • #339 fill wakeup call can spin forever(or until a consumer is blocked again) on MpscBlockingConsumerArrayQueue

    New features:

    • #340 MpscBlockingConsumerArrayQueue provide a new blocking drain variant (thanks @franz1981)

    Thanks to all the contributors, bug reporters and reviewers!

    Source code(tar.gz)
    Source code(zip)
  • v3.2.0(Nov 27, 2020)

    This is a minor release with one new feature and several bug fixes.

    Bug fixes:

    • #319 Relying on test cases provided by @alefedor (#328) we apply the fix used for #205 to NonBlockingHashMapLong and NonBlockingIdentityHashMap to provide getAndSet like semantics for put and remove.
    • #330 Fix a NonBlockingIdentityHashMap replace bug. During this fix some further work was done to bring the code closer in line to the current state of NonBlockingHashMap

    Enhancements:

    • #326 Xadd queues consumers can help producers
    • #323 Update to latest JCStress (thanks @shipilev )
    • Further build and doc improvements (thanks @kay @Rjbeckwith55 @pveentjer )

    New features:

    • After long incubation and following a user request (see #321), we move counters (introduced in #93 by @qwwdfsad) into core!
    • Merging some experimental utils and a #264 we add a PaddedAtomicLong, thanks @pveentjer

    Thanks to all the contributors, bug reporters and reviewers!

    Source code(tar.gz)
    Source code(zip)
  • v3.1.0(Aug 6, 2020)

    This is a minor release with one new feature and several bug fixes.

    Bug fixes:

    • Use byte fields for padding (avoid upcoming false sharing problem in JDK 15+ where field ordering has changed)
    • #289 Add Automatic-Module-Name header to MANIFEST.MF (thanks @vy)
    • #292 Fix inconsistent isEmpty/poll/peek/offer dynamics for SpscLinkedQueue : https://github.com/JCTools/JCTools/commit/5fd57720bf19fcd8d93a91c6281f8c41d5ee6b00#diff-b17b0df9e15e7821411b77042876eb02 (thanks @hl845740757 and @franz1981)
    • Fixed potential for negative queue size for indexed queues and similar issue with isEmpty : https://github.com/JCTools/JCTools/commit/5fd57720bf19fcd8d93a91c6281f8c41d5ee6b00#diff-f32b0a7583f04b29affe3c5f0486df4f (thanks @hl845740757 and @franz1981)
    • #296 Fix peek/relaxedPeek race with poll/offer in MC queues (thanks @hl845740757 and @franz1981)
    • #297 Fix inconsistent size of FF based queues causing potential size() > capacity() (thanks @hl845740757)
    • #316 Fix MpscBlockingConsumerArrayQueue::poll(TimeUnit,timeout) (thanks @philipa , @njhill and @franz1981)
    • #310 Fix MpmcUnboundedXaddArrayQueue::peek/relaxedPeek can load "future" elements (thanks @franz1981)

    New feature:

    • #314 MpscBlockingConsumerArrayQueue::offerIfBelowThreshold is added (thanks @philipa)

    Thanks to all the contributors, bug reporters and reviewers!

    Source code(tar.gz)
    Source code(zip)
  • v3.0.0(Jan 3, 2020)

    This is a major version as there are some minor API breaking changes which may effect users. Please apply with care and provide feedback. The breaking changes:

    • Removed MpscLinkedQueue7 and MpscLinkedQueue8 and consolidate into parent. This removes the need for the builder method on MpscLinkedQueue.
    • Deprecated QueueFactory and spec package classes. These are not used by any users AFAICT and are only used for testing internally.
    • Removed some internal classes and reduced visibility of internal utilities where practical. The @InternalAPI tagging annotation is also used more extensively to discourage dependency.

    We also have some great new queues for y'all to try:

    • #226: XADD unbounded mpsc/mpmc queue: highly scalable linked array queues (from @franz1981)
    • New blocking consumer MPSC (with contributions and bug fixes from @njhill)

    Bug fixes:

    • #209: On Arm7, non-volatile long can have unaligned address leading to error
    • #216: Size of SpscGrowableArrayQueue can exceeds max capacity (from @franz1981 PR #218)
    • #241: Protect the producer index in case of OutOfMemoryError (from @franz1981)
    • #244: Long NBHM AssertionError when replacing missing key (thanks @fvlad for reporting and @cliffclick for assistance and review)
    • Fix argument checks on fill/drain methods
    • Fix LGTM warning, potential int overflow bug b467d29, 15d944c, 6367951

    Improvements:

    • Don't mark generated linked atomic queues as final (from @kay 9db418c)
    • #211: Implement batching methods on MpmcArrayQueue (from @franz1981)
    • #228: Iterator for MpscArrayQueue and MpscUnboundedArrayQueue (PR #229 from @srdo)
    • Iterator support also available for the *ArrayQueue classes
    • #208: MpscLinkedAtomicQueue can be made not final
    • #237: Add scale to exception message to help debug netty/netty#8916 (from @johnou)

    Many other improvements to testing, javadoc, formatting were made with some contributions from @Hearen @JanStureNielsen @nastra thanks!

    Source code(tar.gz)
    Source code(zip)
  • v2.1.2(Mar 11, 2018)

    PR #202 : Fix NBHM bug in remove/replace where ref equality was used to report val match instead of equals (thanks @henri-tremblay) PR #206 : Improved javadoc (thanks @franz1981) Issue #205 : NBHM remove/put getAndSet semantics issue (thanks @fvlad for reporting and @cliffclick for review) Issue #208 : no need for queues to be final

    Further improvements to testing and code style.

    Not included in the release, but very much appreciated, are contributions from @franz1981 and @qwwdfsad to the experimental part of JCTools, which may one day get merged into core, and @maseev contribution to integrate build with Coveralls.io.

    Source code(tar.gz)
    Source code(zip)
  • v2.1.1(Sep 25, 2017)

    PR #193 : Fix API break on release in MpscLinkedAtomicQueue Issue #194 : Fix MpscCompoundQueue::relaxedOffer bug Issue #196 : Fix MpscLinkedArray::fill bug Issue #197 : Fix MpscChunkedQueue:fill bug

    Further improvements to testing. Thanks @Scottmitch and @mlex for reporting issues and helping resolve them!

    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Aug 21, 2017)

    Bug fixes:

    • PR #188 JvmInfo called from Atomic queues invokes Unsafe methods (thanks @kay )

    Features:

    • PR #187 + #186 + #185 Atomic queues are now generated from source (thanks @kay )
    • PR #184 + #190 MpscLinked supports a remove method (thanks @Scottmitch )
    • PR #183 Make SpscLinkedArray queues support the MPQ interface (thanks @franz1981 )
    • PR #181 Testing was expanded for NBHM, and minor issue fixed (thanks @qwwdfsad )

    Some further improvements to formatting, javadoc and testing and general tending to the garden by @nitsanw

    Source code(tar.gz)
    Source code(zip)
  • v2.0.2(May 29, 2017)

    jctools-core changes:

    • PR #168 from @maseev - unifying the approach to queue size range checks and exceptions
    • PR #173 #174 #176 from @neomatrix369 - porting the SPSC linked array queues to non-unsafe versions
    • PR #172 #175 from @chbatey - porting the MPSC linked array queues to non-unsafe versions
    • Fix #179 - bug in MpmcArrayQueue and MpmcAtomicArrayQueue leading to false reporting of queue full on offer which races with a poll, reported by Sharath Gururaj (I think that is @flipsha)

    Further contributions:

    • JCStress testing support added by @victorparmar
    • Code tidy up by @avalanche123
    • Experimental support for MPSC proxy channels by @kay

    Thanks everyone!

    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Jan 3, 2017)

    Fixing up a couple of issues:

    • #143 - toString() didn't work for many of the queues because the default implemetation relied on iterators.
    • #151 fixed by @cliffclick and helped by @vyazelenko - bringing in some fixes and improvements to NHBM
    • Minor javadoc touchups
    Source code(tar.gz)
    Source code(zip)
  • v2.0(Oct 28, 2016)

    • PR #94 : The NonBlockingHashMap by @cliffclick is now released as part of JCTools core. Also thanks to @pcholakov for help is converting and sanity testing some of the benchmark code (PR #108).
    • PR #129 : MPSC linked array queues code is tidied up and split into 3 implementations. The old Chunked is here, but constructor has changed. Growable is split from chunked and Unbounded is added.
    • Bug #135 : Bug fix for the growable MPSC case.
    • PR #127 : Releasing JCTools as an OSGi bundle, thanks @CodingFabian !
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Jun 24, 2016)

    • PERF: Fix GC nepotism issue in SpscUnboundedArrayQueue (Issue #95, PR #96, courtesy of @akarnokd)
    • PERF: Unified base implementation to SpscUnbounded/Growable (Issue #103, PR #107, courtesy of @pcholakov)
    • BUG: IllegalStateException during MpscChunkedArrayQueue.offer(....) (Issue #115)
    • BUG: new MpscChunkedArrayQueue(1024, Integer.MAX_VALUE, ...) throws confusing exception (Issue #116)
    • BUG: SpscGrowable/SpscUnbounded/SpscAtomic/SpscUnboundedAtomic !isEmpty() but poll() == null (Issue #119)
    • BUG: MpscArrayQueue.offerIfBelowTheshold is broken: offering is still possible when queue is full (Issue #120)
    Source code(tar.gz)
    Source code(zip)
  • v1.2(Mar 15, 2016)

    • Added MpscChunkedArrayQueue an MPSC bounded queue aiming to replace current usage of MpscLinkedQueue in usecases where low footprint AND low GC churn are desirable. This is acheived through usage of smaller buffers which are then linked to either bigger buffers or same sized buffers as queue size demands.
    • Fixed a GC nepotism issue in linked queues. This is not a bug but an observable generational GC side effect causing false promotion of linked nodes because of a reference from a promoted dead node. See discussion here: https://github.com/akka/akka/issues/19216
    • Fixed an inconsistently handled exception on offering null elements. This was a bug in MpmcArrayQueue.
    • Formatting and refactoring

    Contributions made by:

    • https://github.com/guidomedina
    • https://github.com/kay
    Source code(tar.gz)
    Source code(zip)
  • v1.1(Mar 16, 2016)

  • v1.1-alpha(Apr 29, 2015)

    Some new toys in core since V1.0:

    • New Spsc queues, growable and unlimited ArrayQueues
    • New Atomic implementations which don't use Unsafe (thanks to @akarnokd)
    • Minor tweaks and fixes
    Source code(tar.gz)
    Source code(zip)
Automon combines the power of AOP (AspectJ) with monitoring or logging tools you already use to declaratively monitor your Java code, the JDK, and 3rd party libraries.

Automon Automon combines the power of AOP (AspectJ) with monitoring tools or logging tools that you already use to declaratively monitor the following

Steve Souza 561 Nov 27, 2022
GMC-Tools - Plugin with basic tools for Minecraft server administrator

GMC-Tools - Plugin with basic tools for Minecraft server administrator. Currently we do not support configuration files and we do not recommend using this plugin on production servers.

GamesMC Studios 4 Jan 14, 2022
The missing bridge between Java and native C++

JavaCPP Commercial support: Introduction JavaCPP provides efficient access to native C++ inside Java, not unlike the way some C/C++ compilers interact

Bytedeco 4k Jan 8, 2023
Dremio - the missing link in modern data

Dremio Dremio enables organizations to unlock the value of their data. Documentation Documentation is available at https://docs.dremio.com. Quickstart

Dremio 1.2k Dec 31, 2022
Source codes of book Java Concurrency In Practice, rebuild by maven.

Introduction Source codes of book: Java Concurrency In Practice(2011, Brain Goetz etc. jcip for short.), rebuild from https://jcip.net/ with maven. Mo

Sam Sune 2 Jun 9, 2022
Duel Threads - Concurrency techniques duel it out for the championship (and bragging rights)

Duel Threads Concurrency techniques duel it out for the championship (and bragging rights) Phases: Argue over rules, challenges and the grand prize Se

Jason Sipula 2 May 9, 2022
Operating Systems - Concepts of computer operating systems including concurrency, memory management, file systems, multitasking, performance analysis, and security. Offered spring only.

Nachos for Java README Welcome to Nachos for Java. We believe that working in Java rather than C++ will greatly simplify the development process by p

Sabir Kirpal 1 Nov 28, 2021
PolarDB-X is a cloud native distributed SQL Database designed for high concurrency, massive storage, complex querying scenarios.

中文文档 What is PolarDB-X ? PolarDB-X is a cloud native distributed SQL Database designed for high concurrency, massive storage and complex querying scen

null 1.2k Dec 31, 2022
Resconstruct is a java library to infer missing information vectors of java classes.

Reconstruct Resconstruct is a java library to infer missing information vectors of java classes. Features Phantom classes Inheritance solving Dummy fi

Nowilltolife 14 Nov 17, 2022
An Auction website. Users can Put up items for sale, bid on currently active auctions and write reviews for items that they have won in the auctions.

Auction-Project An Auction website. Users can Put up items for sale, bid on currently active auctions and write reviews for items that they have won i

Nika Salia 3 Sep 7, 2021
Make a customized list of exercises, create and save workouts, and be led through your routine. This application is currently under development.

HIIT Workout Builder ABOUT This application allows you to create and be led through customized high-intensity interval training (HIIT) sessions. The a

null 1 Nov 28, 2022
IntelliJ Platform plugin that shows the file name of the currently open file in the status bar.

IntelliJ Platform plugin that shows the file name of the currently open file in the status bar. Clicking shows a list of recent files.

Christoffer Hammarström 4 May 9, 2022
Bank Statement Analyzer Application that currently runs in terminal with the commands: javac Application.java java Application [file-name].csv GUI coming soon...

Bank Statement Analyzer Application that currently runs in terminal with the commands: javac Application.java java Application [file-name].csv GUI coming soon...

Hayden Hanson 0 May 21, 2022
Convenient search view for Eclipse to find/replace within the currently active editor.

Find/Replace View plugin for Eclipse Feedback and high-quality pull requests are highly welcome! About What is it? Installation Building from Sources

Sebastian Thomschke 3 May 25, 2022
Drifty is an open-source interactive File Downloader system built with java. It is currently available in CLI mode and has the GUI version under active development.

Drifty Drifty is an open-source interactive File Downloader system built using Java. It takes the link to the file, the directory where it needs to be

Saptarshi Sarkar 60 Dec 24, 2022
Provides additional date-time classes that complement those in JDK 8

ThreeTen-Extra ThreeTen-Extra provides additional date-time classes that complement those in JDK 8. Not every piece of date/time logic is destined for

ThreeTen 361 Jan 8, 2023