Profile-driven lock handling
First Claim
Patent Images
1. A computer-implemented method of processing program code configured to access a lock, the method comprising:
- profiling the program code to collect metadata associated with the lock for a particular runtime environment;
in a first thread attempting to access the lock being held by a second thread, accessing the metadata associated with the lock to determine an expected total wait time for the lock to be held;
tracking a how long the lock has already been held by the second thread while the lock is held by the second thread;
in the first thread, determining from the expected total wait time and how long the lock has already been held by the second thread an expected remaining wait time before the lock is released by the second thread; and
based upon the expected remaining wait time and using at least one hardware-implemented processor, selecting from among a plurality of lock access implementations to access the lock.
1 Assignment
0 Petitions
Accused Products
Abstract
An apparatus, program product and method utilize metadata collected for a lock in a computer program to determine an optimal lock acquisition strategy for the lock. The metadata is typically collected via profiling of the computer program to determine a wait characteristic for the lock in the particular runtime environment in which the computer program executes, and the metadata is used to select from among different lock access implementations to be used to attempt to acquire the lock, often enabling an optimum lock access implementation to be selected for a lock.
-
Citations
24 Claims
-
1. A computer-implemented method of processing program code configured to access a lock, the method comprising:
-
profiling the program code to collect metadata associated with the lock for a particular runtime environment; in a first thread attempting to access the lock being held by a second thread, accessing the metadata associated with the lock to determine an expected total wait time for the lock to be held; tracking a how long the lock has already been held by the second thread while the lock is held by the second thread; in the first thread, determining from the expected total wait time and how long the lock has already been held by the second thread an expected remaining wait time before the lock is released by the second thread; and based upon the expected remaining wait time and using at least one hardware-implemented processor, selecting from among a plurality of lock access implementations to access the lock. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
-
-
21. A computer-implemented method of processing program code configured to access a lock, the method comprising:
-
profiling the program code to collect metadata associated with the lock for a particular runtime environment; accessing the metadata associated with the lock to determine a wait characteristic for the lock; and using a register allocator executing on at least one hardware-implemented processor during compilation of a method that accesses the lock using an inline lock access implementation that, if unsuccessful, calls an external function access implementation to acquire the lock, selecting from among a plurality of register allocation strategies to be used in connection with accessing the lock, wherein selecting from among the plurality of register allocation strategies comprises selecting a first register allocation strategy to use during compilation of the method to minimize register spills upon determining from the metadata that lock contention is common for the lock, and selecting a second register allocation strategy to use during compilation of the method to maximize use of volatile registers upon determining from the metadata that lock contention is not common for the lock.
-
-
22. A computer-implemented method of processing program code configured to access a lock, the method comprising:
-
profiling the program code to collect metadata associated with the lock for a particular runtime environment; in a first thread, accessing the metadata associated with the lock when the lock is held by a second thread to determine an expected total wait time for the lock to be held by the second thread; tracking a how long the lock has already been held by the second thread while the lock is held by the second thread; in the first thread, determining from the expected total wait time and how long the lock has already been held by the second thread an expected remaining wait time before the lock is released by the second thread; and based upon the expected remaining wait time and using at least one hardware-implemented processor, selecting a lock access implementation for the first thread to access the lock, wherein selecting the lock access implementation includes selecting a wait parameter that controls how long to wait to change from using a first lock access implementation for the first thread to using a second lock access implementation for the first thread that has an access method type that differs from that of the first lock access implementation.
-
-
23. An apparatus, comprising:
-
a processor; and a program configured to execute on the processor to process program code configured to access a lock by profiling the program code to collect metadata associated with the lock for a particular runtime environment, in a first thread attempting to access the lock being held by a second thread, accessing the metadata associated with the lock to determine an expected total wait time for the lock to be held, tracking a how long the lock has already been held by the second thread while the lock is held by the second thread, in the first thread, determining from the expected total wait time and how long the lock has already been held by the second thread an expected remaining wait time before the lock is released by the second thread, and based upon the expected remaining wait time, selecting from among a plurality of lock access implementations to access the lock.
-
-
24. A program product, comprising:
-
a program configured to process program code configured to access a lock by profiling the program code to collect metadata associated with the lock for a particular runtime environment, in a first thread attempting to access the lock being held by a second thread, accessing the metadata associated with the lock to determine an expected total wait time for the lock to be held, tracking a how long the lock has already been held by the second thread while the lock is held by the second thread, in the first thread, determining from the expected total wait time and how long the lock has already been held by the second thread an expected remaining wait time before the lock is released by the second thread, and based upon the expected remaining wait time, selecting from among a plurality of lock access implementations to access the lock; and a computer readable recordable type medium bearing the program.
-
Specification