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

Sync with the plugin garbage collector when setting config #12152

Merged
merged 1 commit into from Mar 12, 2024

Conversation

devyn
Copy link
Contributor

@devyn devyn commented Mar 10, 2024

Description

This causes PersistentPlugin to wait for the plugin garbage collector to actually receive and process its config when setting it in set_gc_config.

The motivation behind doing this is to make setting GC config in scripts more deterministic. Before this change we couldn't really guarantee that the GC could see your config before you started doing other things.

There is a slight cost to performance to doing this - we set config before each plugin call because we don't necessarily know that it reflects what's in $env.config, and now to do that we have to synchronize with the GC thread.

This was probably the cause of spuriously failing tests as mentioned by @sholderbach. Hopefully this fixes it. It might be the case that launching threads on some platforms (or just on a really busy test runner) sometimes takes a significant amount of time.

User-Facing Changes

  • possibly slightly worse performance for plugin calls

Tests + Formatting

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

This causes `PersistentPlugin` to wait for the plugin garbage collector
to actually receive and process its config when setting it in
`set_gc_config`.

The motivation behind doing this is to make setting GC config in scripts
more deterministic. Before this change we couldn't really guarantee that
the GC could see your config before you started doing other things.

There is a slight cost to performance to doing this - we set config
before each plugin call because we don't necessarily know that it
reflects what's in `$env.config`, and now to do that we have to
synchronize with the GC thread.

This was probably the cause of spuriously failing tests as mentioned
by @sholderbach. Hopefully this fixes it. It might be the case that
launching threads on some platforms (or just on a really busy test
runner) sometimes takes a significant amount of time.
@devyn
Copy link
Contributor Author

devyn commented Mar 10, 2024

Oh, wow, it still happened here

@sholderbach
Copy link
Member

What is the verdict on the internal change?

@devyn
Copy link
Contributor Author

devyn commented Mar 11, 2024

I believe this is still a good idea, because you'd expect config changes to take effect immediately in a script. The failing test is not the fault of this PR

@devyn devyn changed the title Sync with the plugin garabage collector when setting config Sync with the plugin garbage collector when setting config Mar 11, 2024
@sholderbach
Copy link
Member

You are the expert on this GC, so let's land it and see how it plays in the wild.

@sholderbach sholderbach merged commit 37a9f21 into nushell:main Mar 12, 2024
11 of 15 checks passed
@hustcer hustcer added this to the v0.92.0 milestone Mar 13, 2024
@devyn devyn deleted the plugin-gc-set-config-sync branch March 15, 2024 00:01
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

3 participants