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

Implementation of ClientStateManager #985

Merged

Conversation

adam-singer
Copy link
Contributor

@adam-singer adam-singer commented Jun 11, 2024

Description

Implementation of ClientStateManager where the beginnings of being able to tuck mutations behind a trait for StateManager. StateManager now wraps the StateManagerImpl for inner state structure StateManagerImpl. All mutations should be done on a lock on inner in the future. Moving implementation code of add_action and filter_operations into ClientStateManager trait. Updated accessor code from state_manager to state_manager.inner.

Fixes #990

Type of change

Please delete options that aren't relevant.

  • Refactor

How Has This Been Tested?

Existing tests

Checklist

  • bazel test //... passes locally
  • PR is contained in a single commit, using git amend see some docs

This change is Reviewable

Copy link
Contributor Author

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Analyze (javascript-typescript), Analyze (python), Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, vale, windows-2022 / stable, and 1 discussions need to be resolved


nativelink-scheduler/src/scheduler_state/client_action_state_result.rs line 25 at r1 (raw file):

pub(crate) struct ClientActionStateResult {
    //notify_channel: Receiver<Arc<ActionState>>,

remove

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

Looks good.

Reviewed 3 of 7 files at r1.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), macos-13, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable, and 7 discussions need to be resolved


nativelink-scheduler/src/scheduler_state/client_action_state_result.rs line 31 at r1 (raw file):

impl ClientActionStateResult {
    pub(crate) fn new(mut rx: Receiver<Arc<ActionState>>) -> Self {
        rx.mark_changed();

nit: Add comment on why we are marking it changed.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 185 at r1 (raw file):

        filter: OperationFilter,
    ) -> Result<ActionStateResultStream, Error> {
        let unique_qualifier = &filter

nit: Add todo to build this out to a proper filter.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 194 at r1 (raw file):

            .and_then(|action_info| self.inner.queued_actions.get(action_info))
            .or_else(|| self.inner.active_actions.get(unique_qualifier));
        let client_action_state_result: Pin<Box<Iter<IntoIter<Arc<dyn ActionStateResult>>>>> =

nit: Can we remove this type? Forcing the compiler down a specific type route reduces possible optimizations.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 197 at r1 (raw file):

            Box::pin(
                awaited_action
                    .map(|aa| {

aa?


nativelink-scheduler/src/scheduler_state/state_manager.rs line 200 at r1 (raw file):

                        let rx = aa.notify_channel.subscribe();
                        let action_result: Vec<Arc<dyn ActionStateResult>> =
                            vec![Arc::new(ClientActionStateResult::new(rx))];

nit: Use a fixed array instead, no need to make a heap allocation.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 203 at r1 (raw file):

                        stream::iter(action_result)
                    })
                    .unwrap_or_else(|| stream::iter(Vec::new())),

nit: ditto.

Copy link
Contributor Author

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), macos-13, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable, and 3 discussions need to be resolved


nativelink-scheduler/src/scheduler_state/client_action_state_result.rs line 31 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: Add comment on why we are marking it changed.

Done.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 185 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: Add todo to build this out to a proper filter.

Done.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 194 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: Can we remove this type? Forcing the compiler down a specific type route reduces possible optimizations.

Done.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 197 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

aa?

Done.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 200 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: Use a fixed array instead, no need to make a heap allocation.

Seems like some error between fixed size vec and stream::iter where the size is encoded into the type signature
Screenshot 2024-06-11 at 1.46.25 PM.png

@adam-singer adam-singer force-pushed the adams/impl-client-state-manager branch 2 times, most recently from bcd40a9 to d5a5450 Compare June 11, 2024 21:06
Copy link
Contributor Author

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Analyze (javascript-typescript), Vercel, asan / ubuntu-22.04, integration-tests (20.04), pre-commit-checks, ubuntu-22.04, vale, and 1 discussions need to be resolved


nativelink-scheduler/src/scheduler_state/state_manager.rs line 200 at r1 (raw file):

Previously, adam-singer (Adam Singer) wrote…

Seems like some error between fixed size vec and stream::iter where the size is encoded into the type signature
Screenshot 2024-06-11 at 1.46.25 PM.png

Done.


nativelink-scheduler/src/scheduler_state/state_manager.rs line 203 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: ditto.

Done.

@adam-singer adam-singer force-pushed the adams/impl-client-state-manager branch from d5a5450 to dcb99fb Compare June 11, 2024 21:34
@adam-singer adam-singer marked this pull request as ready for review June 11, 2024 22:34
Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 7 files at r1, 3 of 3 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 LGTMs obtained

@adam-singer adam-singer force-pushed the adams/impl-client-state-manager branch from dcb99fb to 5941018 Compare June 13, 2024 06:11
Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r4, all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and 1 discussions need to be resolved


-- commits line 2 at r4:
nit: missing title.

@adam-singer adam-singer force-pushed the adams/impl-client-state-manager branch from 5941018 to 76fff1d Compare June 13, 2024 17:56
Copy link
Contributor Author

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Analyze (javascript-typescript), Cargo Dev / ubuntu-22.04, Local / ubuntu-22.04, Vercel, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), pre-commit-checks, ubuntu-20.04 / stable, vale


-- commits line 2 at r4:

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: missing title.

Done.

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Publish image, Publish nativelink-worker-lre-cc

* Implementation of `ClientStateManager` that hides mutations behind a trait for `StateManager`.
* `StateManager` now wraps the `StateManagerImpl` for inner state structure `StateManagerImpl`.
* Mutations will be done on a lock on `inner` in the future.
* Moving implementation code of `add_action` and `filter_operations` into `ClientStateManager` trait.
* Updated accessor code from `state_manager` to `state_manager.inner`.
@adam-singer adam-singer force-pushed the adams/impl-client-state-manager branch from 76fff1d to d0fe36a Compare June 17, 2024 06:13
@adam-singer adam-singer merged commit 49efde2 into TraceMachina:main Jun 17, 2024
28 checks passed
@adam-singer adam-singer deleted the adams/impl-client-state-manager branch June 17, 2024 14:57
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.

Implement ClientStateManager for simple scheduler
2 participants