Skip to content

Remove precompile statements #2643

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

Merged
merged 2 commits into from
Feb 22, 2025
Merged

Remove precompile statements #2643

merged 2 commits into from
Feb 22, 2025

Conversation

odow
Copy link
Member

@odow odow commented Feb 19, 2025

These were once necessary, but now they're doing more harm than good.

The precompile_model functions are safe to replace with a warning because they have no user-visible effect.

Code

using JuMP, HiGHS
model = Model(HiGHS.Optimizer)
set_silent(model)
@variable(model, x >= 0)
@variable(model, 0 <= y <= 3)
@objective(model, Min, 12x + 20y)
@constraint(model, c1, 6x + 8y >= 100)
@constraint(model, c2, 7x + 12y >= 120)
optimize!(model)

Before

(base) oscar@MacBookPro precompile % time julia --project=. main.jl
julia --project=. main.jl  2.73s user 0.45s system 101% cpu 3.119 total
(base) oscar@MacBookPro precompile % time julia --project=. main.jl
julia --project=. main.jl  2.76s user 0.41s system 101% cpu 3.111 total
(base) oscar@MacBookPro precompile % time julia --project=. main.jl
julia --project=. main.jl  2.73s user 0.41s system 102% cpu 3.077 total

This PR

(base) oscar@MacBookPro precompile % time julia --project=. main.jl            
julia --project=. main.jl  2.24s user 0.42s system 101% cpu 2.623 total
(base) oscar@MacBookPro precompile % time julia --project=. main.jl
julia --project=. main.jl  2.24s user 0.37s system 102% cpu 2.560 total
(base) oscar@MacBookPro precompile % time julia --project=. main.jl
julia --project=. main.jl  2.28s user 0.39s system 102% cpu 2.620 total

There are also now better tools like PrecompileTools.jl so that we can actually build and solve problems in each package if needed.

@odow odow requested a review from blegat February 20, 2025 02:12
@blegat
Copy link
Member

blegat commented Feb 20, 2025

JuMP and HiGHS both have precompile statements so that's a bit misleading. Maybe also include benchmarks with pure-MOI and a solver that does not have precompile statemtents

)
MOI.precompile_model(UniversalFallback{Model{T}}, constraints)
MOI.precompile_model(
CachingOptimizer{MOI.AbstractOptimizer,UniversalFallback{Model{T}}},
Copy link
Member Author

Choose a reason for hiding this comment

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

@blegat: we don't build this model anymore in JuMP, so these weren't actually being used.

@odow
Copy link
Member Author

odow commented Feb 20, 2025

Arguably, this could make TTFS slower for new versions of MOI and an old version of Julia like 1.6.

For other solvers: we should improve them (if needed) by adding PrecompileTools to their packages. Not to MOI.

I don't think any package was actually using MOI.Utilities.precompile_model anyway.

@odow
Copy link
Member Author

odow commented Feb 20, 2025

Here's SCS:

Old

julia --project=old scs.jl  13.78s user 0.57s system 100% cpu 14.327 total
julia --project=old scs.jl  13.80s user 0.54s system 100% cpu 14.336 total

New

julia --project=. scs.jl  13.80s user 0.53s system 99% cpu 14.329 total
julia --project=. scs.jl  13.80s user 0.51s system 100% cpu 14.285 total

There's no PrecompileTools, and these existing recompilation statements did not help because we've switched the type that JuMP uses.

I guess the action item in addition to this PR is to add precompilation things to each solver package.

@blegat
Copy link
Member

blegat commented Feb 21, 2025

Arguably, this could make TTFS slower for new versions of MOI and an old version of Julia like 1.6.

I don't think we should be worried about users not using the LTS.

For other solvers: we should improve them (if needed) by adding PrecompileTools to their packages. Not to MOI.

Yes, I just thought it would be useful to get a sense of whether users would notice a regression in the meantime. Looking at your SCS benchmark, it seems fine.

@odow odow merged commit 339d769 into master Feb 22, 2025
16 checks passed
@odow odow deleted the od/rm-precompile branch February 22, 2025 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants