Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let IReminderTable to see all hash ranges at once #9381

Open
DunetsNM opened this issue Mar 12, 2025 · 0 comments
Open

Let IReminderTable to see all hash ranges at once #9381

DunetsNM opened this issue Mar 12, 2025 · 0 comments

Comments

@DunetsNM
Copy link

I have a custom implementation of IReminderTable which reads reminders from SQL database (ticks get persisted by other means which is not relevant here). By default there's 30 hash range buckets in each silo, so when Reminder Service refreshes it invokes 30 ReadRows in parallel resulting in 30 parallel SQL queries. While each query is lightweight it'd be even faster if I could make it all in one db roundtrip.

Currently the only idea I have is to make ReadRows(int, int) load all reminders for all silos and cache them for short time (like a minute - anything lower than refresh interval), or get them from the cache and then filter only reminders for the specified hash range. While it reduces number of db roundtrips the tradeoff is it'll fetch and filter more data than required (there's multiple silos).

So, how can I access all the hash ranges inside my Reminder Table implementation, to fetch only relevant reminders but for all buckets at once? Is it possible with current IReminderTable interface at all?

If not possible, then how about changing signature of Task<ReminderTableData> ReadRows(uint begin, uint end) to something like this (could be more readable but it communicates the idea)

Task<ReminderTableData>[] StartReadRowsForRanges((uint begin, uint end)[] ranges);

ReadRows is called for all hash ranges at once anyway via private LocalReminderService.ReadTableAndStartTimers methods, which are then awaited together via Task.WhenAll. This is easy to replace with a call to StartReadRowsForRanges which would return array of hot task each then passed to ReadTableAndStartTimers, and it'd be up to IReminderTable implemenation to decide what to do: run each bucket as a separate query, or merge it all into one query and then fill TaskCompletionSources. Do I miss anything here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants