mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-11 13:38:38 -05:00
ws deque: try to reduce false sharing
This commit is contained in:
parent
9e93ebd3bb
commit
08722691e8
1 changed files with 5 additions and 3 deletions
|
|
@ -35,7 +35,6 @@ end = struct
|
|||
| None -> assert false
|
||||
|
||||
let[@inline] set (self : 'a t) (i : int) (x : 'a) : unit =
|
||||
assert (i >= 0);
|
||||
Array.unsafe_set self.arr (i land ((1 lsl self.log_size) - 1)) (Some x)
|
||||
|
||||
let grow (self : _ t) ~bottom ~top : 'a t =
|
||||
|
|
@ -61,8 +60,11 @@ type 'a t = {
|
|||
}
|
||||
|
||||
let create () : _ t =
|
||||
let arr = CA.create ~log_size:4 () in
|
||||
{ top = A.make 0; top_cached = 0; bottom = A.make 0; arr = A.make arr }
|
||||
let top = A.make 0 in
|
||||
let arr = A.make @@ CA.create ~log_size:4 () in
|
||||
(* allocate far from top to avoid false sharing *)
|
||||
let bottom = A.make 0 in
|
||||
{ top; top_cached = 0; bottom; arr }
|
||||
|
||||
let[@inline] size (self : _ t) : int = max 0 (A.get self.bottom - A.get self.top)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue