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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address feedback from PR #12229 #12242

Merged
merged 3 commits into from Mar 20, 2024
Merged

Conversation

devyn
Copy link
Contributor

@devyn devyn commented Mar 19, 2024

Description

@sholderbach left a very helpful review and this just implements the suggestions he made.

Didn't notice any difference in performance, but there could potentially be for a long running Nushell session or one that loads a lot of stuff.

I also caught a bug where nu-protocol won't build without plugin because of the previous conditional import. Oops. Fixed.

User-Facing Changes

blocks and modules type in EngineState changed again. Shouldn't affect plugins or anything else though really

Tests + Formatting

  • 馃煝 toolkit fmt
  • 馃煝 toolkit clippy
  • 馃煝 toolkit test
  • 馃煝 toolkit test stdlib

After Submitting

@sholderbach left a very helpful review and this just implements the
suggestions he made.

Didn't notice any difference in performance, but there could potentially
be for a long running Nushell session or one that loads a lot of stuff.
@@ -967,7 +966,7 @@ impl<'a> StateWorkingSet<'a> {
}
}

for block in &self.permanent_state.blocks {
for block in self.permanent_state.blocks.iter() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I'm not really sure, why are you using iter() here, but removing iter() call on crates/nu-cli/src/completions/completer.rs:L127?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure either! It probably just got caught up in some kind of intermediate change and I meant to change it back.

Copy link
Member

@sholderbach sholderbach left a comment

Choose a reason for hiding this comment

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

Thanks for continuing to work on that!

Don't know if we have diverse enough benchmarks to see if there is a tradeoff for moving the reallocation burden from the clone to the first mutation of the Arc<Vec<T>>s (after the first make_mut it should remain pretty local).
Our looping benchmarks will clone the &EngineState a bunch of times but spend less time modifying and then merging StateDelta

Comment on lines 93 to 94
let block = Arc::make_mut(&mut block);
block.pipelines.drain(..block.pipelines.len() - 1);
Copy link
Member

Choose a reason for hiding this comment

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

Mhh not sure if this really makes it clearer that the block: &mut Arc<Block> in the outside scope now points to that mutated Arc inner. Which is relevant for the eval_block at the end of the function.

Copy link
Member

Choose a reason for hiding this comment

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

I went back to the original order and added a comment.

Comment on lines +198 to +200
if !delta.blocks.is_empty() {
Arc::make_mut(&mut self.blocks).extend(delta.blocks);
}
Copy link
Member

Choose a reason for hiding this comment

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

Good call to elide that inner clone!

@@ -2,7 +2,6 @@ use super::{usage::Usage, Command, EngineState, OverlayFrame, ScopeFrame, Variab
use crate::ast::Block;
use crate::Module;

#[cfg(feature = "plugin")]
Copy link
Member

Choose a reason for hiding this comment

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

Oh, that went under the radar...

mental note: --no-default-features for the often dreamt of nightly extended test suite.

`let block` here is probably more confusing which value gets assigned
the new `Arc`
Copy link
Member

@sholderbach sholderbach left a comment

Choose a reason for hiding this comment

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

Let's go!

@sholderbach sholderbach merged commit fdf7f28 into nushell:main Mar 20, 2024
15 checks passed
@hustcer hustcer added this to the v0.92.0 milestone Mar 21, 2024
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.

None yet

4 participants