28 std::pair<iterator,bool> p=
il.push_front(infos);
39 auto current_size_delta =
static_cast<long>(infos.
size())
40 -
static_cast<long>(p.first->size());
42 || (p.first->children.empty() && !infos.
children.empty());
44 il.replace(p.first, infos);
48 il.relocate(
il.begin(),p.first);
64 auto it =
il.get<1>().find(token);
65 if(it!=
il.get<1>().end())
76 return cache.insert({token, type, std::vector<pg_uuid_t>(children, children+nb_children)});
81 auto opt =
cache.get(token);
84 auto nb_children = opt.value().children.size();
88 if(nb_children == 0) {
93 for(
unsigned i=0; i<nb_children; ++i)
94 (*children)[i] = opt.value().children[i];
104 auto opt =
cache.get(token);
106 return opt.value().type;
gate_type circuit_cache_get_type(pg_uuid_t token)
Retrieve the type of a cached gate.
unsigned circuit_cache_get_children(pg_uuid_t token, pg_uuid_t **children)
Retrieve the children of a cached gate.
constexpr unsigned MAX_CIRCUIT_CACHE_SIZE
Maximum total byte size of the in-process circuit gate cache (1 MiB).
bool circuit_cache_create_gate(pg_uuid_t token, gate_type type, unsigned nb_children, pg_uuid_t *children)
Insert a new gate into the circuit cache.
static CircuitCache cache
Process-local singleton circuit gate cache.
LRU in-process cache for recently created provenance circuit gates.
C-linkage interface to the in-process provenance circuit cache.
Bounded LRU cache mapping gate UUIDs to their CircuitCacheInfos.
item_list il
The container holding cached entries.
unsigned current_size
Current total byte usage of cached entries.
bool insert(const CircuitCacheInfos &infos)
Insert a new gate into the cache, evicting the oldest if necessary.
std::optional< CircuitCacheInfos > get(pg_uuid_t token) const
Look up a gate by UUID.
All information stored for a single gate in the circuit cache.
std::vector< pg_uuid_t > children
Ordered list of child gate UUIDs.
unsigned size() const
Estimated memory footprint of this entry in bytes.
gate_type type
Kind of gate (input, plus, times, …).