Faster member list by avoiding many FFI calls (#2322)

* Faster member list by avoiding many FFI calls
This commit is contained in:
Timo Kösters 2024-03-05 10:41:51 +01:00 committed by GitHub
parent f2169aaaa8
commit 38cea8e68e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

1
changelog.d/2322.misc Normal file
View file

@ -0,0 +1 @@
Improve room member list loading times, increase chunk size

View file

@ -40,7 +40,7 @@ import kotlin.coroutines.coroutineContext
internal class RoomMemberListFetcher(
private val room: RoomInterface,
private val dispatcher: CoroutineDispatcher,
private val pageSize: Int = 1000,
private val pageSize: Int = 10_000,
) {
private val updatedRoomMemberMutex = Mutex()
private val roomId = room.id()
@ -108,6 +108,7 @@ internal class RoomMemberListFetcher(
// We should probably implement some sort of paging in the future.
coroutineContext.ensureActive()
val chunk = iterator.nextChunk(pageSize.toUInt())
// Load next chunk. If null (no more items), exit the loop
val members = chunk?.parallelMap(RoomMemberMapper::map) ?: break
addAll(members)
Timber.i("Emitting first $size members for room $roomId")