Skip to content

Commit 6773cf3

Browse files
balatclaude
andcommitted
irmin-lwt: expose Tree.inspect, counters, dump_counters, reset_counters, merge
These were missing from the [Tree] submodule of [module type S]: - [val merge : t Irmin.Merge.t]: the merge value used by Irmin tree combinators. - [type counters], [val counters], [val dump_counters], [val reset_counters]: the performance counters shared between all trees backed by the same set of internal caches. [counters] is kept abstract since it is a record (nominal typing) and the underlying [S.Tree.counters] is abstract from inside the functor body. - [val inspect]: a synchronous inspector returning a transparent variant describing the kind and internal state of a tree node ([`Map], [`Key], [`Value], [`Portable_dirty], [`Pruned]). [helpers/context.ml] in Octez calls [inspect] for debugging / introspection paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3e573c6 commit 6773cf3

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

src/irmin-lwt/irmin_lwt.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,19 @@ module type S = sig
597597
t ->
598598
'a ->
599599
'a Lwt.t
600+
601+
val merge : t Irmin.Merge.t
602+
603+
type counters
604+
605+
val counters : unit -> counters
606+
val dump_counters : unit Fmt.t
607+
val reset_counters : unit -> unit
608+
609+
val inspect :
610+
t ->
611+
[ `Contents
612+
| `Node of [ `Map | `Key | `Value | `Portable_dirty | `Pruned ] ]
600613
end
601614

602615
(** {1 Commits} *)
@@ -1134,6 +1147,15 @@ module Make (S : Irmin.Generic_key.S) = struct
11341147
run_eio (fun () ->
11351148
S.Tree.fold ?order ?force ?cache ?uniq ?pre ?post ?depth ?contents
11361149
?node ?tree t acc)
1150+
1151+
let merge = S.Tree.merge
1152+
1153+
type counters = S.Tree.counters
1154+
1155+
let counters = S.Tree.counters
1156+
let dump_counters = S.Tree.dump_counters
1157+
let reset_counters = S.Tree.reset_counters
1158+
let inspect = S.Tree.inspect
11371159
end
11381160

11391161
module Commit = struct

src/irmin-lwt/irmin_lwt.mli

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,25 @@ module type S = sig
616616
t ->
617617
'a ->
618618
'a Lwt.t
619+
620+
(** {2 Merge} *)
621+
622+
val merge : t Irmin.Merge.t
623+
624+
(** {2 Performance counters and inspection} *)
625+
626+
type counters
627+
628+
val counters : unit -> counters
629+
val dump_counters : unit Fmt.t
630+
val reset_counters : unit -> unit
631+
632+
val inspect :
633+
t ->
634+
[ `Contents
635+
| `Node of [ `Map | `Key | `Value | `Portable_dirty | `Pruned ] ]
636+
(** [inspect t] is similar to {!val-kind}, with extra state information
637+
returned for nodes. Pure: no I/O. *)
619638
end
620639

621640
(** {1 Commits} *)

0 commit comments

Comments
 (0)