-
Notifications
You must be signed in to change notification settings - Fork 87
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
[FileFormats.MOF] replace OrderedDict by NamedTuple when writing #2606
Conversation
Could we get some benchmarks? |
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 quite nice
I opened an issue in JuliaFormatter to discuss formatting the named tuples: domluna/JuliaFormatter.jl#895 |
A test using JuMP
model = Model()
@variable(model, x[1:1000] >= 0)
@constraint(model, y[1:1000], sum(i*x[i] for i in 1:1000) == 1)
for i in 1:5
GC.gc()
@time write_to_file(model, "test.mof.json")
end Results: before PR:
after PR:
Which is a big win as there is also the fixed cost of writing the json that both incur. |
Nice nice nice. Note that this could be regarded as technically breaking, but I don't think anyone is using |
Reduction in memory pressure is a big deal for the larger Sienna models. cc @jd-lara this should help your 'always write to MOF' |
should we rename |
Nah leave it for now
…On Fri, 10 Jan 2025, 10:34 am Joaquim Dias Garcia, ***@***.***> wrote:
should we rename moi_to_object to _moi_to_object?
—
Reply to this email directly, view it on GitHub
<#2606 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6MQJOZMWCC44ZMIHOMWH32J3TOVAVCNFSM6AAAAABU466FA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBRGI4DQNRUGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
green light from CI |
"coefficient" => foo.coefficient, | ||
"variable" => name_map[foo.variable], | ||
) | ||
return (coefficient = foo.coefficient, variable = name_map[foo.variable]) |
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 should make such a difference; we were making a new OrderedDict for every single coefficient in the model 😭
@joaquimg do you have a script for the before/after Sienna profile flame graph? |
Is the same script used here (but with PProf): |
All OrderedDicts used are very small. Hence, they allocate unnecessarily. This also creates more GC pressure.