Skip to content

Commit

Permalink
[perf] various latency improvements (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Dec 16, 2021
1 parent a0f3228 commit 6593aea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Clp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ end

include("MOI_wrapper/MOI_wrapper.jl")

if VERSION > v"1.4.2"
include("precompile.jl")
end

# TODO(odow): remove at Clp.jl v1.0.0.
function ClpSolver(args...; kwargs...)
error(
Expand Down
6 changes: 4 additions & 2 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ function _index_map(
::Type{F},
::Type{S},
) where {F,S}
inner = index_map.con_map[F, S]
for ci in MOI.get(src, MOI.ListOfConstraintIndices{F,S}())
row = MOI.Utilities.rows(src.constraints, ci)
index_map[ci] = MOI.ConstraintIndex{F,S}(row)
inner[ci] = MOI.ConstraintIndex{F,S}(row)
end
return
end
Expand All @@ -279,9 +280,10 @@ function _index_map(
F::Type{MOI.VariableIndex},
::Type{S},
) where {S}
inner = index_map.con_map[F, S]
for ci in MOI.get(src, MOI.ListOfConstraintIndices{F,S}())
col = index_map[MOI.VariableIndex(ci.value)].value
index_map[ci] = MOI.ConstraintIndex{F,S}(col)
inner[ci] = MOI.ConstraintIndex{F,S}(col)
end
return
end
Expand Down
16 changes: 16 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function warmup()
bridge = MOI.instantiate(Optimizer; with_bridge_type=Float64)
no_bridge = MOI.instantiate(Optimizer)
cache = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
MOI.optimize!(bridge, cache)
MOI.optimize!(no_bridge, cache)
return
end

function _precompile_()
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
precompile(warmup, ())
return
end

_precompile_()

0 comments on commit 6593aea

Please sign in to comment.