Remove overall item batching (still keeping FSRS batching)

This commit is contained in:
Daniel Pechersky 2025-09-16 16:17:06 +07:00
parent f2d6c30036
commit 1514b99785

View file

@ -290,21 +290,19 @@ impl Collection {
fn update_memory_state_for_cards_with_items(
&mut self,
mut items: Vec<(CardId, FsrsItemForMemoryState)>,
items: Vec<(CardId, FsrsItemForMemoryState)>,
fsrs: &FSRS,
mut set_decay_and_desired_retention: impl FnMut(&mut Card),
mut maybe_reschedule_card: impl FnMut(&mut Card, &mut Self, &FSRS) -> Result<()>,
usn: Usn,
mut on_updated_card: impl FnMut() -> Result<()>,
) -> Result<()> {
const ITEM_CHUNK_SIZE: usize = 100_000;
const FSRS_CHUNK_SIZE: usize = 1000;
const FSRS_BATCH_SIZE: usize = 1000;
let mut to_update = Vec::new();
let mut fsrs_items = Vec::new();
let mut starting_states = Vec::new();
for items in items.chunk_into_vecs(ITEM_CHUNK_SIZE) {
for (card_id, item) in items.into_iter() {
let card = self.storage.get_card(card_id)?.or_not_found(card_id)?;
@ -321,9 +319,9 @@ impl Collection {
p.apply_slice_in_place(&mut starting_states);
for ((to_update, fsrs_items), starting_states) in to_update
.chunk_into_vecs(FSRS_CHUNK_SIZE)
.zip_eq(fsrs_items.chunk_into_vecs(FSRS_CHUNK_SIZE))
.zip_eq(starting_states.chunk_into_vecs(FSRS_CHUNK_SIZE))
.chunk_into_vecs(FSRS_BATCH_SIZE)
.zip_eq(fsrs_items.chunk_into_vecs(FSRS_BATCH_SIZE))
.zip_eq(starting_states.chunk_into_vecs(FSRS_BATCH_SIZE))
{
let memory_states = fsrs.memory_state_batch(fsrs_items, starting_states)?;
@ -336,7 +334,6 @@ impl Collection {
on_updated_card()?;
}
}
}
Ok(())
}