Repository navigation
Conversation
The sort of constrained variables looked up the start column in a Dict on every comparison. Compute the start columns once and sort by them instead.
|
Analysis by Opus below, it could reproduce the drop of 2 GB of allocation you get, where does it come from ? Why each call is slowEach start_column call is cache.variable_to_column[first(x[1])], which does three things:
So each comparison touches up to 6 random memory locations. With starts::Vector{Int}, a comparison reads two Ints that sit next to each other in one array. Measurements (2M elements)
|
|
It depends on the Julia version. On 1.12.7 and 1.13.4, master's Master's sort allocation reproduces without MOI. On 1.13.4, |
_copy_variables_with_setsorts the constrained variables by their start column, and thebyfunction looks upvariable_to_columnon every comparison. I changed it to compute the start columns once and sort by them. Each variable is in at most one entry ofvariable_cones, so the start columns are distinct, and the order and the result ofcopy_toare unchanged.The variables are collected one set type at a time, so the sort has the most work to do when there is more than one set type:
On Julia 1.13.4 the timed call takes 4.7 s and allocates 3.26 GiB on master, and 1.1 s and 1.0 GiB with this PR. Master's isolated
sort!allocates about 2.3 GiB on Julia 1.12.7 and 1.13.4, and about 15 MiB on 1.11.9.