-
-
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
Fix Pkg.BinaryPlatforms invalidations by moving module to Base #52249
Conversation
base/io.jl
Outdated
|
||
Type unstable wrapper around an IO to avoid specializing write, get, and print | ||
""" | ||
struct UnstableIO <: IO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably beside the point, but this is insufficient to avoid inference inferring these functions on specialized IO. For that you'd need to add an extra inferencebarrier in the UnstableIO constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It worked pretty well in practice. :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Keno, would that look like the following?
struct UnstableIO <: IO
io::IO
UnstableIO(@nospecialize(x)) = new(inferencebarrier(x))
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct also doesn't seem compliant with the IO interface, so I am very reluctant to have this merged into Base. Perhaps make this <: AbstractPipe
might suffice though, as then you get all of the required methods "for free"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an IO
interface? Let me see if I can find it. I'm going to see if I can figure this out quickly. Otherwise, I will separate this into another pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were there no tests in Pkg for these that could be copied over as well?
Is there anything else to do here? Should I split the PR into two parts? |
base/io.jl
Outdated
@@ -1520,3 +1520,17 @@ function countlines(io::IO; eol::AbstractChar='\n') | |||
end | |||
|
|||
countlines(f::AbstractString; eol::AbstractChar = '\n') = open(io->countlines(io, eol = eol), f)::Int | |||
|
|||
# From Pkg.jl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be easier to make Pkg instead use an IOContext{IO}(io), since it has the same implementation as this, without needing to add code to Base just for Pkg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that, but IOContext
has a type parameter indicating the parent type. I thought the objective was to create an abstract inference barrier so as to not force recompilation of Pkg methods for new IO
types.
I'm thinking of splitting the pull request so that we can focus on this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is true of the usual interface, but it is valid for the parameter to be simply IO
also. Someone could make a PR to make that constructor a bit simpler also, as right now it is potentially a bit awkwardly specified as IOContext{IO}(unwrapcontext(io)...)
and does not reliably propagate when making a new IOContext from an existing one with more keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see so I may be able to define the following.
UnstableIO(io:IO) = IOContext{IO}(inferencebarrier(io))
Unless I hear otherwise, I intend to drop the |
Why do we need all the other stuff here too? It seems like if Pkg wants to export something with a similar name that does something different it should export something different, rather than pirating the method from Base or expecting Base to contain that functionality. |
Right now I'm looking for pragmatic steps to take to improve load times of To be fair, it was The code here is a compatability shim because the API changed when this functionality moved from I'm going to invite @staticfloat and @giordano to comment on where the older BinaryPlatforms API is still used and why we need the compatibility shim. |
I proposed an alternative approach is JuliaLang/Pkg.jl#3736 . That change is breaking in that it eliminates the ability to dispatch on the |
FWIW the point of those types was to enable dispatch, which I've personally used extensively, just not in any registered packages. |
I have proposed another alternative in JuliaLang/Pkg.jl#3742 , this time keeping the types. To avoid invalidations, I do not subtype |
Move UnstableIO from Pkg.jl to BaseAddress Pkg.jl invalidations by moving code to Base
JuliaLang/Pkg.jl#3702
Edits
UnstableIO
portion was removed in favor of usingIOContext{IO}
instead: Replace UnstableIO with IOContext{IO} Pkg.jl#3735Base.BinaryPlatforms
came toBase
and its relationship withPkg.BinaryPlatforms
: Move Artifacts and BinaryPlatforms into Base #37320