Skip to content

Commit

Permalink
Rename ro_sync in sync
Browse files Browse the repository at this point in the history
  • Loading branch information
icristescu committed Jul 2, 2020
1 parent 10a7b26 commit 08fd4bf
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 63 deletions.
14 changes: 7 additions & 7 deletions src/index.ml
Original file line number Diff line number Diff line change
Expand Up @@ -736,15 +736,15 @@ struct
let close = close' ~hook:(fun _ -> ())
let ro_sync' ?hook t =
Stats.incr_nb_ro_sync ();
let sync' ?hook t =
Stats.incr_nb_sync ();
let t = check_open t in
Log.info (fun l -> l "[%s] ro_sync" (Filename.basename t.root));
Log.info (fun l -> l "[%s] sync" (Filename.basename t.root));
if t.config.readonly then sync_log ?hook t else raise RW_not_allowed
let ro_sync t = ro_sync' t
let sync t = sync' t
let ro_sync_with_timer t = Stats.ro_sync_with_timer (fun () -> ro_sync t)
let sync_with_timer t = Stats.sync_with_timer (fun () -> sync t)
end
module Make = Make_private
Expand Down Expand Up @@ -776,9 +776,9 @@ module Private = struct
val replace_with_timer : ?sampling_interval:int -> t -> key -> value -> unit
val ro_sync_with_timer : t -> unit
val sync_with_timer : t -> unit
val ro_sync' : ?hook:[ `Before_offset_read ] Hook.t -> t -> unit
val sync' : ?hook:[ `Before_offset_read ] Hook.t -> t -> unit
end
module Make = Make_private
Expand Down
16 changes: 8 additions & 8 deletions src/index_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ module type S = sig
val close : t -> unit
(** Closes all resources used by [t]. *)

val ro_sync : t -> unit
(** [ro_sync t] syncs a read-only index with the files on disk. Raises
val sync : t -> unit
(** [sync t] syncs a read-only index with the files on disk. Raises
[RW_not_allowed] if called by a read-write index. *)
end

Expand Down Expand Up @@ -220,8 +220,8 @@ module type Index = sig
index. *)

exception RW_not_allowed
(** The exception is raised when a ro_sync operation is attempted on a
read-write index. *)
(** The exception is raised when a sync operation is attempted on a read-write
index. *)

exception Closed
(** The exception raised when any operation is attempted on a closed index,
Expand Down Expand Up @@ -279,11 +279,11 @@ module type Index = sig
[sampling_interval]. If [sampling_interval] is not set, no operation
is timed. *)

val ro_sync_with_timer : t -> unit
(** Time ro_sync operations. *)
val sync_with_timer : t -> unit
(** Time sync operations. *)

