diff --git a/modules/client/sync.cc b/modules/client/sync.cc index 5823b8db4..92af40496 100644 --- a/modules/client/sync.cc +++ b/modules/client/sync.cc @@ -24,6 +24,7 @@ namespace ircd::m::sync extern conf::item buffer_size; extern conf::item linear_buffer_size; extern conf::item linear_delta_max; + extern conf::item polylog_prefetch; extern conf::item longpoll_enable; extern conf::item polylog_phased; extern conf::item polylog_only; @@ -133,6 +134,13 @@ ircd::m::sync::linear_delta_max { "help", linear_delta_max_help }, }; +decltype(ircd::m::sync::polylog_prefetch) +ircd::m::sync::polylog_prefetch +{ + { "name", "ircd.client.sync.polylog.prefetch" }, + { "default", 8192 }, +}; + decltype(ircd::m::sync::polylog_phased) ircd::m::sync::polylog_phased { @@ -1036,8 +1044,15 @@ try *data.out }; - // Prefetch loop - if(data.range.first == 0) + const bool prefetch + { + false + || (data.range.first == 0 && bool(polylog_prefetch)) + || (data.range.second - data.range.first > size_t(polylog_prefetch)) + }; + + // Branch to run a prefetch loop. + if(prefetch) { const scope_restore prefetching { diff --git a/modules/client/sync/rooms.cc b/modules/client/sync/rooms.cc index 3bc787d4d..b6f5a1541 100644 --- a/modules/client/sync/rooms.cc +++ b/modules/client/sync/rooms.cc @@ -141,6 +141,9 @@ ircd::m::sync::rooms_polylog(data &data) bool ret{false}; int64_t phase(0); + if(data.prefetch) + data.user_rooms.prefetch(); + ret |= _rooms_polylog(data, "join", phase); if(data.phased && ret) return ret;