package memtrace_viewer

  1. Overview
  2. Docs
Interactive memory profiler based on Memtrace

Install

Dune Dependency

Authors

Maintainers

Sources

memtrace_viewer-v0.16.0.tar.gz
sha256=bb50fc48fef748dffe7ff1e151021b1361500c432a8c2991065fd31fd474f817

doc/src/memtrace_viewer.common/fragment_trie_intf.ml.html

Source file fragment_trie_intf.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
open! Core

module type Location = sig
  type t [@@deriving bin_io, sexp, equal]

  include Hashable.S with type t := t

  val dummy : t

  module Debug : sig
    type nonrec t = t [@@deriving sexp_of]
  end
end

module type Entry = sig
  type t [@@deriving bin_io, sexp]

  module Debug : sig
    type nonrec t = t [@@deriving sexp_of]
  end
end

module type Metadata = sig
  type t [@@deriving bin_io, sexp]
end

module type Suffix_tree = sig
  type location
  type entry

  module Node : sig
    module Id : sig
      type t

      include Hashable.S with type t := t
      include Sexpable.S with type t := t
    end

    type t

    val id : t -> Id.t
    val entry : t -> entry
    val incoming_edge : t -> location
    val suffix : t -> t option
    val children : t -> (location, t) List.Assoc.t
    val representative : t -> t

    module Debug : sig
      type nonrec t = t [@@deriving sexp_of]
    end
  end

  type t

  val root : t -> Node.t
end

module type Backtrace = sig
  module Location : Location

  (** A backtrace, represented from toplevel to allocation site **)
  type t = Location.t list [@@deriving sexp, bin_io, compare, hash]

  include Comparable.S with type t := t

  module Debug : sig
    type nonrec t = t [@@deriving sexp_of]
  end

  module Reversed : sig
    type backtrace := t

    (** A backtrace, represented from allocation site to toplevel *)
    type t [@@deriving sexp, bin_io, compare, hash]

    val of_forward : backtrace -> t
    val of_reversed_list : Location.t list -> t
    val elements : t -> Location.t list
    val nil : t
    val cons : Location.t -> t -> t
    val append : t -> t -> t
    val hd : t -> Location.t option
    val tl : t -> t option
    val head_and_tail : t -> (Location.t * t) option

    include Comparable.S with type t := t

    module Debug : sig
      type nonrec t = t [@@deriving sexp_of]
    end
  end

  val of_reversed : Reversed.t -> t
end

