Skip to content

Address feedback from PR #12229 - #12242

Merged
sholderbach merged 3 commits into
nushell:mainfrom
devyn:pr-12229-feedback
Mar 20, 2024
Merged

sholderbach merged 3 commits into
nushell:mainfrom
devyn:pr-12229-feedback

Conversation

@devyn

@devyn devyn commented Mar 19, 2024 •

Copy link
Copy Markdown
Contributor

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

devyn added 2 commits March 19, 2024 15:47
@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.
}

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

use crate::ast::Block;
use crate::Module;

#[cfg(feature = "plugin")]

Copy link
Copy Markdown
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`

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

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
@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.

4 participants