-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Excise Random from the system image #51432
Conversation
What a beautiful hack!
Why wouldn't that work well for LinearAlgebra? |
We currently need to run Ideally we could express method deletion to precompilation and perform it along side method insertion and not invalidate the method table after loading the package once again. Quoting @vtjnash
But I don't think I have the bandwidth to implement that. |
I happened to discuss this today with @gbaraldi @staticfloat and a few others. The big problems with this approach is that this isn't really compatible with pre-compilation. We discussed whether it would be possible to have a special method marker that causes the runtime to load a pkgimage when something looks at the method (either inference or the runtime). If we pre-declare all methods that the pkgimage is adding to base and use this mechanism for them, I don't think we actually need to bump the world age, so this should be compatible with pre-compilation. Of course, we'd also need a mechanism to prevent the pkgimage from actually adding any methods to base that weren't predeclared, but that seems easy to do. |
Agreed, when I discussed this with @vtjnash he seemed to think that it would suffice to have a method deletion marker, such that the deletion happens before we insert the new methods in the MT. In was also thinking fo a special kind of method that knows to load a different library, but that seems to be a bigger ask. (E.g. what do we do when I would definitely appreciate some help here with the runtime changes, in particular we need to solve this for Linear algebra where the numbers of methods are.many more and the cost of invalidation is much higher. |
I don't really see how that it is different from having the package actually just loaded. It is not like the methods somehow actively do things when you aren't using them, they are just special markers with data that define what things happen when someone actively intentionally looks at them. That is a bit different from the LinAlg situation perhaps, where we almost want an LBT-like approach (lazy blas trampoline) so that you can start with just |
106ff7e
to
fcca55c
Compare
Need to fix that, probably by docs noticing and calling |
070ef3f
to
446a6f7
Compare
@timholy Test failures here are due to @KristofferC https://github.com/JuliaLang/Pkg.jl/blob/b02fb95979c71dc5834aad739ad61622cccf4a16/test/api.jl#L274 assumes that Random is in the system image? I assume deleting that test should be fine? |
@nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. |
Yes, that seems fine. |
7e227cb
to
1b4a194
Compare
I am inclined towards merging this next week to start shaking out issues with this on nightlies. @vtjnash or @JeffBezanson does either of you have time for a review? |
31ccfb6
to
3cbf778
Compare
Given that this has a performance cost for What's the cost of having rand (but just for Xoshiro) in the sysimage? randn does only have 26% overhead over rand, so probably should be kept too (I don't know about the code overhead of it, likely larger but still small). Given that Xoshiro, the default rng is really simple and small (at least for uniform), both its state and the code, is it possible to excise Random partially from the sysimage? I.e. the legacy rng, and all that's not usable before the import, i.e. what's not strictly in Base, but feels like it. I think I'm just proposing moving rand and rand to Base (from Random), and keep leaving the rest e.g. randstring out. I think it would mean you could fully quality as Base.rand as you already can (or not qualify). You can also qualify as Random.rand and it should also be kept, seems simple and not slower. |
b80489b
to
b038633
Compare
…51641) The problem with the `delete_method` in `__init__` approach is that we invalidate the method-table, after we have performed all of the caching work. A package dependent on `Random`, will still see the stub method in Base and thus when we delete the stub, we may invalidate useful work. Instead we delete the methods when Random is being loaded, thus a dependent package only ever sees the method table with all the methods in Random, and non of the stubs methods. The only invalidation that thus may happen are calls to `rand` and `randn` without first doing an `import Random`.
0fc6400
to
923efb9
Compare
I am not really a fan of this solution,
but it does work. Preferably this is something one could
express to the method-table so that instead of doing this at init time
in Random, we do it on at top-level and package loading does the deletion
and addition of methods at the same time.
For Random the current solution might be fine, but for LinearAlgebra we do
need a better mechanism.