module type Fragment = sig
  module Location : Location
  module Entry : Entry
  module Backtrace : Backtrace with module Location := Location

  module Id : sig
    type t [@@deriving bin_io]

    include Hashable.S with type t := t
    include Sexpable.S with type t := t
    include Comparable.S with type t := t
  end

  type t

  val id : t -> Id.t
  val is_empty : t -> bool
  val is_singleton : t -> bool
  val same : t -> t -> bool
  val entry : t -> Entry.t
  val first : t -> orient:Orientation.t -> Location.t
  val backtrace : t -> Backtrace.t
  val backtrace_rev : t -> Backtrace.Reversed.t
  val retract : t -> orient:Orientation.t -> t option
  val retract_by : t -> orient:Orientation.t -> n:int -> t option
  val one_frame_extensions : t -> orient:Orientation.t -> (Location.t, t) List.Assoc.t
  val has_extensions : t -> orient:Orientation.t -> bool
  val extend : t -> orient:Orientation.t -> Location.t -> t option
  val extend_by_callers : t -> Backtrace.Reversed.t -> t option
  val extend_by_callees : t -> Backtrace.t -> t option
  val is_extension : t -> extension:t -> orient:Orientation.t -> bool
  val representative : t -> t
  val length : t -> int


  module Debug : sig
    type nonrec t = t [@@deriving sexp_of]
  end

  module Oriented : sig
    type fragment := t

    (** A fragment and an orientation. Can be thought of as a tree node --
        with its extensions as children and it's retraction as parent. *)
    type t

    val fragment : t -> fragment
    val orient : t -> Orientation.t
    val first : t -> Location.t
    val retract : t -> t option
    val retract_by : t -> n:int -> t option
    val one_frame_extensions : t -> (Location.t, t) List.Assoc.t
    val has_extensions : t -> bool
    val extend : t -> Location.t -> t option

    module Debug : sig
      type nonrec t = t [@@deriving sexp_of]
    end
  end

  val oriented : t -> orient:Orientation.t -> Oriented.t

  module Iterator : sig
    type fragment := t

    (** An iterator that iterates through the prefixes of a fragment
        from callers to callees. *)
    type t

    val next : t -> t option
    val prev : t -> t option
    val location : t -> Location.t
    val prefix : t -> fragment
    val suffix : t -> fragment

    module Trace : sig
      type t = private
        { prefix_trace : Backtrace.Reversed.t
        ; suffix_trace : Backtrace.t
        }
      [@@deriving sexp, bin_io, compare]

      include Comparable.S with type t := t
    end

    val trace : t -> Trace.t
  end

  val iterator_start : t -> Iterator.t option
  val iterator_end : t -> Iterator.t option
end

module type Trie = sig
  module Location : Location
  module Entry : Entry
  module Metadata : Metadata
  module Backtrace : Backtrace with module Location := Location

  module type Suffix_tree =
    Suffix_tree with type location := Location.t and type entry := Entry.t

  module Fragment :
    Fragment
    with module Location := Location
     and module Entry := Entry
     and module Backtrace := Backtrace

  type t [@@deriving sexp]

  val of_suffix_tree
    :  (module Suffix_tree with type t = 'a)
    -> 'a
    -> metadata:Metadata.t
    -> t

  val metadata : t -> Metadata.t
  val empty_fragment : t -> Fragment.t
  val find : t -> Backtrace.t -> Fragment.t option
  val find_rev : t -> Backtrace.Reversed.t -> Fragment.t option
  val find_singleton : t -> Location.t -> Fragment.t option
  val find_iterator : t -> Fragment.Iterator.Trace.t -> Fragment.Iterator.t option

  val deep_fold_callers
    :  t
    -> init:'a
    -> f:(backtrace:Backtrace.t -> fragment:Fragment.t -> 'a -> 'a)
    -> 'a

  val deep_fold_callees
    :  t
    -> init:'a
    -> f:(backtrace_rev:Backtrace.Reversed.t -> fragment:Fragment.t -> 'a -> 'a)
    -> 'a

  val fold_singletons
    :  t
    -> init:'a
    -> f:(location:Location.t -> fragment:Fragment.t -> 'a -> 'a)
    -> 'a

  module Serialized : sig
    type unserialized := t
    type t [@@deriving sexp, bin_io]

    val serialize : unserialized -> t
    val unserialize : t -> unserialized
  end

  module Debug : sig
    type nonrec t = t [@@deriving sexp_of]
  end
end

module type S = sig
  module Location : Location
  module Entry : Entry
  module Metadata : Metadata

  module type Suffix_tree =
    Suffix_tree with type location := Location.t and type entry := Entry.t

  module Backtrace : Backtrace with module Location := Location

  module Fragment :
    Fragment
    with module Location := Location
     and module Entry := Entry
     and module Backtrace := Backtrace

  module Trie :
    Trie
    with module Location := Location
     and module Entry := Entry
     and module Metadata := Metadata
     and module Backtrace := Backtrace
     and module Fragment := Fragment

  module For_testing : sig
    module Dumped : sig
      type t = Trie.t [@@deriving sexp_of]
    end
  end
end

module type Fragment_trie = sig
  module type Location = Location
  module type Entry = Entry
  module type Metadata = Metadata
  module type Backtrace = Backtrace
  module type Suffix_tree = Suffix_tree
  module type Fragment = Fragment
  module type Trie = Trie
  module type S = S

  module Make (Location : Location) (Entry : Entry) (Metadata : Metadata) :
    S
    with module Location := Location
     and module Entry := Entry
     and module Metadata := Metadata
end
OCaml

Innovation. Community. Security.