mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 22:41:12 +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,20 +146,33 @@ ircd::m::vm::execute(eval &eval,
|
|||
if(likely(opts.phase[phase::VERIFY] && opts.mfetch_keys))
|
||||
eval.mfetch_keys();
|
||||
|
||||
size_t ret(0), i(0);
|
||||
for(auto it(begin(events)); it != end(events) && i < opts.limit; ++it, ++i) try
|
||||
size_t accepted(0), existed(0), i, j, k;
|
||||
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
|
||||
};
|
||||
|
||||
existed += __builtin_popcountl(exists);
|
||||
for(k = 0; k < j; ++k) try
|
||||
{
|
||||
if(exists & (1 << k))
|
||||
continue;
|
||||
|
||||
const auto status
|
||||
{
|
||||
execute(eval, event)
|
||||
execute(eval, events[i + k])
|
||||
};
|
||||
|
||||
ret += status == fault::ACCEPT;
|
||||
accepted += status == fault::ACCEPT;
|
||||
}
|
||||
catch(const ctx::interrupted &)
|
||||
{
|
||||
|
@ -169,8 +182,9 @@ ircd::m::vm::execute(eval &eval,
|
|||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return accepted;
|
||||
}
|
||||
|
||||
ircd::m::vm::fault
|
||||
|
|
Loading…
Reference in a new issue