Performant synchronized queue and stack data structures in Java

Started [lock] profiling                                                                                                                       
--- Execution profile ---
Total samples : 713834
Frame buffer usage : 0.0288%

--- 1106165618177 ns (58.97%), 395609 samples
[ 0] org.apache.tomcat.util.collections.SynchronizedStack
[ 1] org.apache.tomcat.util.collections.SynchronizedStack.push
[ 2] org.apache.tomcat.util.net.NioBlockingSelector.write
[ 3] org.apache.tomcat.util.net.NioSelectorPool.write
[ 4] org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite
[ 5] org.apache.tomcat.util.net.SocketWrapperBase.doWrite
[ 6] org.apache.tomcat.util.net.SocketWrapperBase.flushBlocking
[ 7] org.apache.tomcat.util.net.SocketWrapperBase.flush
[ 8] org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.end
[ 9] org.apache.coyote.http11.filters.IdentityOutputFilter.end
[10] org.apache.coyote.http11.Http11OutputBuffer.end
[11] org.apache.coyote.http11.Http11Processor.finishResponse
[12] org.apache.coyote.AbstractProcessor.action
[13] org.apache.coyote.Response.action
[14] org.apache.catalina.connector.OutputBuffer.close
[15] org.apache.catalina.connector.Response.finishResponse
[16] org.apache.catalina.connector.CoyoteAdapter.service
[17] org.apache.coyote.http11.Http11Processor.service
[18] org.apache.coyote.AbstractProcessorLight.process
[19] org.apache.coyote.AbstractProtocol$ConnectionHandler.process
[20] org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
[21] org.apache.tomcat.util.net.SocketProcessorBase.run
[22] java.util.concurrent.ThreadPoolExecutor.runWorker
[23] java.util.concurrent.ThreadPoolExecutor$Worker.run
[24] org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run
[25] java.lang.Thread.run

--- 769519847169 ns (41.03%), 314384 samples
[ 0] org.apache.tomcat.util.collections.SynchronizedStack
[ 1] org.apache.tomcat.util.collections.SynchronizedStack.pop
[ 2] org.apache.tomcat.util.net.NioBlockingSelector.write
[ 3] org.apache.tomcat.util.net.NioSelectorPool.write
[ 4] org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite
[ 5] org.apache.tomcat.util.net.SocketWrapperBase.doWrite
[ 6] org.apache.tomcat.util.net.SocketWrapperBase.flushBlocking
[ 7] org.apache.tomcat.util.net.SocketWrapperBase.flush
[ 8] org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.end
[ 9] org.apache.coyote.http11.filters.IdentityOutputFilter.end
[10] org.apache.coyote.http11.Http11OutputBuffer.end
[11] org.apache.coyote.http11.Http11Processor.finishResponse
....
SynchronizedCollectionsBenchmark.concurrentLinkedDeque  thrpt    5        5360524.349 ±   405803.655  ops/s
SynchronizedCollectionsBenchmark.concurrentLinkedQueue thrpt 5 5935777.516 ± 619664.615 ops/s
SynchronizedCollectionsBenchmark.synchronizedQueue thrpt 5 12134033.786 ± 3262089.933 ops/s
SynchronizedCollectionsBenchmark.synchronizedStack thrpt 5 12727145.327 ± 2682451.900 ops/s

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store