Skip to content

Commit 2caa283

Browse files
ldanilekConvex, Inc.
authored andcommitted
TableIterator tokio yield between docs (#30226)
GitOrigin-RevId: c6b98f05a596c1c69c08bc12a9254ba9d7c143dc
1 parent fd6054e commit 2caa283

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/database/src/table_iteration.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ impl<RT: Runtime> TableIterator<RT> {
252252

253253
let mut merged_page_docs = self.reload_revisions_at_snapshot_ts(merged_page);
254254
while let Some((key, ts, doc)) = merged_page_docs.try_next().await? {
255+
// The caller will likely consume the documents in a CPU-intensive loop,
256+
// and `merged_page_docs.try_next().await` will often be Ready
257+
// immediately, so it won't yield.
258+
// Make sure we yield to not starve other tokio tasks.
259+
tokio::task::consume_budget().await;
260+
255261
yield (key, ts, doc);
256262
}
257263
if matches!(page_end, CursorPosition::End) {

0 commit comments

Comments
 (0)