3 ms·
Even lots of low latency standard Java is tending towards single threaded non blocking models without synchronisation. The costs of synchronised blocks is high
by benjaminwootton 13y ago
Even lots of low latency standard Java is tending towards single threaded non blocking models without synchronisation.
The costs of synchronised blocks is high on the JVM. They defer to the operating system for thread scheduling, they enforce a memory barrier meaning all data is flushed out to RAM rather than CPU caches, and multithreaded code dirties CPU caches, reducing performance.
More server side code should be single threaded than not in my opinion.
- kasey_junk 13y agoYou can write lock free algorithms that are not single threaded as well. If you design your system so that only 1 thread is doing the writing of data you avoid a lot of the negative performance implications you mention. That said, I completely agree. Many times making a single threaded system faster will improve performance vs making it parallel.