question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sharing values by reference between kernels should be opt-in

See original GitHub issue

Reference sharing isn’t the common case. Most kernels don’t share a process (e.g. JavaScript versus C#) and/or have no values that can helpfully be shared by reference without assuming a specific runtime and language in order to bind data to specific types (e.g. SQL, KQL, HTTP). And even in cases where reference sharing is possible (e.g. between C#, F#, and PowerShell in the default kernel configuration in dotnet-interactive), if the necessary imports and assembly references aren’t in place ahead of time, then the share will fail.

Sharing by reference is useful for some scenarios though, including certain optimizations (reducing serialization and chattiness) and cases where developers want to use kernels directly in process.

For these reasons, #!share, #!set, and other magic commands that dispatch SendValue and RequestValue commands should be made to opt into reference sharing, for example by specifying an option like --by-ref. When this is specified for out-of-proc kernels or kernels that don’t wish to share internal types, the magic command should fail.

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AbhitejJohncommented, Feb 22, 2023

I like the idea of a warning/diagnostic in the product to help with the transition 👍

1reaction
jonsequiturcommented, Feb 22, 2023

Changing this behavior for #!share would most likely be a larger breaking change for more users, and for our samples docs, than is worthwhile.

After some time spent working on #2765, it seems to me more prudent to use the shift to the new #!set command as an opportunity to fix this there. So #!share will continue to share by reference by default, with that being disabled when the --mime-type option is used. #!set on the other hand will require the use of a --byref option to perform reference sharing, with the following resulting in an error:

  • Attempting to use both --mime-type and --byref together.
  • Attempting to share by reference from a proxy kernel.
  • Attempting to share by reference to a proxy kernel.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance of passing structs to kernel by value ...
Hi all, I recently started to use unified memory, because it seems to offer the cleanest way to pass any struct containing device...
Read more >
interactive/docs/variable-sharing.md at main
Another way to share variables between kernels can be found in the Variables View. You can open it by clicking the Variables button...
Read more >
DDD - How to use Shared Kernel with multiple bounded ...
One solution would be to use one large shared kernel. All objects that are used in at least two bounded contexts end up...
Read more >
Sharing Run-Time Parameters Across Multiple Kernels
The run-time parameter to switch channels in the previous graph is shared by ... Both entities need to see the same switched value...
Read more >
The kernel's command-line parameters
The kernel parses parameters from the kernel command line up to “–”; if it doesn't recognize a parameter and it doesn't contain a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found