mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd:Ⓜ️:vm: Add array-wide reference event_id pre-prefetcher.
This commit is contained in:
parent
d034ac7a7b
commit
59d4b987b5
4 changed files with 43 additions and 3 deletions
|
@ -22,6 +22,7 @@ namespace ircd::m::vm
|
|||
string_view loghead(const mutable_buffer &, const eval &);
|
||||
string_view loghead(const eval &); // single tls buffer
|
||||
|
||||
size_t prefetch_refs(const eval &);
|
||||
size_t fetch_keys(const eval &);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,12 @@ struct ircd::m::vm::opts
|
|||
/// perform a parallel/mass fetch before proceeding with the evals.
|
||||
bool mfetch_keys {true};
|
||||
|
||||
/// Whether to launch prefetches for all event_id's (found at standard
|
||||
/// locations) from the input vector, in addition to some other related
|
||||
/// local db prefetches. Disabled by default because it operates prior
|
||||
/// to verification and access phases; can be enabled explicitly.
|
||||
bool mprefetch_refs {false};
|
||||
|
||||
/// Throws fault::EVENT if *all* of the prev_events do not exist locally.
|
||||
/// This is used to enforce that at least one path is traversable. This
|
||||
/// test is conducted after waiting if fetch_prev and fetch_prev_wait.
|
||||
|
|
|
@ -78,6 +78,27 @@ ircd::m::vm::fetch_keys(const eval &eval)
|
|||
return fetched;
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::vm::prefetch_refs(const eval &eval)
|
||||
{
|
||||
assert(eval.opts);
|
||||
const dbs::write_opts &wopts
|
||||
{
|
||||
eval.opts->wopts
|
||||
};
|
||||
|
||||
size_t prefetched(0);
|
||||
for(const auto &event : eval.pdus)
|
||||
{
|
||||
if(event.event_id)
|
||||
prefetched += m::prefetch(event.event_id, "_event_idx");
|
||||
|
||||
prefetched += dbs::prefetch(event, wopts);
|
||||
}
|
||||
|
||||
return prefetched;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::m::vm::loghead(const eval &eval)
|
||||
{
|
||||
|
|
|
@ -220,8 +220,20 @@ ircd::m::vm::execute(eval &eval,
|
|||
const size_t prefetched_keys
|
||||
{
|
||||
prefetch_keys?
|
||||
fetch_keys(eval):
|
||||
0UL
|
||||
fetch_keys(eval): 0UL
|
||||
};
|
||||
|
||||
const bool prefetch_refs
|
||||
{
|
||||
opts.phase[phase::PREINDEX]
|
||||
&& opts.mprefetch_refs
|
||||
&& events.size() > 1
|
||||
};
|
||||
|
||||
const size_t prefetched_refs
|
||||
{
|
||||
prefetch_refs?
|
||||
vm::prefetch_refs(eval): 0UL
|
||||
};
|
||||
|
||||
size_t accepted(0), existed(0), i, j, k;
|
||||
|
@ -936,7 +948,7 @@ ircd::m::vm::execute_pdu(eval &eval,
|
|||
};
|
||||
|
||||
// Allocate transaction; prefetch dependencies.
|
||||
if(likely(opts.phase[phase::PREINDEX]))
|
||||
if(likely(opts.phase[phase::PREINDEX]) && !opts.mprefetch_refs)
|
||||
{
|
||||
const scope_restore eval_phase
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue