0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-01 19:22:53 +01:00

ircd:Ⓜ️:vm: Add earlier PREINDEX phase with prefetches for txn.

This commit is contained in:
Jason Volk 2020-12-05 05:12:45 -08:00
parent 54a591e45c
commit bf5b03adc4
4 changed files with 20 additions and 0 deletions

View file

@ -176,6 +176,7 @@ enum ircd::m::vm::phase
FETCH_PREV, ///< Previous events fetch phase. FETCH_PREV, ///< Previous events fetch phase.
FETCH_STATE, ///< State events fetch phase. FETCH_STATE, ///< State events fetch phase.
PRECOMMIT, ///< Precommit sequence. PRECOMMIT, ///< Precommit sequence.
PREINDEX, ///< Prefetch indexing & transaction dependencies.
AUTH_RELA, ///< Relative authentication phase. AUTH_RELA, ///< Relative authentication phase.
COMMIT, ///< Commit sequence. COMMIT, ///< Commit sequence.
AUTH_PRES, ///< Authentication phase. AUTH_PRES, ///< Authentication phase.

View file

@ -247,6 +247,7 @@ try
// Primary interest is to perform the INDEX and WRITE phase which create // Primary interest is to perform the INDEX and WRITE phase which create
// a database transaction and commit it respectively. // a database transaction and commit it respectively.
vmopts.phase.set(vm::phase::PREINDEX, true);
vmopts.phase.set(vm::phase::INDEX, true); vmopts.phase.set(vm::phase::INDEX, true);
vmopts.phase.set(vm::phase::WRITE, true); vmopts.phase.set(vm::phase::WRITE, true);

View file

@ -178,6 +178,7 @@ ircd::m::vm::reflect(const enum phase &code)
case phase::FETCH_PREV: return "FETCH_PREV"; case phase::FETCH_PREV: return "FETCH_PREV";
case phase::FETCH_STATE: return "FETCH_STATE"; case phase::FETCH_STATE: return "FETCH_STATE";
case phase::PRECOMMIT: return "PRECOMMIT"; case phase::PRECOMMIT: return "PRECOMMIT";
case phase::PREINDEX: return "PREINDEX";
case phase::AUTH_RELA: return "AUTH_RELA"; case phase::AUTH_RELA: return "AUTH_RELA";
case phase::COMMIT: return "COMMIT"; case phase::COMMIT: return "COMMIT";
case phase::AUTH_PRES: return "AUTH_PRES"; case phase::AUTH_PRES: return "AUTH_PRES";

View file

@ -869,6 +869,22 @@ ircd::m::vm::execute_pdu(eval &eval,
&& eval.parent->event_->event_id && eval.parent->event_->event_id
}; };
// Allocate transaction; prefetch dependencies.
if(likely(opts.phase[phase::PREINDEX]))
{
const scope_restore eval_phase
{
eval.phase, phase::PREINDEX
};
dbs::write_opts wopts(opts.wopts);
wopts.event_idx = eval.sequence;
const size_t prefetched
{
dbs::prefetch(event, wopts)
};
}
const scope_restore eval_phase_precommit const scope_restore eval_phase_precommit
{ {
eval.phase, phase::PRECOMMIT eval.phase, phase::PRECOMMIT
@ -1151,6 +1167,7 @@ ircd::m::vm::write_append(eval &eval,
} }
} }
assert(eval.txn);
const size_t wrote const size_t wrote
{ {
dbs::write(*eval.txn, event, wopts) dbs::write(*eval.txn, event, wopts)