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

Add mechanism to disable creating new worlds #56639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Nov 21, 2024

As a performance optimization, when you are certain only to run all remaining code in a fixed world (e.g. not even eval a new closure or comprehension), such as when all code is defined in a system image and not being used interactively, you can put a call to:

Base.Experimental.disable_new_worlds()

Which will enable performance optimizations around avoiding tracking backedges and invalidations.

As a performance optimization, when you are certain only to run all
remaining code in a fixed world (e.g. not even eval a new closure or
comprehension), such as when all code is defined in a system image and
not being used interactively, you can put a call to:

    Base.Experimental.disable_new_worlds()

Which will enable performance optimizations around avoiding tracking
backedges and invalidations.
Base.Experimental.disable_new_worlds()
Mark that no new worlds (methods additions, deletions, etc) are permitted to be
created, allowing for greater performance and slightly lower memory usage by
Copy link
Member

Choose a reason for hiding this comment

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

Performance here can be elaborated a bit on here I think. Presumably your for loops won't run faster. This has mostly to do with package loading?

Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
created, allowing for greater performance and slightly lower memory usage by
created, allowing for lower latencies and slightly lower memory usage by

Copy link
Member

Choose a reason for hiding this comment

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

Okay, but when do you want to use this? This should have a description of a use case I feel.

@topolarity
Copy link
Member

This also means that you can't load any more code either, is that right?

Folks may not think of using Foo as world-incrementing, but of course it is

"""
Base.Experimental.disable_new_worlds()
Mark that no new worlds (methods additions, deletions, etc) are permitted to be
Copy link
Member

Choose a reason for hiding this comment

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

It's probably worth mentioning that this transition is permanent (if I understand correctly)

@vtjnash
Copy link
Member Author

vtjnash commented Nov 21, 2024

This also means that you can't load any more code either, is that right?

You currently can (though Keno might remove that soon), since defining code isn't a world operation, only adding methods, so the methods won't "take effect" but the loading itself will be successful.

@JeffBezanson
Copy link
Member

JeffBezanson commented Nov 22, 2024

That's neat --- I suppose you could load and use a package that just defines some constants or something. But in practice of course that is not really a requirement in these cases AFAIK.

JL_DLLEXPORT void jl_disable_new_worlds(void)
{
if (jl_generating_output())
jl_error("Disabling Method changes is not possible when generating output.");
Copy link
Member

Choose a reason for hiding this comment

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

But that's the only time I want to do it? 😂 How do you use this to generate "sealed" system images?

@topolarity
Copy link
Member

I think it's more confusing than it is neat.

As a user, I would think it's a bug for Julia to claim to have loaded a package but not have applied its methods to the dispatch table

@JeffBezanson
Copy link
Member

JeffBezanson commented Nov 22, 2024

Yeah no argument there; I don't think there is a real use case. (To clarify: I'm only referring to loading a package that defines methods, but ignoring those methods, as having no use case, not this PR generally.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:latency Compiler latency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants