JuliaStats / NMF.jl

A Julia package for non-negative matrix factorization
Other
91 stars 34 forks source link

Add precompilation #71

Closed timholy closed 1 year ago

timholy commented 1 year ago

Especially on (the upcoming) Julia 1.9, this greatly reduces TTFX, from >5s to ~10ms on my machine.

Because SnoopPrecompile does not support Julia 0.7, this PR requires that we abandon support for very old Julia versions, and that in turn requires a minor version bump (policy of the General registry). Since this package isn't changing quickly, I recommend taking the leap to 1.0.

See #69 for the test failure. After merging that PR, you can close and reopen this to re-run the tests.

timholy commented 1 year ago

Here's the raw data (on what is effectively Julia nightly):

master:

julia> @time using NMF
  0.175066 seconds (279.97 k allocations: 20.235 MiB, 4.21% compilation time)

julia> X = rand(8, 6);

julia> @time @eval nnmf(X, 4);
  6.783210 seconds (14.65 M allocations: 929.582 MiB, 6.85% gc time, 99.98% compilation time)

This PR:

julia> @time using NMF
  0.468556 seconds (879.66 k allocations: 62.893 MiB, 10.06% gc time, 1.62% compilation time)

julia> X = rand(8, 6);

julia> @time @eval nnmf(X, 4);
  0.010354 seconds (952 allocations: 115.509 KiB, 65.50% compilation time)

So there's a small increase in load time, in exchange for a massive decrease in TTFX.

codecov-commenter commented 1 year ago

Codecov Report

Base: 89.70% // Head: 92.27% // Increases project coverage by +2.56% :tada:

Coverage data is based on head (aa889ce) compared to base (8629a5d). Patch has no changes to coverable lines.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #71 +/- ## ========================================== + Coverage 89.70% 92.27% +2.56% ========================================== Files 10 10 Lines 408 660 +252 ========================================== + Hits 366 609 +243 - Misses 42 51 +9 ``` | [Impacted Files](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats) | Coverage Δ | | |---|---|---| | [src/multupd.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL211bHR1cGQuamw=) | `96.34% <0.00%> (-3.66%)` | :arrow_down: | | [src/projals.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3Byb2phbHMuamw=) | `100.00% <0.00%> (ø)` | | | [src/greedycd.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2dyZWVkeWNkLmps) | `100.00% <0.00%> (ø)` | | | [src/initialization.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2luaXRpYWxpemF0aW9uLmps) | `100.00% <0.00%> (ø)` | | | [src/interf.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2ludGVyZi5qbA==) | `92.85% <0.00%> (+1.19%)` | :arrow_up: | | [src/utils.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3V0aWxzLmps) | `86.84% <0.00%> (+1.65%)` | :arrow_up: | | [src/coorddesc.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2Nvb3JkZGVzYy5qbA==) | `100.00% <0.00%> (+3.03%)` | :arrow_up: | | [src/spa.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3NwYS5qbA==) | `88.88% <0.00%> (+6.53%)` | :arrow_up: | | [src/alspgrad.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2Fsc3BncmFkLmps) | `85.22% <0.00%> (+6.79%)` | :arrow_up: | | [src/common.jl](https://codecov.io/gh/JuliaStats/NMF.jl/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2NvbW1vbi5qbA==) | `72.97% <0.00%> (+7.75%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.