Module Prime_cache_metric

Parameters and measuring functions for memory caches (prime.unstable).

type t
type check_state = private {
cs_cm : t;
cs_time : float;
cs_memory_pressure : float;
mutable cs_live_count : int;
mutable cs_dead_count : int;
}
val create : ?⁠period_sample_size:int -> current_time:(unit -> float) -> current_memory_pressure:(unit -> float) -> ?⁠report:(check_state -> unit) -> unit -> t

Creates specifications for how to measure whether objects are worth caching. The returned object can be used by Prime_cache and Prime_beacon.

parameter period_sample_size

The approximate number of accesses averaged over in the estimate of the expected period before the next access.

parameter current_time

The current time according to a clock which is considered relevant for computing the cost of using memory for caching.

parameter current_memory_pressure

The current cost of using one unit of memory as cache for one unit of time.

parameter report

This function is called after a collection with information about how it went.

Internal Functions

The remaining functions of this module are subject to change at any time. They and are not needed for using the predefined caches.

val access_init : t -> float
val access_step : t -> int -> float -> float
val check_start : t -> check_state
val check : check_state -> int -> float -> float -> bool
val check_stop : check_state -> unit