RSS feed [root] /design /weblog /concurrency



title search:


Mon Sep 28 00:25:32 HKT 2015


(google search) (amazon search)
download zip of files only

Mon Jan 23 18:33:07 HKT 2017 From /weblog/design/concurrency


Stealing thread -

Intel Guide for Developing Multithreaded Applications -[..]or-developing-multithreaded-applications

Difference ways to stop a thread -[..]ept_url=/hpc-high-performance-computing/

Interesting, I am not sure if I agree, but chrome ( which use fork ) are really cool in performance:
There’s another problem with Unix programming in Ruby that I’ll just touch on briefly: Java people and Windows people. They’re going to tell you that fork(2) is bad because they don’t have it on their platform, or it sucks on their platform, or whatever, but it’s cool, you know, because they have native threads, and threads are like, way better anyways.

Fuck that.

Don’t ever let anyone tell you that fork(2) is bad. Thirty years from now, there will still be a fork(2) and a pipe(2) and a exec(2) and smart people will still be using them to solve hard problems reliably and predictably, just like they were thirty years ago.

MRI Ruby people need to accept, like Python (you have seen multiprocessing, yes?), that Unix processes are one of two techniques for achieving reliable concurrency and parallelism in server applications. Threads are out. You can use processes, or async/events, or both processes and async/events, but definitely not threads. Threads are out.

1x1 win M*N -

Best number of threads:
N = number of CPUs
U = target CPU utilization (0 <= U <= 1)
W/C = ration of wait time to cpu time (measured through profiling)

threads = N * U * (1 + W/C) -[..]ratio-of-java-threads-to-cpus-on-solaris

Another post about tuning thread pool -[..]ortance-of-tuning-your-thread-pools.html

Threads Basics -

The Dos and Don'ts of Multithreading -[..]-26-09-low-level-threading-table-of.html

(google search) (amazon search)

Tue Nov 15 10:49:25 HKT 2016 From /weblog/design/concurrency


How to write safer concurrency code -

reentrant and thread safe functions -[..]/31/reentrant-and-thread-safe-functions/

Libraries / toolkits for multicore process -[..]intableArticle.jhtml?articleID=212900103

Introduction -[..]QQSNDLRSKHSCJUNN2JVN?articleID=212903586[..]CQSNDLRSKHSCJUNN2JVN?articleID=213001517

Collections of links -[..]rallel-Or-Get-Left-Behind.html&Itemid=29

Briefing of difference modeling of threading system -[..]intableArticle.jhtml?articleID=215900465[..]inners-guide-to-multithreaded-libraries/[..]haloms_blog/2010/08/concurrency-101.html

Saving the Failwhale: The Art of Concurrency (Page last updated December 2012, Added 2012-12-26, Author Dhanji R. Prasanna, Publisher informit). Tips:

1) Contention is unavoidable - some resources are just slower, and you must wait for them. The secrets to good concurrency are 1) ensuring that these slower resources are rarely used, and 2) during such waiting periods, giving the faster tiers other work to do so that they continue to be utilized well.
2) Overuse of synchronization constructs such as locks and mutexes leads to systems that perform poorly under load.
3) ConcurrentHashMap is an efficient thread-safe map while HashMap is not thread-safe.
4) ConcurrentHashMap doesn't do away with locks, it still uses them but it uses more than the single global lock, so that threads gain some measure of concurrency. It uses separate locks for partitions, so that multiple threads writing to the map are likely to access different partitions, using separate locks and therefore process their data simultaneously. This technique is known as lock-striping. Efficient striping uses a number of locks proportional to the number of CPU cores in a system.
5) The asynchronous processing model smooths resource spikes by adding requests to a queue which is serviced by a pool of workers - spikes in requests make the queue grow rather than overloading the workers. (The ExecutorService is essentially a thread pool accompanied by a task queue.)

Discussion of using difference model for concurrency -[..]cks-application-architecture-pros-a.html

