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

Make PrecompileTools into a stdlib #50923

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Make PrecompileTools into a stdlib #50923

wants to merge 2 commits into from

Conversation

timholy
Copy link
Sponsor Member

@timholy timholy commented Aug 15, 2023

This makes PrecompileTools an upgradable stdlib.
While it will still live in its own repository, this allows
it to be used by other stdlibs to lower their TTFX
when they migrate out.

This makes PrecompileTools an upgradable stdlib.
While it will still live in its own repository, this allows
it to be used by other stdlibs to lower their TTFX
when they migrate out.
@timholy
Copy link
Sponsor Member Author

timholy commented Aug 15, 2023

After a slack discussion with @KristofferC, we concluded that because we'd also need to make Preferences an upgradable stdlib, it might be better to vendor the ~60LOC needed from PrecompileTools.

@timholy timholy closed this Aug 15, 2023
@timholy timholy deleted the teh/pctools branch August 15, 2023 12:14
@vchuravy
Copy link
Sponsor Member

I think we only didn't make preferences as stdlib, because at the time we hadn't figured out how to make them upgradeable.

@staticfloat and I want to eventually use Preferences for behaviour in Base (but not include Preferences in the sysimg)

@timholy
Copy link
Sponsor Member Author

timholy commented Aug 15, 2023

I'm happy to reopen this if we get to a point where we want it.

@vchuravy
Copy link
Sponsor Member

I now want this :)

@timholy timholy restored the teh/pctools branch September 16, 2023 19:35
@timholy timholy reopened this Sep 16, 2023
@timholy
Copy link
Sponsor Member Author

timholy commented Sep 16, 2023

Back from the dead! But we'll need Preferences before we can merge this, I think.

@KristofferC
Copy link
Sponsor Member

I now want this :)

Why?

But we'll need Preferences before we can merge this, I think.

:(

@vchuravy
Copy link
Sponsor Member

vchuravy commented Sep 16, 2023

I originally thought I would need it for #51350, but I was mistaken.

I can see a use for this when we have a lot of upgradeable stdlibs that don't want to maintain explicit precompile statement lists.

(We could also vendor a Preference free version, but I don't feel to bad about making Preferences an upgradeable stdlib.)

@mkitti
Copy link
Contributor

mkitti commented Sep 30, 2023

Could we move some code from PrecompileTools.jl into Base or Core?

In particular, the ccalls really should be wrapped into a Julia function.

ccall(:jl_generating_output, Cint, ())
ccall(:jl_debug_method_invalidation, Any, (Cint,), 1)

@IanButterworth
Copy link
Sponsor Member

Is there anything stopping us making Preferences.jl and PrecompileTools.jl upgradable stdlibs?

I ask because it would be nice to fix things like this without having every downstream stdlib re-craft workloads that trigger the recompilation.

 inserting print(io::IO, c::Base.AnnotatedChar) @ StyledStrings ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.12/StyledStrings/src/io.jl:281 invalidated:
   backedges: 1: superseding print(io::IO, c::AbstractChar) @ Base char.jl:261 with MethodInstance for print(::IOBuffer, ::Base.AnnotatedChar{Char}) (40 children)
              2: superseding print(io::IO, c::AbstractChar) @ Base char.jl:261 with MethodInstance for print(::IOContext{IOStream}, ::Base.AnnotatedChar{Char}) (82 children)
              3: superseding print(io::IO, c::AbstractChar) @ Base char.jl:261 with MethodInstance for print(::IOContext{IOBuffer}, ::Base.AnnotatedChar{Char}) (309 children)
   3 mt_cache

via the approach

module SomeStdlib

using PrecompileTools
@recompile_invalidations begin
    using StyledStrings and other stdlib deps...
end
...
end

@timholy
Copy link
Sponsor Member Author

timholy commented Sep 13, 2024

@recompile_invalidations should be a last resort---it's intended more for end users who want to easily create effective personal Startup.jl packages than for routine use in packages. Has anyone diagnosed what's being invalidated? Perhaps many of those can be fixed?

@IanButterworth
Copy link
Sponsor Member

The issue seems fundamental with how StyledStrings is split between the stdlib and Base, hence the need to heal rather than fix. JuliaLang/StyledStrings.jl#61

@timholy
Copy link
Sponsor Member Author

timholy commented Sep 16, 2024

Isn't just fixing the piracy the better solution?

@KristofferC
Copy link
Sponsor Member

Jeff doesn't want more cruft in Base. So somehow this "compromise" was made where only part of the AnnotatedString API was moved into Base and part of it (the thing that renders colors etc when an annotated string happens to have those annotations) was left in StyledString.

@IanButterworth
Copy link
Sponsor Member

REPL and Pkg now use the PrecompileTools mechanics
#55782
JuliaLang/Pkg.jl#4024

I'm not sure whether this should be closed, but that's a lot of the latency sensitive UX stuff improved.

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.

5 participants