31 std::pair<iterator,bool> p=
il.push_front(infos);
42 auto current_size_delta =
static_cast<long>(infos.
size())
43 -
static_cast<long>(p.first->size());
45 || (p.first->children.empty() && !infos.
children.empty());
47 il.replace(p.first, infos);
51 il.relocate(
il.begin(),p.first);
67 auto it =
il.get<1>().find(token);
68 if(it!=
il.get<1>().end())
84 return cache.insert({token, type, std::vector<pg_uuid_t>(children, children+nb_children)});
89 auto opt =
cache.get(token);
92 auto nb_children = opt.value().children.size();
96 if(nb_children == 0) {
101 for(
unsigned i=0; i<nb_children; ++i)
102 (*children)[i] = opt.value().children[i];
112 auto opt =
cache.get(token);
114 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.
bool circuit_cache_create_gate(pg_uuid_t token, gate_type type, unsigned nb_children, const pg_uuid_t *children)
Insert a new gate into the circuit cache.
void circuit_cache_reset(void)
Forget every cached gate.
static unsigned long max_cache_size()
Byte budget of the cache: provsql.gate_cache_size, in kB.
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.
int provsql_gate_cache_size
Byte budget, in kB, of the per-backend gate cache; provsql.gate_cache_size GUC.
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…).