mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
modules/client/sync: Improve phased initial sync by bursting full room list at phase 0.
This commit is contained in:
parent
a82410009e
commit
a8b536e420
3 changed files with 42 additions and 25 deletions
10
ircd/m.cc
10
ircd/m.cc
|
@ -731,15 +731,7 @@ try
|
|||
return false;
|
||||
|
||||
// Skip the item for phased-sync ranges if it's not phased-sync aware.
|
||||
if(!phased && data.phased && int64_t(data.range.first) < 0L)
|
||||
{
|
||||
assert(data.phased);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Skip the item for the initial-sync pass if it's phased-sync aware;
|
||||
// it will be called for the first time at the next phase.
|
||||
if(phased && data.phased && data.range.first == 0UL)
|
||||
if(!phased && data.phased)
|
||||
return false;
|
||||
|
||||
#ifdef RB_DEBUG
|
||||
|
|
|
@ -133,18 +133,16 @@ ircd::m::sync::_rooms_polylog(data &data,
|
|||
const user::rooms::closure_bool closure{[&data, &ret, &phase]
|
||||
(const m::room &room, const string_view &membership_)
|
||||
{
|
||||
assert(!data.phased || int64_t(data.range.first) < 0L);
|
||||
|
||||
if(data.phased)
|
||||
{
|
||||
if(phase >= int64_t(data.range.first))
|
||||
{
|
||||
--phase;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(phase < int64_t(data.range.first) && ret)
|
||||
return false;
|
||||
|
||||
if(int64_t(data.range.first) < 0L)
|
||||
--phase;
|
||||
|
||||
if(phase > int64_t(data.range.first))
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(RB_DEBUG)
|
||||
|
@ -160,20 +158,19 @@ ircd::m::sync::_rooms_polylog(data &data,
|
|||
#endif
|
||||
|
||||
{
|
||||
const scope_restore phased
|
||||
{
|
||||
data.phased, int64_t(data.range.first) < 0? false : data.phased
|
||||
};
|
||||
|
||||
const scope_restore range
|
||||
{
|
||||
data.range.first, data.phased? 0UL : data.range.first
|
||||
data.range.first, phased.theirs? 0UL : data.range.first
|
||||
};
|
||||
|
||||
ret |= _rooms_polylog_room(data, room);
|
||||
}
|
||||
|
||||
if(data.phased && !ret)
|
||||
{
|
||||
--data.range.first;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(RB_DEBUG)
|
||||
thread_local char tmbuf[32];
|
||||
if(data.stats && rooms.stats_debug) log::debug
|
||||
|
|
|
@ -41,7 +41,10 @@ ircd::m::sync::room_state
|
|||
{
|
||||
"rooms.state",
|
||||
room_state_polylog,
|
||||
room_state_linear
|
||||
room_state_linear,
|
||||
{
|
||||
{ "phased", true },
|
||||
}
|
||||
};
|
||||
|
||||
decltype(ircd::m::sync::room_invite_state)
|
||||
|
@ -154,12 +157,37 @@ ircd::m::sync::room_state_polylog_events(data &data)
|
|||
{
|
||||
const m::room &room{*data.room};
|
||||
const m::room::state state{room};
|
||||
|
||||
json::stack::array array
|
||||
{
|
||||
*data.out, "events"
|
||||
};
|
||||
|
||||
bool ret{false};
|
||||
if(data.phased && data.range.first == 0)
|
||||
{
|
||||
data.room->get(std::nothrow, "m.room.create", "", [&]
|
||||
(const m::event &event)
|
||||
{
|
||||
room_state_append(data, array, event, index(event));
|
||||
ret = true;
|
||||
});
|
||||
|
||||
data.room->get(std::nothrow, "m.room.canonical_alias", "", [&]
|
||||
(const m::event &event)
|
||||
{
|
||||
room_state_append(data, array, event, index(event));
|
||||
});
|
||||
|
||||
data.room->get(std::nothrow, "m.room.name", "", [&]
|
||||
(const m::event &event)
|
||||
{
|
||||
room_state_append(data, array, event, index(event));
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ctx::mutex mutex;
|
||||
const event::closure_idx each_idx{[&data, &array, &mutex, &ret]
|
||||
(const m::event::idx event_idx)
|
||||
|
|
Loading…
Reference in a new issue