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 - Cooperative Program Loading #33715

Closed

Conversation

Lichtso
Copy link
Contributor

@Lichtso Lichtso commented Oct 16, 2023

Problem

Currently transaction batches race in parallel to load, verify and compile missing cache entries.
Instead they should be coordinating and split these tasks to distribute the workload across the threads and to avoid redundant work.

Summary of Changes

  • Removes LoadedPrograms::replenish() and LoadedProgramsForTxBatch::replenish().
  • Adds LoadedProgramType::Loading and LoadedProgram::new_loading().
  • Adds LoadedPrograms::get_cooperative_loading_task() and LoadedPrograms::submit_cooperative_loading_task().

@Lichtso Lichtso marked this pull request as draft October 16, 2023 17:14
program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
let mut missing = Vec::new();
let mut unloaded = Vec::new();
let found = keys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly related to this PR since it was already like this, but I think this
should be a loop not a filter_map.

The iterator is filtering found, and at the same time populating missing, setting some stats,
and now also populating waiting_list. Seems arbitrary and confusing that one is done through the
iterator and the rest imperatively. As a rule of thumb, I think iterators should be for one sequence
-> one sequence transformations.

runtime/src/bank.rs Outdated Show resolved Hide resolved
@Lichtso Lichtso force-pushed the refactor/cooperative_porgram_loading branch from 4408b4b to 92e6a61 Compare October 17, 2023 16:31
if let Some(task) = loaded_programs_cache.next_cooperative_loading_task() {
task
} else {
// Waiting for some other TX batch to complete loading the programs needed by this TX batch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But won't this spin?

I think we should sleep when there's no work, we could use Condvar or something to sleep until the
threads that are compiling our programs signal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it is a spin lock. Can make it ore efficient later, still working on correctness though.

@Lichtso Lichtso force-pushed the refactor/cooperative_porgram_loading branch from 92e6a61 to 1b4d9b9 Compare October 18, 2023 15:24
@Lichtso Lichtso changed the title Refactor - Cooperative Program Loading Feature - Cooperative Program Loading Oct 21, 2023
@Lichtso Lichtso force-pushed the refactor/cooperative_porgram_loading branch 3 times, most recently from 4183994 to c036405 Compare October 27, 2023 11:05
@github-actions github-actions bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Nov 13, 2023
@Lichtso Lichtso force-pushed the refactor/cooperative_porgram_loading branch from c036405 to 0a6d0c7 Compare November 15, 2023 13:53
@Lichtso Lichtso removed the stale [bot only] Added to stale content; results in auto-close after a week. label Nov 15, 2023
@Lichtso Lichtso force-pushed the refactor/cooperative_porgram_loading branch 2 times, most recently from de72937 to b0e6d78 Compare November 21, 2023 15:32
@Lichtso Lichtso force-pushed the refactor/cooperative_porgram_loading branch 2 times, most recently from edf1dcb to 90c139c Compare November 27, 2023 15:45
@Lichtso Lichtso force-pushed the refactor/cooperative_porgram_loading branch from 90c139c to 305dcd2 Compare December 7, 2023 09:20
@Lichtso Lichtso closed this Dec 11, 2023
@Lichtso Lichtso deleted the refactor/cooperative_porgram_loading branch December 11, 2023 20:41
@Lichtso
Copy link
Contributor Author

Lichtso commented Dec 12, 2023

Closed in favor of #34407.

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.

3 participants