0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 16:33:53 +01:00

ircd:Ⓜ️:media::file: Add prefetching for events during read iteration.

This commit is contained in:
Jason Volk 2019-09-16 18:12:51 -07:00
parent 994b42ca71
commit 05641c356b
2 changed files with 27 additions and 2 deletions

View file

@ -133,6 +133,13 @@ ircd::m::media::blocks_cache_comp_size
}
};
decltype(ircd::m::media::events_prefetch)
ircd::m::media::events_prefetch
{
{ "name", "ircd.media.file.prefetch.events" },
{ "default", 16L },
};
decltype(ircd::m::media::database)
ircd::m::media::database;
@ -458,15 +465,32 @@ ircd::m::media::file::read(const m::room &room,
room, 1, &fopts
};
if(!it)
return ret;
room::events it_pf
{
room, 1, &fopts
};
// Block buffer
const unique_buffer<mutable_buffer> buf
{
64_KiB
};
for(; bool(it); ++it)
size_t prefetched(0), fetched(0);
for(; bool(it); ++it, ++fetched)
{
const m::event &event{*it};
for(; it_pf && prefetched < fetched + events_prefetch; ++it_pf)
prefetched += m::prefetch(it_pf.event_idx(), fopts);
++fetched;
const m::event &event
{
*it
};
if(at<"type"_>(event) != "ircd.file.block")
continue;

View file

@ -22,6 +22,7 @@ namespace ircd::m::media
extern conf::item<bool> blocks_cache_comp_enable;
extern conf::item<size_t> blocks_cache_size;
extern conf::item<size_t> blocks_cache_comp_size;
extern conf::item<size_t> events_prefetch;
extern const db::descriptor blocks_descriptor;
extern const db::description description;
extern std::shared_ptr<db::database> database;