Skip to content

Commit bb366bf

Browse files
committed
Tweak to use 0th counter on set in Accumulator
This should slightly improve performance of `set` as the 0th counter should be at the root of the splay tree.
1 parent e308669 commit bb366bf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/kcas_data/accumulator.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ module Xt = struct
3636
let s = Xt.get ~xt (Array.unsafe_get a i) in
3737
if i = 0 then s else get ~xt a s (i - 1)
3838

39-
let set ~xt a n = add ~xt a (n - get ~xt a)
39+
let set ~xt a n =
40+
let delta = n - get ~xt a in
41+
if delta <> 0 then
42+
Xt.fetch_and_add ~xt (Array.unsafe_get a 0) delta |> ignore
4043
end
4144

4245
let add a n = if n <> 0 then Loc.fetch_and_add (get_self a) n |> ignore

0 commit comments

Comments
 (0)