Concurrency vs Parallelism -[..]/2013/12/concurrency-vs-parallelism.html

Compare between Actors, CSP, Disruptor and raw Threads -[..]omparision-of-different-concurrency.html

Few coding tips that should be useful for most languages -[..]erformance-scalability-and-liveness.html[..]2015/09/java-concurrency-essentials.html

Service Design
Do one thing, do it well
No shared operational state
Bound your queues
Name custom thread pools and register an UncaughtExceptionHandler
Prefer immutable data objects over mutable state[..]-to-25-billion-notifications-during.html

(google search) (amazon search)

Wed Nov 02 16:13:31 HKT 2016 From /weblog/design/concurrency


10-ways-to-reduce-lock-contention-in-threaded-programs -[..]ce-lock-contention-in-threaded-programs/

Discussion about lock the form and prevent 2 user edit it in the same time and currupt the object, what is the possible drawback. -[..]-optimistic-locking-isnt-a-silver-bullet

futexes -[..]ds/browse_thread/thread/3c3608a779dc6731

Spinning -[..]ome/lock-free-algorithms/tricks/spinning

Locks for rarely changed data, sound like good suggestion -[..]pic/comp.programming.threads/dyrbRKsj4gw

Try to use non-blocking approach if possible -[..]1/locks-condition-variables-latency.html

Concurrency without lock, and even without correctness? -

Single write principle -[..].au/2011/09/single-writer-principle.html

Comparing difference kind of locks again -[..]11/stampedlocktryoptimisticread-and.html

10-ways-to-reduce-lock-contention-in-threaded-programs -[..]ce-lock-contention-in-threaded-programs/

(google search) (amazon search)

Wed Dec 31 19:11:17 HKT 2014 From /weblog/design/concurrency


Case study of a parallel slowdown, and the analysis of how to find it out -[..]2/avoiding-parallel-slowdown-in-jetty-9/

Discuss about the racing condition when multiple accessing java.util.HashMap -[..]au/2009/06/beautiful-race-condition.html

(google search) (amazon search)

Thu Jun 05 17:50:25 HKT 2014 From /weblog/design/concurrency


Fast synchronization between a single producer and single consumer -[..]eenASingleProducerAndSingleConsumer.aspx

Lock free queue idea. -[..]read/thread/82066179448783da?hl=en&pli=1

Use of Disruptor -

Use of Queue -[..]ble-presents-queue-er-message-queue.html

Discuss about the "Railway approach" of producer consumer queue -[..]ormance-Java-Inter-Thread-Communications[..]alternative-multi-producer-approach.html

Probably worth to consider replacing queue by actor -[..]implifying-trading-system-with-akka.html

(google search) (amazon search)

Sun May 15 02:11:54 HKT 2011 From /weblog/design/concurrency


Deadlock detector sample -

Deadlock in J2EE, explaining deadlock in various place, e.g. DB, VM, code,... -

A blog comment about database deadlock very detail -[..]2007/04/java-wish-list-2-retry-code.html

Technique to prevent deadlock: Automatic Lock Releases, Timeout, automatic detection -

(google search) (amazon search)

Tue Nov 13 16:06:21 HKT 2007 From /weblog/design/concurrency


A few example of writing non-blocking thread safe method, mostly using the concept of Idempotency[..]readerwriter-in-java-in-nonblocking.html[..]works/java/library/j-jtp04186/index.html

Not exactly related, some project about non-blocking IO

(google search) (amazon search)

Thu Sep 13 02:01:25 HKT 2007 From /weblog/design/concurrency

Transactional memory

Someone say the basic idea behind transactional memory is that memory is shared by all the threads in a read-only manner. Threads modify data by "committing" objects to shared memory. If a thread commits on top of a dirty object then it has to "rollback" and retry.[..]007/2007-08-13_transactional_memory.html

(google search) (amazon search)