Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@L-M-Sherlock
Copy link
Contributor

@L-M-Sherlock L-M-Sherlock commented Feb 13, 2025

It supports load balance and easy days natively in rescheduling. For the sake of performance, I didn't reuse the LoadBalancer and LoadBalancerContext.

Preview:

25.02:

image

The PR:

image

The PR with easy days:

imageimage

@jakeprobst
Copy link
Contributor

jakeprobst commented Feb 13, 2025

For the sake of performance, I didn't reuse the LoadBalancer and LoadBalancerContext.

this feels like a setup for future sadness, how bad was the perf hit that made this the preferable choice?

At the very least, I'd say move everything that is common to both into their own functions so the logic will be consistent across them both. this will also make it easier to see the ways in which these differ, like I can tell they are sliiightly different but its hard to determine where without also pulling up the other code, if all common logic is in the same spot it'll be clear what the differences are.

@L-M-Sherlock
Copy link
Contributor Author

this feels like a setup for future sadness, how bad was the perf hit that made this the preferable choice?

This function is I/O bound:

impl LoadBalancer {
pub fn new(
today: u32,
did_to_dcid: HashMap<DeckId, DeckConfigId>,
next_day_at: TimestampSecs,
storage: &SqliteStorage,
) -> Result<LoadBalancer> {
let cards_on_each_day =
storage.get_all_cards_due_in_range(today, today + LOAD_BALANCE_DAYS as u32)?;

For rescheduling, the today is the last review date, so I have to re-create load balancer for each card. It's very slow. It would take 1 minute to reschedule thousands of cards.

@dae
Copy link
Member

dae commented Feb 13, 2025

For future maintenance, we definitely want as much code shared between the paths as possible - whether that's by reusing old code and doing things like mutating an existing context for each card instead of creating a new one (which may not be practical here), or by introducing this new code and having the old code use it.

@YukiNagat0
Copy link
Contributor

Does this change respect the mw.col.load_balancer_enabled option?

@L-M-Sherlock
Copy link
Contributor Author

Does this change respect the mw.col.load_balancer_enabled option?

It does now.

For future maintenance, we definitely want as much code shared between the paths as possible - whether that's by reusing old code and doing things like mutating an existing context for each card instead of creating a new one (which may not be practical here), or by introducing this new code and having the old code use it.

I'm reusing some code snippet now.

@L-M-Sherlock L-M-Sherlock marked this pull request as ready for review February 13, 2025 07:07
@L-M-Sherlock
Copy link
Contributor Author

In the latest commit, if the user changes the easy days setting and enable "reschedule cards on change", the rescheduling will be executed without modifying the desired retention or FSRS parameters.

@dae
Copy link
Member

dae commented Feb 16, 2025

Thanks Jarrett, this should make a lot of people happy. As this is largely based on @jakeprobst's code, I'll defer to him on the final approval, but no issues from my end.

One thought: it won't be obvious to users that reschedule on change affects easy days as it's in a different section. One optional improvement would be to display a yellow warning when easy days are changed and reschedule is off - something like:

"Existing reviews will not be rescheduled unless '{ deck-config-reschedule-cards-on-change }' is enabled in the FSRS options."

@jakeprobst
Copy link
Contributor

looks good to me!

@L-M-Sherlock
Copy link
Contributor Author

In the 51f43f5, I added this warning:

image

It works well with previous warning, too.

image

@user1823
Copy link
Contributor

Existing reviews will not be rescheduled unless 'Reschedule cards on change' is enabled in the FSRS options.

What if the user doesn't have FSRS enabled? IMO, this warning should be hidden in that case.

@user1823
Copy link
Contributor

Also somewhat related:
Currently, the FSRS helper add-on has its own implementation of load balancer and easy days. Does it make sense to expose the Rust code to add-ons so that the Helper add-on could use it directly instead of re-implementing it in Python?

@jakeprobst
Copy link
Contributor

Currently, the FSRS helper add-on has its own implementation of load balancer and easy days. Does it make sense to expose the Rust code to add-ons so that the Helper add-on could use it directly instead of re-implementing it in Python?

My initial thought is this is probably really difficult to do, unfortunately

@dae
Copy link
Member

dae commented Feb 18, 2025

What if the user doesn't have FSRS enabled? IMO, this warning should be hidden in that case.

I thought about it, but hiding it gives the user no clue that it's not retroactive in the SM2 case.

@dae
Copy link
Member

dae commented Feb 18, 2025

Thanks everyone!

@dae dae merged commit 59e143e into ankitects:main Feb 18, 2025
1 check passed
@dae
Copy link
Member

dae commented Feb 18, 2025

Sorry, I try to remove my attribution when making such trivial changes, but I forgot again. :-(

@L-M-Sherlock L-M-Sherlock deleted the Feat/support-load-balance-and-easy-days-in-rescheduling branch February 18, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants