mirror of
https://github.com/matrix-construct/construct
synced 2024-11-11 12:31:07 +01:00
ircd:Ⓜ️:homeserver: Use batched eval in bootstrap loop.
This commit is contained in:
parent
fb1f36ce72
commit
1407d8451a
1 changed files with 43 additions and 44 deletions
|
@ -269,12 +269,13 @@ try
|
||||||
// Outputs to infolog for each event; may be noisy;
|
// Outputs to infolog for each event; may be noisy;
|
||||||
vmopts.infolog_accept = false;
|
vmopts.infolog_accept = false;
|
||||||
|
|
||||||
static const size_t window_size
|
static const size_t batch_max
|
||||||
{
|
{
|
||||||
4_MiB
|
2048
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t count {0}, ebytes[2] {0}, accept {0}, exists {0};
|
size_t count {0}, ebytes[2] {0, 1}, accept {0};
|
||||||
|
std::vector<m::event> vec(1024);
|
||||||
vm::eval eval
|
vm::eval eval
|
||||||
{
|
{
|
||||||
vmopts
|
vmopts
|
||||||
|
@ -282,27 +283,31 @@ try
|
||||||
|
|
||||||
// Perform the eval
|
// Perform the eval
|
||||||
util::timer stopwatch;
|
util::timer stopwatch;
|
||||||
for(auto it(begin(events)); it != end(events); ++it)
|
auto it(begin(events));
|
||||||
|
while(it != end(events))
|
||||||
{
|
{
|
||||||
const json::object object
|
size_t i(0);
|
||||||
|
for(; i < vec.size() && it != end(events); ++i, ++it)
|
||||||
{
|
{
|
||||||
*it
|
const string_view &elem(*it);
|
||||||
|
vec[i] = json::object{elem};
|
||||||
|
ebytes[1] += elem.size() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t accepted
|
||||||
|
{
|
||||||
|
execute(eval, vector_view<const m::event>
|
||||||
|
{
|
||||||
|
vec.data(), vec.data() + i
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
const m::event event
|
assert(i >= accepted);
|
||||||
{
|
accept += accepted;
|
||||||
object
|
count += i;
|
||||||
};
|
|
||||||
|
|
||||||
const auto code
|
auto opts(map_opts);
|
||||||
{
|
opts.offset = ebytes[0];
|
||||||
execute(eval, event)
|
|
||||||
};
|
|
||||||
|
|
||||||
count += 1;
|
|
||||||
accept += code == vm::fault::ACCEPT;
|
|
||||||
exists += code == vm::fault::EXISTS;
|
|
||||||
ebytes[1] += object.string_view::size();
|
|
||||||
const size_t incore
|
const size_t incore
|
||||||
{
|
{
|
||||||
ebytes[1] > ebytes[0]?
|
ebytes[1] > ebytes[0]?
|
||||||
|
@ -310,34 +315,28 @@ try
|
||||||
0UL
|
0UL
|
||||||
};
|
};
|
||||||
|
|
||||||
if(incore >= window_size)
|
ebytes[0] += evict(map, incore, opts);
|
||||||
|
|
||||||
|
const auto db_bytes
|
||||||
{
|
{
|
||||||
auto opts(map_opts);
|
db::ticker(*dbs::events, "rocksdb.bytes.written")
|
||||||
opts.offset = ebytes[0];
|
};
|
||||||
ebytes[0] += evict(map, incore, opts);
|
|
||||||
|
|
||||||
const auto db_bytes
|
log::info
|
||||||
{
|
{
|
||||||
db::ticker(*dbs::events, "rocksdb.bytes.written")
|
log, "Bootstrap retired:%zu count:%zu accept:%zu %s in %s | %zu event/s; input %s/s; output %s/s",
|
||||||
};
|
vm::sequence::retired,
|
||||||
|
count,
|
||||||
|
accept,
|
||||||
|
pretty(pbuf[0], iec(ebytes[1])),
|
||||||
|
stopwatch.pretty(pbuf[1]),
|
||||||
|
(count / std::max(stopwatch.at<seconds>().count(), 1L)),
|
||||||
|
pretty(pbuf[2], iec(ebytes[1] / std::max(stopwatch.at<seconds>().count(),1L)), 1),
|
||||||
|
pretty(pbuf[3], iec(db_bytes / std::max(stopwatch.at<seconds>().count(),1L)), 1),
|
||||||
|
};
|
||||||
|
|
||||||
log::info
|
ctx::yield();
|
||||||
{
|
ctx::interruption_point();
|
||||||
log, "Bootstrap retired:%zu count:%zu accept:%zu exists:%zu %s in %s | %zu event/s; input %s/s; output %s/s",
|
|
||||||
vm::sequence::retired,
|
|
||||||
count,
|
|
||||||
accept,
|
|
||||||
exists,
|
|
||||||
pretty(pbuf[0], iec(ebytes[1])),
|
|
||||||
stopwatch.pretty(pbuf[1]),
|
|
||||||
(count / std::max(stopwatch.at<seconds>().count(), 1L)),
|
|
||||||
pretty(pbuf[2], iec(ebytes[1] / std::max(stopwatch.at<seconds>().count(),1L)), 1),
|
|
||||||
pretty(pbuf[3], iec(db_bytes / std::max(stopwatch.at<seconds>().count(),1L)), 1),
|
|
||||||
};
|
|
||||||
|
|
||||||
ctx::yield();
|
|
||||||
ctx::interruption_point();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log::notice
|
log::notice
|
||||||
|
|
Loading…
Reference in a new issue