Skip to content

Replace builtin modules in compiled script#473

Merged
geseq merged 18 commits into
d5:masterfrom
milaboratory:PR-for-upstream
Apr 13, 2026
Merged

Replace builtin modules in compiled script#473
geseq merged 18 commits into
d5:masterfrom
milaboratory:PR-for-upstream

Conversation

@DenKoren

Copy link
Copy Markdown
Contributor

Compiled code can be executed concurrently out of the box thanks to Clone() method of compiled script.

The problem is that custom builtin module, given to the script as a 'dependency' may not support this. Or it may require customisation for each clone to work properly (say, you provide a driver, transaction, connection or whatever else that should be unique for each script).

Inability to update/replace builtin modules inside script after compilation makes it impossible to re-use compiled script and requires compilation for each run.

This PR solves the mentioned limitation by extending compiled script's API.
The change is implemented maintaining backward compatibility with old behaviour, where bytecode was shared across several cloned instances of script.

Bytecode gets copied only when builtin modules need to be replaced after compilation (kind of 'copy-on-write' approach)

@DenKoren DenKoren changed the title Add ability to replace builtin modules in compiled code Replace builtin modules in compiled code Dec 11, 2025
@DenKoren DenKoren changed the title Replace builtin modules in compiled code Replace builtin modules in compiled script Dec 11, 2025
@geseq

geseq commented Dec 13, 2025

Copy link
Copy Markdown
Collaborator

Thanks for the PR. This looks like a good idea overall. On a high level this looks good to me, but will review deeper today/tomorrow.

@d5 can you take a look as well please?

@geseq geseq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM overall

Comment thread script.go Outdated
@DenKoren DenKoren requested a review from geseq April 1, 2026 18:32
@geseq geseq merged commit 70b0e6e into d5:master Apr 13, 2026
1 check passed
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