mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 23:44:01 +01:00
ircd:Ⓜ️:vm: Add inner batch loop around parallel existence query.
This commit is contained in:
parent
121de5a6dc
commit
b3085eecd8
1 changed files with 31 additions and 17 deletions
|
@ -146,31 +146,45 @@ ircd::m::vm::execute(eval &eval,
|
||||||
if(likely(opts.phase[phase::VERIFY] && opts.mfetch_keys))
|
if(likely(opts.phase[phase::VERIFY] && opts.mfetch_keys))
|
||||||
eval.mfetch_keys();
|
eval.mfetch_keys();
|
||||||
|
|
||||||
size_t ret(0), i(0);
|
size_t accepted(0), existed(0), i, j, k;
|
||||||
for(auto it(begin(events)); it != end(events) && i < opts.limit; ++it, ++i) try
|
for(i = 0; i < events.size() && i < opts.limit; i += j)
|
||||||
{
|
{
|
||||||
const m::event &event
|
id::event ids[64];
|
||||||
|
for(j = 0; j < 64 && i + j < events.size() && i + j < opts.limit; ++j)
|
||||||
|
ids[j] = events[i + j].event_id;
|
||||||
|
|
||||||
|
// Bitset indicating which events already exist.
|
||||||
|
const uint64_t exists
|
||||||
{
|
{
|
||||||
*it
|
!opts.replays?
|
||||||
|
m::exists(vector_view<const id::event>(ids, j)):
|
||||||
|
0UL
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto status
|
existed += __builtin_popcountl(exists);
|
||||||
|
for(k = 0; k < j; ++k) try
|
||||||
{
|
{
|
||||||
execute(eval, event)
|
if(exists & (1 << k))
|
||||||
};
|
continue;
|
||||||
|
|
||||||
ret += status == fault::ACCEPT;
|
const auto status
|
||||||
}
|
{
|
||||||
catch(const ctx::interrupted &)
|
execute(eval, events[i + k])
|
||||||
{
|
};
|
||||||
throw;
|
|
||||||
}
|
accepted += status == fault::ACCEPT;
|
||||||
catch(const std::exception &)
|
}
|
||||||
{
|
catch(const ctx::interrupted &)
|
||||||
continue;
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch(const std::exception &)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::m::vm::fault
|
ircd::m::vm::fault
|
||||||
|
|
Loading…
Reference in a new issue