val ro_sync' : ?hook:[ `Before_offset_read ] Hook.t -> t -> unit
(** [`Before_offset_read]: after reading the generation number and the
val sync' : ?hook:[ `Before_offset_read ] Hook.t -> t -> unit
(** [`Before_offset_read]: before reading the generation number and the
offset. *)
end

Expand Down
18 changes: 9 additions & 9 deletions src/stats.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type t = {
mutable nb_merge : int;
mutable nb_replace : int;
mutable replace_times : float list;
mutable nb_ro_sync : int;
mutable ro_sync_times : float list;
mutable nb_sync : int;
mutable sync_times : float list;
}

let fresh_stats () =
Expand All @@ -19,8 +19,8 @@ let fresh_stats () =
nb_merge = 0;
nb_replace = 0;
replace_times = [];
nb_ro_sync = 0;
ro_sync_times = [];
nb_sync = 0;
sync_times = [];
}

let stats = fresh_stats ()
Expand All @@ -33,8 +33,8 @@ let reset_stats () =
stats.nb_merge <- 0;
stats.nb_replace <- 0;
stats.replace_times <- [];
stats.nb_ro_sync <- 0;
stats.ro_sync_times <- []
stats.nb_sync <- 0;
stats.sync_times <- []

let get () = stats

Expand All @@ -50,7 +50,7 @@ let incr_nb_merge () = stats.nb_merge <- succ stats.nb_merge

let incr_nb_replace () = stats.nb_replace <- succ stats.nb_replace

let incr_nb_ro_sync () = stats.nb_ro_sync <- succ stats.nb_ro_sync
let incr_nb_sync () = stats.nb_sync <- succ stats.nb_sync

let add_read n =
incr_bytes_read n;
Expand All @@ -76,9 +76,9 @@ let end_replace ~sampling_interval =
replace_timer := Mtime_clock.counter ();
nb_replace := 0 )

let ro_sync_with_timer f =
let sync_with_timer f =
let timer = Mtime_clock.counter () in
f ();
let span = Mtime_clock.count timer in
let time = Mtime.Span.to_us span in
stats.ro_sync_times <- time :: stats.ro_sync_times
stats.sync_times <- time :: stats.sync_times
8 changes: 4 additions & 4 deletions src/stats.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type t = {
mutable nb_merge : int;
mutable nb_replace : int;
mutable replace_times : float list;
mutable nb_ro_sync : int;
mutable ro_sync_times : float list;
mutable nb_sync : int;
mutable sync_times : float list;
}
(** The type for stats for an index I.
Expand All @@ -33,10 +33,10 @@ val incr_nb_merge : unit -> unit

val incr_nb_replace : unit -> unit

val incr_nb_ro_sync : unit -> unit
val incr_nb_sync : unit -> unit

val start_replace : unit -> unit

val end_replace : sampling_interval:int -> unit

val ro_sync_with_timer : (unit -> unit) -> unit
val sync_with_timer : (unit -> unit) -> unit
40 changes: 20 additions & 20 deletions test/unix/force_merge.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ let readonly_and_merge () =
Index.replace w k1 v1;
Index.flush w;
let t1 = Index.force_merge w in
Index.ro_sync r1;
Index.ro_sync r2;
Index.ro_sync r3;
Index.sync r1;
Index.sync r2;
Index.sync r3;
test_one_entry r1 k1 v1;
test_one_entry r2 k1 v1;
test_one_entry r3 k1 v1;
Expand All @@ -139,9 +139,9 @@ let readonly_and_merge () =
let v2 = Value.v () in
Index.replace w k2 v2;
Index.flush w;
Index.ro_sync r1;
Index.ro_sync r2;
Index.ro_sync r3;
Index.sync r1;
Index.sync r2;
Index.sync r3;
test_one_entry r1 k1 v1;
let t2 = Index.force_merge w in
test_one_entry r2 k2 v2;
Expand All @@ -154,21 +154,21 @@ let readonly_and_merge () =
test_one_entry r1 k1 v1;
Index.replace w k2 v2;
Index.flush w;
Index.ro_sync r1;
Index.sync r1;
let t3 = Index.force_merge w in
test_one_entry r1 k1 v1;
Index.replace w k3 v3;
Index.flush w;
Index.ro_sync r3;
Index.sync r3;
let t4 = Index.force_merge w in
test_one_entry r3 k3 v3;

let k2 = Key.v () in
let v2 = Value.v () in
Index.replace w k2 v2;
Index.flush w;
Index.ro_sync r2;
Index.ro_sync r3;
Index.sync r2;
Index.sync r3;
test_one_entry w k2 v2;
let t5 = Index.force_merge w in
test_one_entry w k2 v2;
Expand All @@ -179,8 +179,8 @@ let readonly_and_merge () =
let v2 = Value.v () in
Index.replace w k2 v2;
Index.flush w;
Index.ro_sync r2;
Index.ro_sync r3;
Index.sync r2;
Index.sync r3;
test_one_entry r2 k1 v1;
let t6 = Index.force_merge w in
test_one_entry w k2 v2;
Expand Down Expand Up @@ -212,7 +212,7 @@ let write_after_merge () =
let hook = after (fun () -> Index.replace w k2 v2) in
let t = Index.force_merge ~hook w in
Index.await t |> check_completed;
Index.ro_sync r1;
Index.sync r1;
test_one_entry r1 k1 v1;
Alcotest.check_raises (Printf.sprintf "Absent value was found: %s." k2)
Not_found (fun () -> ignore_value (Index.find r1 k2))
Expand All @@ -232,7 +232,7 @@ let replace_while_merge () =
test_one_entry w k2 v2)
in
let t = Index.force_merge ~hook w in
Index.ro_sync r1;
Index.sync r1;
test_one_entry r1 k1 v1;
Index.await t |> check_completed

Expand Down Expand Up @@ -269,7 +269,7 @@ let find_in_async_generation_change () =
let f () =
Index.replace w k1 v1;
Index.flush w;
Index.ro_sync r1;
Index.sync r1;
test_one_entry r1 k1 v1
in
let t1 = Index.force_merge ~hook:(before f) w in
Expand All @@ -286,11 +286,11 @@ let find_in_async_same_generation () =
let f () =
Index.replace w k1 v1;
Index.flush w;
Index.ro_sync r1;
Index.sync r1;
test_one_entry r1 k1 v1;
Index.replace w k2 v2;
Index.flush w;
Index.ro_sync r1;
Index.sync r1;
test_one_entry r1 k2 v2
in
let t1 = Index.force_merge ~hook:(before f) w in
Expand All @@ -306,14 +306,14 @@ let sync_after_clear_log () =
let k1, v1 = (Key.v (), Value.v ()) in
Index.replace rw k1 v1;
Index.flush rw;
let hook = after_clear (fun () -> Index.ro_sync ro) in
let hook = after_clear (fun () -> Index.sync ro) in
let t = Index.force_merge ~hook rw in
Index.await t |> check_completed;
test_one_entry ro k1 v1;
let k2, v2 = (Key.v (), Value.v ()) in
Index.replace rw k2 v2;
Index.flush rw;
Index.ro_sync ro;
Index.sync ro;
let hook = after_clear (fun () -> test_one_entry ro k1 v1) in
let t = Index.force_merge ~hook rw in
Index.await t |> check_completed;
Expand All @@ -333,7 +333,7 @@ let merge_during_sync () =
let t = Index.force_merge rw in
Index.await t |> check_completed)
in
Index.ro_sync' ~hook ro;
Index.sync' ~hook ro;
test_one_entry ro k1 v1;
Index.close rw;
Index.close ro
Expand Down
Loading

0 comments on commit 08fd4bf

Please sign in to comment.