Lock Reservation: Java Locks Can Mostly Do Without Atomic Operations Kawachiya, Koseki, - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Lock Reservation: Java Locks Can Mostly Do Without Atomic Operations Kawachiya, Koseki,

Description:

Bit used for to represent lock reservation status and named LRV. Lock Reservation ... When LRV is set, lockword in reserve mode and lockword structure defined by the ... – PowerPoint PPT presentation

Number of Views:267
Avg rating:3.0/5.0
Slides: 15
Provided by: ccGa
Category:

less

Transcript and Presenter's Notes

Title: Lock Reservation: Java Locks Can Mostly Do Without Atomic Operations Kawachiya, Koseki,


1
Lock Reservation Java Locks Can Mostly Do
Without Atomic OperationsKawachiya, Koseki,
OnoderaIBM Research, Tokyo Research Lab,
JapanOOPSLA 2002
  • Jon Steelman
  • cs8803g
  • 26 November 2002

2
What is paper seeking to accomplish?
  • Increase in threaded performance
  • Why important?
  • Built-in support for multi-threaded programming
  • Java programs perform many lock operations
  • Atomic operations are very expensive

3
What is being exploited?
  • Thread locality
  • How is thread locality being exploited?
  • Novel algorithm called lock reservation

4
Thread Locality- What is it?
  • Sequence of threads in temporal order that
    acquire the lock.
  • Dominant locker long repetition of a specific
    thread

5
Exploitable Thread Locality of Java Locks
Even for multi-threaded programs, more than 75
of lock operations were performed by the initial
lockers in first repetition.
6
Lock Reservation
  • Exploits Thread Locality and reserves locks for
    threads
  • Algorithm that can built on any existing locking
    algorithm that uses a lockword and allows use of
    one bit in the lockword, q.v. the fast Tasuki
    lock used in IBMs jdk 1.3.1
  • Bit used for to represent lock reservation status
    and named LRV

7
Lock Reservation
  • If objects lock reserved for thread, thread
    acquires lock with a few instructions and no
    atomic operations.
  • If lock reserved for another thread, reservation
    cancelled and falls back to conventional locking
    algorithm
  • If objects lock not reserved, system uses the
    conventional locking algorithm
  • When LRV is set, lockword in reserve mode and
    lockword structure defined by the lock
    reservation algorithm. Otherwise, lockword is in
    base mode.

8
Lockword Structure
LRV bit
Thread ID
Recursion Cnt
1
(defined by base locking algorithm)
0
Lockword semantics in reserve mode
A
0
1
Reserved for Thread A, but not held
A
gt0
1
Reserved for and held by Thread A
0
0
1
Reserved anonymously
9
Lock State Transitions
10
Notes on State
  • Owner thread can read-modify-write the lockword
    without atomic operations
  • Once reservation is cancelled, lockword will
    never be reserved again
  • Cancellation is most expensive operation but
    ratio to lock operations is less than 0.05 in
    actual lock-intensive programs

11
Performance Improvements
12
Lock Statistics
13
Observations
  • Significantly improves performance if reservation
    succeeds while maintaining comparable performance
    if reservation fails
  • Since lock reservation is a runtime technique, it
    is complementary to compiler optimizations like
    escape analysis and recursive lock elimination

14
Future Extensions
  • Lowering cost of cancellations
  • Avoiding cancellations, for example, by starting
    in base mode and avoiding reserve mode
  • Dynamic profiling
  • Static analysis
  • When cancellation cost lowered, pursuing an
    algorithm enhancement allowing repeated lock
    reservations on an object
Write a Comment
User Comments (0)
About PowerShow.com