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

move builtin generation logic to precompilation time #139

Merged
merged 4 commits into from Mar 14, 2019
Merged

Conversation

KristofferC
Copy link
Member

The current build system has the problem that if someone adds JuliaInterpreter on two julia versions, the second add will not build JuliaInterpreter (since it is already downloaded and assumed built). This will then give an error when loading it that it misses the file.

Instead, just run this on precompilation time if we cant find the file.

The negative is that we need to load the code for generating the builtin file every time we load the package but from my measurements it is within noise.

@codecov-io
Copy link

codecov-io commented Mar 14, 2019

Codecov Report

Merging #139 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #139   +/-   ##
=====================================
  Coverage       0%     0%           
=====================================
  Files          14     14           
  Lines        1643   1645    +2     
=====================================
- Misses       1643   1645    +2
Impacted Files Coverage Δ
src/JuliaInterpreter.jl 0% <ø> (ø) ⬆️
src/generate_builtins.jl 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a1f50d...fa14f50. Read the comment docs.

Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

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

Very cool, I definitely favor this.

@@ -20,12 +20,22 @@ module CompiledCalls
# This module is for handling intrinsics that must be compiled (llvmcall)
end

const BUILTIN_FILE = joinpath(@__DIR__, "builtins-julia$(Int(VERSION.major)).$(Int(VERSION.minor)).jl")

if !isfile(BUILTIN_FILE)
Copy link
Member

Choose a reason for hiding this comment

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

Should we also check Base.stale_cachefile("generate_builtins.jl", cachefile)? I'm not sure I'm thinking about the logic of this properly, but it seems to make sense to rebuild it if the generator changes.

If possible, it would be lovely to preserve the ability to edit the "builtins-" file for the purposes of debugging. If I'm thinking about it correctly, it seems that checking the mtime on "generate_builtins.jl" but not "builtins-" will preserve that capability.

Copy link
Member Author

Choose a reason for hiding this comment

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

Storing the mtime of generate_builtins.jl and rerun the build script if it changed makes sense.

If possible, it would be lovely to preserve the ability to edit the "builtins-" file for the purposes of debugging.

The changes here shouldn't affect that?

Copy link
Member

Choose a reason for hiding this comment

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

Right, that's what I'm expecting too. But sometimes the chain of dependencies makes my head hurt.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you have to store the mtime, do you? That comparison should be run for you by stale_cachefile.

Copy link
Member

@timholy timholy Mar 14, 2019

Choose a reason for hiding this comment

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

Maybe another approach: put this logic inside a ccall(:jl_generating_output, Cint, ()) == 1 and add the generate_builtins.jl as an include_dependency? If you wanted to get fancy, you could even run it in a separate process, and then generate_builtins.jl would not be part of the cachefile.

Copy link
Member Author

Choose a reason for hiding this comment

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

Something like this then?

@KristofferC KristofferC force-pushed the kc/build branch 2 times, most recently from 5f8cfd8 to eac8c78 Compare March 14, 2019 11:16
@@ -20,12 +20,21 @@ module CompiledCalls
# This module is for handling intrinsics that must be compiled (llvmcall)
end

const BUILTIN_FILE = joinpath(@__DIR__, "builtins-julia$(Int(VERSION.major)).$(Int(VERSION.minor)).jl")

if ccall(:jl_generating_output, Cint, ()) == 1
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this check really needed?

@pfitzseb
Copy link
Member

Hm, I think we'll need a fallback if someone runs Julia with --compiled-modules=no, right? With the current implementation the BUILTIN_FILE would never be generated in that case.

@KristofferC
Copy link
Member Author

Yeah, that was my point with #139 (comment). Should just be able to remove that.

@pfitzseb
Copy link
Member

Hm but then the builtin file would be regenerated every time the module is loaded, which is a safer but more annoying default, no?

@KristofferC
Copy link
Member Author

Yes, every time it is loaded when running with --compiled-modules=no because generate_builtins might have changed.

src/JuliaInterpreter.jl Outdated Show resolved Hide resolved
Co-Authored-By: KristofferC <kristoffer.carlsson@chalmers.se>
@KristofferC KristofferC merged commit 1b844be into master Mar 14, 2019
@KristofferC KristofferC deleted the kc/build branch March 14, 2019 14:42
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.

None yet

4 participants