IP Library › Granted Patent US 12,254,900
Granted Patent B2
US 12,254,900 · App. 18/617,546 · Granted Mar 18, 2025

Reader bias based locking technique enabling high read concurrency for read-mostly workloads

Inventors: David Dice (Foxboro, MA); Alex Kogan (Needham, MA)
Assignee: Oracle International Corporation
G11B20/10268G06F9/526G06F16/2343G06F16/2365G11B20/105G11C16/26
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,254,900
App. No.
18/617,546
Granted
Mar 18, 2025
Kind
B2
Abstract

A data object has a lock and a condition indicator associated with it. Based at least partly on detecting a first setting of the condition indicator, a reader stores an indication that the reader has obtained read access to the data object in an element of a readers structure and reads the data object without acquiring the lock. A writer detects the first setting and replaces it with a second setting, indicating that the lock is to be acquired by readers before reading the data object. Prior to performing a write on the data object, the writer verifies that one or more elements of the readers structure have been cleared.

Claims (52)

1. A computer-implemented method, comprising:

determining, by a first writer of a plurality of data accessors which includes at least the first writer and at least one reader, that a flag associated with a data object on which a write operation is to be performed by the first writer is set to a first value, wherein the first value indicates that a read operation on the data object can be performed without acquiring a lock associated with the data object;

computing, by the first writer based on one or more metrics associated with the write operation, a duration during which readers are to be prevented from performing read operations on the data object without acquiring the lock; and

causing, by the first writer, the flag to be set to a second value for at least the duration, wherein the second value indicates that the lock has to be acquired to perform a read operation on the data object.

2. The computer-implemented method as recited in claim 1 , wherein the one or more metrics includes a time for which the first writer has to wait for one or more readers to complete in-progress read operations on the data object before the first writer can initiate the write operation.

3. The computer-implemented method as recited in claim 1 , wherein the one or more metrics includes a time taken by the writer to examine a readers data structure which includes entries representing in-progress read operations on at least the data object.

4. The computer-implemented method as recited in claim 1 , wherein said causing, by the first writer, the flag to be set to the second value for at least the second duration comprises:

setting a timeout associated with the second value, such that readers are prevented from re-setting the flag to the first value until the timeout expires.

5. The computer-implemented method as recited in claim 1 , further comprising:

determining, by a first reader of the plurality of data accessors, that the flag is set to the second value;

acquiring, by the first reader, in accordance with the second value, the lock associated with the data object; and

subsequent to verifying, by the first reader, that the first reader is permitted to re-set the flag, re-setting the flag to the first value by the first reader.

6. The computer-implemented method as recited in claim 1 , further comprising:

acquiring, by the first writer, the lock on the data object prior to determining that the flag is set to the first value.

7. The computer-implemented method as recited in claim 1 , further comprising:

analyzing performance of read or write operations directed to at least the data object during an observation period; and

modifying, based at least in part on a result of said analyzing, a tuning parameter used to compute the duration during which readers are to be prevented from performing read operations on the data object without acquiring the lock.

8. A system, comprising:

one or more computing devices;

wherein the one or more computing devices include instructions that upon execution on or across the one or more computing devices:

determine, by a first writer of a plurality of data accessors which includes at least the first writer and at least one reader, that a flag associated with a data object on which a write operation is to be performed by the first writer is set to a first value, wherein the first value indicates that a read operation on the data object can be performed without acquiring a lock associated with the data object;

compute, by the first writer based on one or more metrics associated with the write operation, a duration during which readers are to be prevented from performing read operations on the data object without acquiring the lock; and

cause, by the first writer, the flag to be set to a second value for at least the duration, wherein the second value indicates that the lock has to be acquired to perform a read operation on the data object.

9. The system as recited in claim 8 , wherein the one or more metrics includes a time for which the first writer has to wait for one or more readers to complete in-progress read operations on the data object before the first writer can initiate the write operation.

10. The system as recited in claim 8 , wherein the one or more metrics includes a time taken by the writer to examine a readers data structure which includes entries representing in-progress read operations on at least the data object.

