Skip to content

Commit

Permalink
CP-51209: add hooks lock_acquired/released for bpftrace
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Granado <[email protected]>
  • Loading branch information
mg12 authored and edwintorok committed Nov 13, 2024
1 parent cbdc58f commit 44767bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ocaml/database/db_lock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ module ReentrantLock : REENTRANT_LOCK = struct

let current_tid () = Thread.(self () |> id)

let [@inline never][@specialize never] lock_acquired () = ()

let [@inline never][@specialize never] lock_released () = ()

let lock l =
let me = current_tid () in
match Atomic.get l.holder with
Expand All @@ -91,6 +95,7 @@ module ReentrantLock : REENTRANT_LOCK = struct
while not (Atomic.compare_and_set l.holder None intended) do
Condition.wait l.condition l.lock
done ;
lock_acquired ();
let stats = l.statistics in
let delta = Clock.Timer.span_to_s (Mtime_clock.count counter) in
stats.total_time <- stats.total_time +. delta ;
Expand All @@ -109,7 +114,8 @@ module ReentrantLock : REENTRANT_LOCK = struct
let () = Atomic.set l.holder None in
Mutex.lock l.lock ;
Condition.signal l.condition ;
Mutex.unlock l.lock
Mutex.unlock l.lock;
lock_released ();
)
| _ ->
failwith
Expand Down

0 comments on commit 44767bb

Please sign in to comment.