From 18977fabe160c234db740fac601b0103e568d48b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 16 Oct 2018 00:06:44 -0700 Subject: [PATCH] modules/client/sync: Condition on conf items for prefetches of polylog state/timeline. --- modules/client/sync.cc | 32 +++++++++++++++++++++++++------- modules/client/sync.h | 3 +++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/modules/client/sync.cc b/modules/client/sync.cc index ce9737d13..f15b04527 100644 --- a/modules/client/sync.cc +++ b/modules/client/sync.cc @@ -616,6 +616,20 @@ ircd::m::sync::linear::handle(client &client, // polylog // +ircd::conf::item +ircd::m::sync::polylog::prefetch_state +{ + { "name", "ircd.client.sync.polylog.prefetch.state" }, + { "default", true }, +}; + +ircd::conf::item +ircd::m::sync::polylog::prefetch_timeline +{ + { "name", "ircd.client.sync.polylog.prefetch.timeline" }, + { "default", true }, +}; + bool ircd::m::sync::polylog::handle(client &client, shortpoll &sp, @@ -897,14 +911,17 @@ ircd::m::sync::polylog::room_state(shortpoll &sp, room, &fopts }; - state.for_each([&] - (const m::event::idx &event_idx) + if(bool(prefetch_state)) { - if(event_idx < sp.since || event_idx >= sp.current) - return; + state.for_each([&] + (const m::event::idx &event_idx) + { + if(event_idx < sp.since || event_idx >= sp.current) + return; - m::prefetch(event_idx, fopts); - }); + m::prefetch(event_idx, fopts); + }); + } state.for_each([&] (const m::event &event) @@ -1001,7 +1018,8 @@ ircd::m::sync::polylog::room_timeline_events(shortpoll &sp, if(it.event_idx() >= sp.current) break; - m::prefetch(it.event_idx(), fopts); + if(bool(prefetch_timeline)) + m::prefetch(it.event_idx(), fopts); } limited = i >= 10; diff --git a/modules/client/sync.h b/modules/client/sync.h index c393e4591..6014285cd 100644 --- a/modules/client/sync.h +++ b/modules/client/sync.h @@ -72,6 +72,9 @@ namespace ircd::m::sync::linear namespace ircd::m::sync::polylog { + extern conf::item prefetch_state; + extern conf::item prefetch_timeline; + static void room_state(shortpoll &, json::stack::object &, const m::room &); static m::event::id::buf room_timeline_events(shortpoll &, json::stack::array &, const m::room &, bool &limited); static void room_timeline(shortpoll &, json::stack::object &, const m::room &);