11. The system as recited in claim 8 , wherein to cause, by the first writer, the flag to be set to the second value for at least the second duration, the one or more computing devices include further instructions that upon execution on or across the one or more computing devices:

set a timeout associated with the second value, such that readers are prevented from re-setting the flag to the first value until the timeout expires.

12. The system as recited in claim 8 , wherein the one or more computing devices include further instructions that upon execution on or across the one or more computing devices:

determine, by a first reader of the plurality of data accessors, that the flag is set to the second value;

acquire, by the first reader, in accordance with the second value, the lock associated with the data object; and

subsequent to verifying, by the first reader, that the first reader is permitted to re-set the flag, re-set the flag to the first value by the first reader.

13. The system as recited in claim 8 , wherein the one or more computing devices include further instructions that upon execution on or across the one or more computing devices:

acquire, by the first writer, the lock on the data object prior to determining that the flag is set to the first value.

14. The system as recited in claim 8 , wherein the one or more computing devices include further instructions that upon execution on or across the one or more computing devices:

analyze performance of read or write operations directed to at least the data object during an observation period; and

modify, based at least in part on a result of analysis of the performance, a tuning parameter used to compute the duration during which readers are to be prevented from performing read operations on the data object without acquiring the lock.

15. A computer-implemented method, comprising:

obtaining, by one or more readers of a plurality of data accessors, read access to a first data object without acquiring a first lock on the first data object;

determining, by a writer of the plurality of data accessors, whose write is directed to the first data object, that the write is to be deferred until the one or more readers have completed respective read operations on the first data object; and

causing, by the writer, based at least in part on said determining, another reader of the plurality of data accessors to acquire the first lock to obtain read access to the first data object.

16. The computer-implemented method as recited in claim 15 , further comprising:

determining, by a first reader of the one or more readers prior to obtaining read access to the first data object, based at least in part on a first value of a flag associated with the first data object, that read access to the first data object can be obtained without acquiring the first lock; and

wherein said causing, by the writer, the other reader to acquire the first lock comprises:

setting, by the first writer, the flag to a second value.

17. The computer-implemented method as recited in claim 16 , further comprising:

re-setting the flag to the first value by the other reader after the other reader has acquired the first lock to obtain read access to the first data object.

18. The computer-implemented method as recited in claim 15 , further comprising:

setting, by the writer, a timeout such that prior to expiration of the timeout, readers are required to acquire the first lock to obtain read access to the first data object.

19. The computer-implemented method as recited in claim 18 , further comprising:

computing, by the writer, the timeout based on one or more metrics, including a metric indicating a period for which the write is deferred.

20. The computer-implemented method as recited in claim 15 , wherein said determining, by the writer of the plurality of data accessors that the write is to be deferred comprises:

