Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #5425 +/- ##
=======================================
Coverage 88.85% 88.85%
=======================================
Files 333 333
Lines 91244 91252 +8
Branches 91244 91252 +8
=======================================
+ Hits 81072 81082 +10
+ Misses 6348 6344 -4
- Partials 3824 3826 +2 ☔ View full report in Codecov by Sentry. |
poljar
left a comment
There was a problem hiding this comment.
Seems sensible, left a question.
| let num_items = if chunk_type == CHUNK_TYPE_GAP_TYPE_STRING { | ||
| 0 | ||
| } else { | ||
| num_events_by_chunk_ids.get(&id).copied().unwrap_or(0) | ||
| }; |
There was a problem hiding this comment.
Doesn't a gap have 0 events by definition? Making this if/else redundant?
There was a problem hiding this comment.
It is, but my local testing showed it's 1% slower to not have this branch. The theory is that, at least on my machine, it's faster to allocate the chunk type string and compare against it, than it is to do a hashmap lookup that results in a cache miss.
But 1% doesn't matter much, so happy to get rid of it if you prefer?
There was a problem hiding this comment.
Nah it's fine. A comment explaining this might be nice though.
…ta` even faster See the updated code comment.
f6fc76a to
92d7349
Compare
|
Fantastic! |
#5411 was already an immense improvement for the loading of the chunks metadata, but running the benchmark on my machine it can take up to 25 ms for a single room with 10K events, which is unfortunately still a lot (considering we can have hundreds/thousands of rooms).
The strategy used there is good:
This implies that we'll have one additional
selectquery per event chunk. This gave me the idea for this strategy:COUNT+GROUP BY, and put that into a hashmap (from chunk id to number of events in that chunk)Then, when reforming the chunk metadata, use the hashmap to get the associated number of events. This is doing step 2 of the initial strategy in the app, to avoid running an extra
SELECTquery per event chunk.This leads to the following improvement, as reported by
cargo benchon the new benchmark:That is, it takes around 2ms for loading the metadata of a single room, instead of the initial 25ms that it took on my machine.