Comments (1)
It turns out that removing AtomicReference
s (& simlar) in favor of VarHandle
s 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
:
modified:
from jox.
Related Issues (20)
- Could you use a LongAdder instead of AtomicLong HOT 3
- Consider using a different build system
- Add module-info
- Change package to com.softwaremill.jox
- Make Channel final
- Remove nesting of exceptions/ChannelClosed
- Consider adding concurrency tests using JCStress
- Consider renaming `done()` to `close()` and implementing `AutoCloseable`
- Support default clauses in selects
- In select, return Done only when all channels are done
- Improve performance tests
- Add isClosedForSend / isClosedForReceive
- Remove filtering done channels in select
- Potential memory leak when the channel only sees interrupted sends
- Allow using Future-s in select
- Add a broadcast channel, also usable in select
- Add reactive streams interoperability
- Add a wrapper exception when rethrowing exceptions in send/receive
- Channel stop receiving HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jox.