examining, by the writer, contents of a data structure which contains one or more entries representing in-progress read operations on the first data object, wherein individual ones of the entries are generated by respective readers.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 28, 2024
From: DICE, DAVID; KOGAN, ALEX
To: ORACLE INTERNATIONAL CORPORATION
Reel/Frame 066931/0564 →
Continuity (7)
Continuation 18174520 · Feb 24, 2023
Continuation 17507714 · Oct 21, 2021
Continuation 17020655 · Sep 14, 2020
Continuation 16739851 · Jan 10, 2020
Continuation 16290431 · Mar 1, 2019
Provisional Application 62734197 · Sep 20, 2018
Related Publication 20240265945A1 · Aug 8, 2024
References Cited (57)
US 7934062B2 · McKenney et al. · 2011 [cited by applicant]
US 8332374B2 · Lev · 2012 [cited by examiner]
US 8799591B2 · Larson · 2014 [cited by applicant]
US 9329895B2 · Steinmacher-Burow · 2016 [cited by applicant]
US 9824018B2 · Joshi et al. · 2017 [cited by applicant]
US 9910893B2 · Li · 2018 [cited by applicant]
US 10346220B2 · Liu · 2019 [cited by applicant]
US 10535368B1 · Dice · 2020 [cited by applicant]
US 10811049B2 · Dice et al. · 2020 [cited by applicant]
US 11056145B2 · Kogan et al. · 2021 [cited by applicant]
US 11170816B2 · Dice et al. · 2021 [cited by applicant]
US 11594252B2 · Dice et al. · 2023 [cited by applicant]
US 11972777B2 · Dice et al. · 2024 [cited by applicant]
US 20070165319A1 · Fisher · 2007 [cited by applicant]
US 20130151466A1 · Skaria · 2013 [cited by applicant]
US 20150286586A1 · Yadav · 2015 [cited by applicant]
US 20170017532A1 · Falco · 2017 [cited by applicant]
US 20170308565A1 · Broll · 2017 [cited by applicant]
US 20200411049A1 · Dice et al. · 2020 [cited by applicant]
US 20210287716A1 · Kogan et al. · 2021 [cited by applicant]
US 20230206953A1 · Dice et al. · 2023 [cited by applicant]
David Dice, “Biased Locking in HotSpot”, Aug. 18, 2006, Retrieved from https://blogs.oracle.com/dave/biased-locking-in-hotspot, pp. 1-8. [cited by applicant]
Bjorn B. Brandenburg, et al., “Spin-Based Reader-Writer Synchronization for Multiprocessor Real-Time Systems”, In Real-Time Systems Journal, Sep. 2010, pp. 1-61. [cited by applicant]
Irina Calciu, et al., “NUMA-Aware Reader-Writer Locks”, ACM, PPoPP'13, Feb. 23-27, 2013, pp. 157-166. [cited by applicant]
Jonathan Corbert, “Big reader locks”, Retrieved from https://lwn.net/Articles/378911, Mar. 16, 2010, pp. 1-2. [cited by applicant]
Luke Dalessandro, et al., “Hybrid NOrec: A Case Study in the Effectiveness of Best Effort Hardware Transactional Memory”, ACM, ASPLOS'11, Mar. 5-11, 2011, pp. 39-51. [cited by applicant]
Peter Damron, et al., “Hybrid Transactional Memory”, In Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS), 2006, pp. 336-346. [cited by applicant]
Dave Dice, et al., “Refined Transactional Lock Elision”, In Proceedings of the 21st ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPOPP), 2016, pp. 1-12. [cited by applicant]
Yossi Lev, et al., “Scalable Reader-Writer Locks”, ACM, SPAA'09, Aug. 11-13, 2009, pp. 1-10. [cited by applicant]
Ran Liu, et al, “Scalable Read-mostly Synchronization Using Passive Reader-Writer Locks”, In Proceedings of the USENIX Annual Technical Conference (ATC), 2014, pp. 219-230. [cited by applicant]
Nick Piggin, “kernel: introduce brlock”, Retrieved from https://lwn.net/Articles/378781, Mar. 16, 2010, pp. 1-3. [cited by applicant]
“Distributed Cache-Line Counter Scalable RW-Lock”, Retrieved from http://concurrencyfreaks.blogspot.com/2013/09/distributed-cache-line-counter-scalable.html, Sep. 1, 2013, pp. 1-6. [cited by applicant]
Yehuda Afek, et al., “Cache Index-Aware Memory Allocation”, ACM, ISMM'11, Jun. 2011, pp. 1-10. [cited by applicant]
Jonathan Corbert, “Driver porting: mutual exclusion with seqlocks”, Retrieved from https://lwn.net/Articles/378911, 2010, pp. 1-2. [cited by applicant]
Mathieu Desnoyers, et al., “User-Level Implementations of Read-Copy Update”, IEEE Transactions on Parallel and Distributed Systems, 2009, pp. 1-14. [cited by applicant]
Dave Dice et al, “Lightweight Contention Management for Efficient Compare-and-Swap Operations”, dated May 24, 2013, pp. 1-25. [cited by applicant]
Dave Dice et al, “Scalable Statistics Counters”, Dated Jun. 23-25, 2013, pp. 1-10. [cited by applicant]
Dave Dice et al, “Early Experience with a commercial Hardware Transactional Memory Implementation”, dated Oct. 2009, pp. 1-60. [cited by applicant]
David Dice, et al., “Lock Cohorting: A General Technique for Designing NUMA Locks”, ACM, Transactions on Parallel Computing, vol. 1, No. 2, Article 13, Jan. 2015, pp. 13:1-13:42. [cited by applicant]
David Dice, “Quickly reacquirable locks”, Retrieved from https://patents.google.com/patent/US7814488, 2002, pp. 1. [cited by applicant]
Pascal Felber, et al., “Hardware Read-Write Lock Elision”, EuroSys'16, Apr. 2016, pp. 1-15. [cited by applicant]
Wilson C. Hsieh, et al., “Scalable Reader-Writer Locks for Parallel Systems”, In Proceedings Sixth International Parallel Processing Symposium, 1992, pp. 1-19. [cited by applicant]
Andi Kleen, “Lock elision in the GNU C library”, Retrieved from https://lwn.net/Articles/534758, Jan. 30, 2013, pp. 1-7. [cited by applicant]
Christoph Lameter, “Effective Synchronization on Linux/NUMA Systems”, Gelato Conference 2005, pp. 1-23. [cited by applicant]
George Marsaglia, “Xorshift RNGs”, Journal of Statistical Software Articles, 2003, Retrieved from https://doi.org/10.18637/jss.v008.i14, pp. 1-6. [cited by applicant]
John M. Mello-Crummey, et al., “Scalable Reader-Writer Synchronization for Shared-Memory Multiprocessors”, In Proceedings of the Third ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPOPP '91)… [cited by applicant]
Oracle, “Class StampedLock”, Retrieved from https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/StampedLock.html, 2012, pp. 1-13. [cited by applicant]
Filip Pizlo, et al., “Fine-grained Adaptive Biased Locking”, ACM, PPPJ'11, Aug. 2011, pp. 1-11. [cited by applicant]
Ravi Rajwar, et al., “Speculative Lock Elision: Enabling Highly Concurrent Multithreaded Execution”, In Proceedings of the 34th Annual ACM/IEEE International Symposium on Microarchitecture (MICRO 34), IEEE Computer Soci… [cited by applicant]
“A persistent key-value store for fast storage environments”, Retrieved from www.rocksdb.org, 2018, pp. 1. [cited by applicant]
Kenneth Russell, et al., “Eliminating Synchronization-Related Atomic Operations with Biased Locking and Bulk Rebiasing”, ACM, OOPSLA'06, Copyright Sun Microsystems, Inc., Oct. 2006, pp. 1-9. [cited by applicant]
Jun Shirako, et al, “Design, Verification and Applications of a New Read-Write Lock Algorithm”, ACM, SPAA'12, Jun. 25-27, 2012, pp. 1-10. [cited by applicant]
Nalini Vasedevan, et al., “Simple and Fast Biased Locks”, ACM, PACT'10, Sep. 11-15, 2010, pp. 1-9. [cited by applicant]
D. Vyukov, “Distributed Reader-Writer Mutex”, Retrieved from http://www.1024cores.ent/home/lock-free-algorithms/reader-writer-mutex, 2011, pp. 1-7. [cited by applicant]
Wikipedia, “Loss aversion”, Retrieved from https://en.wikipeida.org/wiki/Loss_aversion on Jul. 25, 2019, pp. 1-12. [cited by applicant]
Wikipedia, “Ski rental problem”, Retrieved from https://en.wikipedia.org/w/index.php?title=Ski_rental_problem&oldid=. . . on Jul. 25, 2019, pp. 1-4. [cited by applicant]
Wikipedia, “Birthday problem”, Retrieved from https://en.wikipedia.org/w/index.php?title=Birthday_problem&oldid=85 . . . on Jul. 25, 2019, pp. 1-10. [cited by applicant]