What is meant by “quick” contactless synchronization?

In the "Performance and Scalability" chapter of the JCIP book :

The synchronized mechanism is optimized for the non-contact case (unstable is always not allowed), and with this letter the operational cost of the “non-contact” “fast track” synchronization ranges is from 20 to 250 clock cycles for most systems.

What does the author mean as a result of contactless synchronization along the fast path?

+6
source share
3 answers

I am not familiar with the topic of the book, but in general, the “fast path” is a specific possible branch of the control flow that is much more efficient than others and therefore prefers, but cannot handle complex cases.

I assume the book talks about Java synchronized block / qualifier. In this case, the fast way, most likely the one where it is easy to detect that there are no other threads accessing the same data. What the book says is that the synchronized implementation has been optimized to have better performance when only one thread actually uses the object, as opposed to the case when multiple threads and synchronization actually mediate among them.

+7
source

There are two different concepts here.

  • Quick Access Code and Slow Path
  • Restless and inconsistent synchronization

Slow-path vs Fast-path code

This is another way to identify the machine binary manufacturer.

With HotSpot VM, the slow path code is the binary code created by the C ++ implementation, where the fast path code means the code created by the JIT compiler.

In general, the quick access code is much optimized. To fully understand the JIT compilers, wikipedia is a good place to start .

Restless and consistent synchronization

Java Synchronization Design ( Monitors ) have a ownership concept. When a thread tries to block (obtain ownership) on the monitor, it can be blocked (belongs to another thread) or unlocked.

Restless synchronization occurs in two different scenarios:

  • Unlocked Monitor (property out of order)
  • The monitor already belongs to the same stream.

Alleged synchronization, on the other hand, means that the thread will be blocked until the owner thread has disabled the monitor lock.

Answering the question

By means of quick access to incomplete synchronization, the author means that the fastest bytecode algorithm (quick way) in the cheapest scenario (contactless synchronization).

+14
source

The first step in acquiring a synchronized lock is a one-year recording (monitor owner field). If the lock is not in dispute, then that’s all that will happen.

If the lock is disputed, then there will be various context switches and other mechanisms that increase clock cycles.

+2
source

Source: https://habr.com/ru/post/952924/


All Articles