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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erts: Share external funs globally #7894

Merged
merged 1 commit into from Nov 28, 2023

Conversation

jhogberg
Copy link
Contributor

By storing external funs in a dedicated literal area shared by all modules and keeping a reference to them in the export entry they refer to, they will no longer be tied to the lifetime of the module that created them. make_fun/3 will also use this reference so that dynamic creation of an external fun also results in a shared literal. This opens up for optimizations in, for example, gen_statem where there will no longer be any drawbacks to caching the event function when in state_functions mode.

@jhogberg jhogberg added the team:VM Assigned to OTP team VM label Nov 21, 2023
@jhogberg jhogberg requested a review from bjorng November 21, 2023 13:13
@jhogberg jhogberg self-assigned this Nov 21, 2023
@jhogberg jhogberg force-pushed the john/erts/share-external-funs branch from 70ffd43 to e07698d Compare November 21, 2023 13:22
Copy link
Contributor

github-actions bot commented Nov 21, 2023

CT Test Results

No tests were run for this PR. This is either because the build failed, or the PR is based on a branch without GH actions tests configured.

Results for commit 8d053b0

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@jhogberg jhogberg force-pushed the john/erts/share-external-funs branch 2 times, most recently from 53bdd5d to 5335501 Compare November 21, 2023 14:03
@jhogberg jhogberg added the testing currently being tested, tag is used by OTP internal CI label Nov 22, 2023
@garazdawi
Copy link
Contributor

When are these literal funs garbage collected? When the export entry that they point to is deleted?

@jhogberg
Copy link
Contributor Author

When are these literal funs garbage collected? When the export entry that they point to is deleted?

They have the same lifetime as their respective export entry, which are never deleted at the moment.

By storing external funs in a dedicated literal area shared by
all modules and keeping a reference to them in the export entry
they refer to, they will no longer be tied to the lifetime of
the module that created them. `make_fun/3` will also use this
reference so that dynamic creation of an external fun will also
result in a literal.

Like all other literal optimizations at the moment, this will be
lost when the term is placed into an ordinary ETS table (although
compressed retains it by happenstance), but that is a general
issue for all literals which may be fixed in a later PR.
@jhogberg jhogberg force-pushed the john/erts/share-external-funs branch from cdea7ce to 8d053b0 Compare November 23, 2023 15:54
@jhogberg jhogberg merged commit 1ab00e8 into erlang:master Nov 28, 2023
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants