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

Feature request: run_pending_tasks method to optionally take the max number of entries to process in a call #346

Open
tatsuya6502 opened this issue Nov 16, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@tatsuya6502
Copy link
Member

Split from #345 (comment).

And does the eviction handler then block data or threads for such a long time that the end-user observes a very long response time?

If that is the case, would it not be more handy to give the user some control over this behavior? Either beforehand by giving the run_pending_tasks() function an input u64 parameter of the maximum amount of items which can processed, and/or afterwards supply a boolean or u64 as return value containing the numbers of items which still needs to be processed...?

So, without queued delivery mode, cache writes could be blocked in the above case. As you see in the migration guide, run_pending_tasks does many types of task, so we could provide a struct with some fields to specify the maximum amounts of items to process per task type. As for the return type, it is expensive (e.g. O(n)) to count the numbers of items, which still needs to be processed. So probably we will return a stuct having the counters for the numbers of items, which were processed, per task type.

@tatsuya6502 tatsuya6502 added the enhancement New feature or request label Nov 16, 2023
@tatsuya6502
Copy link
Member Author

tatsuya6502 commented Dec 30, 2023

let counters = cache.pending_task_processing_options()
    // The maximum entries to process by the tasks that can call the
    // eviction listener.
    .max_entries_to_evict_due_to_size_limit(100)
    .max_expired_entries_to_evict(100)
    // (The entries scanned after calling `invalidate_all` or
    // `invalidate_entries_if`)
    .max_entries_to_scan_by_bulk_invalidation(500)
    // The maximum items to process by other tasks.
    .max_read_logs_to_process(2000)
    .max_write_logs_to_process(100)
    // Process the pending tasks.
    .run();

// NOTE: If you do not set some options above, `0` will be used for them.

// Resulting counters.
dbg!(counters.entries_evicted_due_to_size_limit);
dbg!(counters.expired_entries);
dbg!(counters.scanned_entries_by_bulk_invalidation);
dbg!(counters.read_logs_processed);
dbg!(counters.write_logs_processed);

EDIT: Renamed items to entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant