Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file stats_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304(*
* Copyright (c) 2018-2022 Tarides <contact@tarides.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openImportmodulePack_store=structtypefield=|Appended_hashes|Appended_offsets|Staging(** Found in the store's write buffer. *)|Lru(** Found in the store's LRU of recent [find] results. *)|Pack_direct(** Decoded directly from the pack file (via a direct key). *)|Pack_indexed(** Binding recovered from the pack file after first checking the index
for its offset and length (via an indexed key). *)|Not_found(** Find returned [None]. *)[@@derivingirmin]typet={mutableappended_hashes:int;mutableappended_offsets:int;mutabletotal:int;mutablefrom_staging:int;mutablefrom_lru:int;mutablefrom_pack_direct:int;mutablefrom_pack_indexed:int;}[@@derivingirmin]endmoduleIndex=structmoduleS=Index.Statstypet=S.t={mutablebytes_read:int;mutablenb_reads:int;mutablebytes_written:int;mutablenb_writes:int;mutablenb_merge:int;mutablemerge_durations:floatlist;mutablenb_replace:int;mutablereplace_durations:floatlist;mutablenb_sync:int;mutabletime_sync:float;mutablelru_hits:int;mutablelru_misses:int;}[@@derivingirmin]endmoduleFile_manager=structtypefield=|Dict_flushes|Suffix_flushes|Index_flushes|Auto_dict|Auto_suffix|Auto_index|Flushtypet={mutabledict_flushes:int;mutablesuffix_flushes:int;mutableindex_flushes:int;mutableauto_dict:int;mutableauto_suffix:int;mutableauto_index:int;mutableflush:int;}[@@derivingirmin]endmoduleLatest_gc=structtyperusage={maxrss:int64;minflt:int64;majflt:int64;inblock:int64;oublock:int64;nvcsw:int64;nivcsw:int64;}[@@derivingirmin]typeocaml_gc={minor_words:float;promoted_words:float;major_words:float;minor_collections:int;major_collections:int;heap_words:int;compactions:int;top_heap_words:int;stack_size:int;}[@@derivingirmin]typeduration={wall:float;sys:float;user:float}[@@derivingirmin](** Timings in seconds *)typestep={duration:duration;rusage:rusage;ocaml_gc:ocaml_gc;index:Index.t;pack_store:Pack_store.t;inode:Irmin_pack.Stats.Inode.t;}[@@derivingirmin](** Stats gathered for one worker step *)typeworker={initial_maxrss:int64;initial_heap_words:int;initial_top_heap_words:int;initial_stack_size:int;steps:(string*step)list;files:(string*int63)list;objects_traversed:int63;suffix_transfers:int63list;}[@@derivingirmin](** Stats produced by the worker. They are meant to be transmited to the
parent process through the gc result JSON file.
[steps] is the list of all step names associated with the timing of these
steps plus stats recorded at the end of the step. An association lists is
used here instead of types because in the future the exact list of tasks
may change and we don't want the rigidity of types, especially because
these informations will end up appearing in a file format.
Since the worker lives in a fork, [rusage] and [ocaml_gc] contain stats
that are impacted by what happened in the main process, prior to the fork.
The [init_*] fields reflect this.
The total wall time of the worker is the sum of all [wall] fields in
[steps].
[files] contains the size of files created by the GC. And association list
is used instead of plain types for the same reason as [steps]/
[suffix_transfers] contains an int for each transfer loop to the new
suffix. That integer corresponds to the number of bytes copied during that
loop. The sum of these integers is equal to the "suffix" step in [files]. *)typestats={generation:int;commit_offset:int63;before_suffix_start_offset:int63;before_suffix_end_offset:int63;after_suffix_start_offset:int63;after_suffix_end_offset:int63;steps:(string*duration)list;worker:worker;}[@@derivingirmin](** All the stats for a single successful GC run.
[commit_offset] is the offset of the commit provided by the irmin user.
The [before_*] (and [after_*]) offsets track the state of the suffix
before (and after) the GC.
[steps] has a similar meaning as [steps] in [worker] but for the main
process. *)typet=statsoption[@@derivingirmin](** [Latest_gc.t] is an [option] type because before the first gc end, there
are no gc stats to expose. *)endmoduletypeSigs=sigmodulePack_store:sigincludemoduletypeofPack_storewithtypet=Pack_store.ttypestatvalcache_misses:t->intvalexport:stat->tendmoduleIndex:sigincludemoduletypeofIndexwithtypet=Index.ttypestatvalexport:stat->tendmoduleFile_manager:sigincludemoduletypeofFile_managerwithtypet=File_manager.ttypestatvalexport:stat->tendmoduleLatest_gc:sigincludemoduletypeofLatest_gcwithtypeduration=Latest_gc.durationwithtypeocaml_gc=Latest_gc.ocaml_gcwithtyperusage=Latest_gc.rusagewithtypestep=Latest_gc.stepwithtypeworker=Latest_gc.workerwithtypestats=Latest_gc.statswithtypet=Latest_gc.ttypestatvalexport:stat->tvalnew_suffix_end_offset_before_finalise:worker->int63valfinalise_duration:stats->float(** Time taken by the GC finalisation in seconds. It includes the time it
took to wait for the worker to finish in case of [~wait:true]. *)valtotal_duration:stats->float(** Total wall duration of the GC in seconds, from the call to GC and to the
end of finalise. This duration contains the time it takes for the user
to trigger a finalise while the worker is over. *)valfinalise_suffix_transfer:stats->int63(** [finalise_suffix_transfer stats] is the number of bytes appended to the
new suffix by the finalise step of the GC. Before this, the worker
already appended bytes to the new suffix, this is reported in
[worker.suffix_transfers]. *)endtypet={pack_store:Pack_store.stat;index:Index.stat;file_manager:File_manager.stat;latest_gc:Latest_gc.stat;}(** Record type for all statistics that will be collected. There is a single
instance (which we refer to as "the instance" below) which is returned by
{!get}. *)valreset_stats:unit->unit(** [reset_stats ()] will call the relevant [clear] function on each field of
the instance. This typically resets the fields (e.g. to 0 for an int
field). *)valget:unit->t(** [get ()] returns the instance of {!t} that stores the satistics. If
{!report_pack_store} or {!report_index} is not called before, the content
will be filled with default value, decided at create time (most the time,
[0]). *)valreport_pack_store:field:Pack_store.field->unit(** [report_pack_store ~field] increments the [field] value in the
[pack_store] stats. It also increments the [total] field in
{!Pack_store.type-t} when the field is related to [finds]. *)valreport_index:unit->unit(** [report_index ()] fills the [stats] with value from the {!Index.Stats}
module. This essentially copies the "current" values from {!Index.Stats}
to the [get()] instance [index] field. *)valincr_appended_hashes:unit->unit(** [incr_appended_hashes ()] increments the field [appended_hashes] for
[pack_store] in the instance. *)valincr_appended_offsets:unit->unit(** [incr_appended_offsets] increments the field [appended_offsets] for
[pack_store] in the instance. *)typecache_stats={cache_misses:float}typeoffset_stats={offset_ratio:float;offset_significance:int}(** [offset_ratio]: [appended_offsets / (appended_offsets + appended_hashes)];
[offset_significance]: [appended_offsets + appended_hashes] *)valget_cache_stats:unit->cache_stats(** [get_cache_stats()] uses the instance [pack_store] field to compute cache
misses. *)valget_offset_stats:unit->offset_stats(** [get_offset_stats()] uses the instance [pack_store] field to compute
offset stats. *)valincr_fm_field:File_manager.field->unit(** [incr_fm_field field] increments the chosen stats field for the
{!File_manager} *)valreport_latest_gc:Latest_gc.stats->unit(** [report_latest_gc gc_stats] sets [(get ()).latest_gc] to the stats of the
latest successful GC. *)end