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

RFC: construct the name to object dicts lazily #535

Merged
merged 4 commits into from
Oct 21, 2018
Merged

Conversation

mlubin
Copy link
Member

@mlubin mlubin commented Oct 11, 2018

Following up on the discussion in jump-dev/JuMP.jl#1402. This change avoids creating the names_to_var dictionary until it's needed.

Using @IainNZ's script that benchmarks variable creation time,

Before:

10^1:  0.000 s, 3981.300000 ns/var, 286 a, 28.600000 a/var
10^2:  0.000 s, 1016.850000 ns/var, 844 a, 8.440000 a/var
10^3:  0.001 s, 703.424000 ns/var, 6756 a, 6.756000 a/var
10^4:  0.007 s, 664.980500 ns/var, 69774 a, 6.977400 a/var
10^5:  0.100 s, 1003.817160 ns/var, 699808 a, 6.998080 a/var
10^6:  1.558 s, 1558.397552 ns/var, 6999859 a, 6.999859 a/var

After:

10^1:  0.000 s, 3638.900000 ns/var, 286 a, 28.600000 a/var
10^2:  0.000 s, 829.310000 ns/var, 838 a, 8.380000 a/var
10^3:  0.001 s, 520.511000 ns/var, 6742 a, 6.742000 a/var
10^4:  0.005 s, 491.230300 ns/var, 69754 a, 6.975400 a/var
10^5:  0.077 s, 766.043240 ns/var, 699776 a, 6.997760 a/var
10^6:  1.005 s, 1004.825593 ns/var, 6999809 a, 6.999809 a/var

so we get the ~0.5 seconds back as predicted.

These results are with an immutable VariableInfo struct (jump-dev/JuMP.jl#1525).

Closes #536

@codecov-io
Copy link

codecov-io commented Oct 12, 2018

Codecov Report

Merging #535 into master will decrease coverage by 0.08%.
The diff coverage is 91.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #535      +/-   ##
==========================================
- Coverage   95.65%   95.56%   -0.09%     
==========================================
  Files          46       46              
  Lines        4692     4712      +20     
==========================================
+ Hits         4488     4503      +15     
- Misses        204      209       +5
Impacted Files Coverage Δ
src/attributes.jl 95.65% <ø> (ø) ⬆️
src/Utilities/universalfallback.jl 99.3% <ø> (ø) ⬆️
src/Utilities/model.jl 99.57% <100%> (-0.43%) ⬇️
src/Test/modellike.jl 98.06% <33.33%> (-1.94%) ⬇️

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 3b59433...f5e0e22. Read the comment docs.

@blegat blegat mentioned this pull request Oct 12, 2018
@mlubin mlubin merged commit e766768 into master Oct 21, 2018
@mlubin mlubin deleted the ml/lazynamedict branch October 21, 2018 16:31
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.

3 participants