Limit chunk reparation mechanisms to avoid too high delays

Change-Id: I0512a911b8637cd62815e2570e1897a374bbcf5b
This commit is contained in:
SpiritCroc 2022-05-13 12:22:41 +02:00
parent 7c80957e5a
commit 07288c5458

View file

@ -65,6 +65,8 @@ const val ENABLE_TIMELINE_LOOP_SPLITTING = true
// TODO: once we feel comfortable that this is no longer necessary,
// we probably want to disable this again for improving performance.
const val ENABLE_TIMELINE_EMPTY_CHUNK_CLEANUP = true
// Performance consideration for huge timelines, when having ENABLE_TIMELINE_LOOP_SPLITTING or ENABLE_TIMELINE_EMPTY_CHUNK_CLEANUP set to true
const val MAX_CHUNK_REPAIR_CHECK_COUNT = 100
internal class LoadTimelineStrategy constructor(
private val roomId: String,
@ -431,6 +433,10 @@ internal class LoadTimelineStrategy constructor(
}
}
chunk = next
if (visited.size > MAX_CHUNK_REPAIR_CHECK_COUNT) {
Timber.i("Abort searching $directionName for empty chunks after ${visited.size} chunks")
return
}
}
}
@ -449,6 +455,10 @@ internal class LoadTimelineStrategy constructor(
break
}
visited.add(chunk.identifier())
if (visited.size > MAX_CHUNK_REPAIR_CHECK_COUNT) {
Timber.i("Abort searching $directionName for chunk loops after ${visited.size} chunks")
return
}
chunk = directionFun(chunk)
}