Coder Social home page Coder Social logo

Comments (1)

adamw avatar adamw commented on May 24, 2024

It turns out that removing AtomicReferences (& simlar) in favor of VarHandles doesn't improve performance, in fact sometimes it is worse.

First, test results using the original code:

Benchmark                               (capacity)  (chainLength)  (parallelism)  Mode  Cnt     Score     Error  Units
BufferedBenchmark.arrayBlockingQueue             1            N/A            N/A  avgt   20  2095.593 ± 177.599  ns/op
BufferedBenchmark.arrayBlockingQueue            10            N/A            N/A  avgt   20   367.676 ±  24.427  ns/op
BufferedBenchmark.arrayBlockingQueue           100            N/A            N/A  avgt   20   107.827 ±   1.675  ns/op
BufferedBenchmark.channel                        1            N/A            N/A  avgt   20   228.243 ±   7.701  ns/op
BufferedBenchmark.channel                       10            N/A            N/A  avgt   20   177.787 ±   6.996  ns/op
BufferedBenchmark.channel                      100            N/A            N/A  avgt   20   137.060 ±   6.589  ns/op
ChainedBenchmark.channelChain                    0          10000            N/A  avgt   20   154.699 ±   2.209  ns/op
ChainedBenchmark.channelChain                  100          10000            N/A  avgt   20     7.864 ±   0.240  ns/op
ChainedBenchmark.queueChain                      0          10000            N/A  avgt   20    83.437 ±   1.607  ns/op
ChainedBenchmark.queueChain                    100          10000            N/A  avgt   20     5.400 ±   1.097  ns/op
ParallelBenchmark.parallelChannels               0            N/A          10000  avgt   20   149.495 ±   6.335  ns/op
ParallelBenchmark.parallelChannels             100            N/A          10000  avgt   20    11.031 ±   0.099  ns/op
ParallelBenchmark.parallelQueues                 0            N/A          10000  avgt   20    86.549 ±   3.922  ns/op
ParallelBenchmark.parallelQueues               100            N/A          10000  avgt   20    15.760 ±   0.126  ns/op
RendezvousBenchmark.channel                    N/A            N/A            N/A  avgt   20   178.605 ±  11.120  ns/op
RendezvousBenchmark.exchanger                  N/A            N/A            N/A  avgt   20    93.763 ±   2.815  ns/op
RendezvousBenchmark.synchronousQueue           N/A            N/A            N/A  avgt   20  1418.993 ±  84.143  ns/op
SelectBenchmark.selectWithSingleClause         N/A            N/A            N/A  avgt   20   240.426 ±  17.889  ns/op
SelectBenchmark.selectWithTwoClauses           N/A            N/A            N/A  avgt   20   458.217 ±  38.065  ns/op

and the modified one:

Benchmark                               (capacity)  (chainLength)  (parallelism)  Mode  Cnt     Score     Error  Units
BufferedBenchmark.arrayBlockingQueue             1            N/A            N/A  avgt   20  2096.575 ± 178.763  ns/op
BufferedBenchmark.arrayBlockingQueue            10            N/A            N/A  avgt   20   371.569 ±  21.292  ns/op
BufferedBenchmark.arrayBlockingQueue           100            N/A            N/A  avgt   20   109.351 ±   3.441  ns/op
BufferedBenchmark.channel                        1            N/A            N/A  avgt   20   246.394 ±  17.874  ns/op
BufferedBenchmark.channel                       10            N/A            N/A  avgt   20   209.877 ±   5.067  ns/op
BufferedBenchmark.channel                      100            N/A            N/A  avgt   20   141.476 ±   8.357  ns/op
ChainedBenchmark.channelChain                    0          10000            N/A  avgt   20   173.824 ±   1.723  ns/op
ChainedBenchmark.channelChain                  100          10000            N/A  avgt   20     8.703 ±   0.316  ns/op
ChainedBenchmark.queueChain                      0          10000            N/A  avgt   20    93.446 ±  10.738  ns/op
ChainedBenchmark.queueChain                    100          10000            N/A  avgt   20     4.325 ±   0.198  ns/op
ParallelBenchmark.parallelChannels               0            N/A          10000  avgt   20   143.736 ±   2.066  ns/op
ParallelBenchmark.parallelChannels             100            N/A          10000  avgt   20     9.803 ±   0.054  ns/op
ParallelBenchmark.parallelQueues                 0            N/A          10000  avgt   20    99.582 ±  12.161  ns/op
ParallelBenchmark.parallelQueues               100            N/A          10000  avgt   20    15.506 ±   0.121  ns/op
RendezvousBenchmark.channel                    N/A            N/A            N/A  avgt   20   220.929 ±   7.744  ns/op
RendezvousBenchmark.exchanger                  N/A            N/A            N/A  avgt   20    92.825 ±   0.892  ns/op
RendezvousBenchmark.synchronousQueue           N/A            N/A            N/A  avgt   20  1452.203 ± 229.371  ns/op
SelectBenchmark.selectWithSingleClause         N/A            N/A            N/A  avgt   20   290.090 ±  23.935  ns/op
SelectBenchmark.selectWithTwoClauses           N/A            N/A            N/A  avgt   20   672.587 ±  33.612  ns/op

The channelChain stress-test behaves worse (154/7 ms vs 173/7ms).
The parallelChannels test behaves better (149/11 ms vs 143/9ms).

Inspecting flame graphs, it turns out that the original version is inlined more aggressivelly, so maybe that's part of the answer:

original for updateCellReceive:

image

modified:

image

from jox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.