mirror of
https://github.com/matrix-construct/construct
synced 2024-11-30 02:32:43 +01:00
modules/client/rooms/messages: Cleanup loop; improve prefetch; reduce density of branches.
This commit is contained in:
parent
be2ae27af6
commit
404da37cc4
1 changed files with 14 additions and 19 deletions
|
@ -40,7 +40,7 @@ conf::item<size_t>
|
||||||
prefetch_max
|
prefetch_max
|
||||||
{
|
{
|
||||||
{ "name", "ircd.client.rooms.messages.prefetch.max" },
|
{ "name", "ircd.client.rooms.messages.prefetch.max" },
|
||||||
{ "default", 32L },
|
{ "default", 24L },
|
||||||
};
|
};
|
||||||
|
|
||||||
log::log
|
log::log
|
||||||
|
@ -132,12 +132,12 @@ get__messages(client &client,
|
||||||
top, "chunk"
|
top, "chunk"
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &pfetch_max
|
const auto &max_prefetch
|
||||||
{
|
{
|
||||||
std::min(size_t(page.limit), size_t(prefetch_max))
|
std::min(size_t(page.limit), size_t(prefetch_max))
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t pfetch{0}, pfetched{0};
|
size_t prefetch{0};
|
||||||
m::room::events pf
|
m::room::events pf
|
||||||
{
|
{
|
||||||
room
|
room
|
||||||
|
@ -151,10 +151,10 @@ get__messages(client &client,
|
||||||
|
|
||||||
for(; it; page.dir == 'b'? --it : ++it)
|
for(; it; page.dir == 'b'? --it : ++it)
|
||||||
{
|
{
|
||||||
for(; pf && pfetch < pfetched + prefetch_max; page.dir == 'b'? --pf : ++pf)
|
for(; pf && prefetch < hit + miss + max_prefetch; page.dir == 'b'? --pf : ++pf)
|
||||||
pfetch += pf.prefetch();
|
prefetch += pf.prefetch();
|
||||||
|
|
||||||
if(hit + miss == 0 && pfetch > 0)
|
if(hit + miss == 0 && prefetch > 0)
|
||||||
ctx::yield();
|
ctx::yield();
|
||||||
|
|
||||||
const m::event &event
|
const m::event &event
|
||||||
|
@ -166,22 +166,17 @@ get__messages(client &client,
|
||||||
if(hit > page.limit || miss >= size_t(max_filter_miss))
|
if(hit > page.limit || miss >= size_t(max_filter_miss))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(!visible(event, request.user_id))
|
const bool ok
|
||||||
{
|
{
|
||||||
++miss;
|
(empty(filter_json) || match(filter, event))
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty(filter_json) && !match(filter, event))
|
&& visible(event, request.user_id)
|
||||||
{
|
|
||||||
++miss;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_append(chunk, event, it.event_idx(), user_room, room_depth))
|
&& _append(chunk, event, it.event_idx(), user_room, room_depth)
|
||||||
++hit;
|
};
|
||||||
else
|
|
||||||
++miss;
|
hit += ok;
|
||||||
|
miss += !ok;
|
||||||
}
|
}
|
||||||
chunk.~array();
|
chunk.~array();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue