From e2139ac0f8dd81828a2d849f7b0a9e8412fd53af Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Thu, 26 Jan 2023 05:22:59 -0600 Subject: [PATCH] Add precompilation (#71) 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, let's take the leap to 1.0. --- .github/workflows/ci.yml | 2 +- Project.toml | 6 ++++-- src/NMF.jl | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83546bc..889bfc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: version: - - '1.0' + - '1.6' - '1' # automatically expands to the latest stable 1.x release of Julia - nightly os: diff --git a/Project.toml b/Project.toml index 813b087..dd915f8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NMF" uuid = "6ef6ca0d-6ad7-5ff6-b225-e928bfa0a386" license = "MIT" -version = "0.5.3" +version = "1.0.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -9,14 +9,16 @@ NonNegLeastSquares = "b7351bd1-99d9-5c5d-8786-f205a815c4d7" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" RandomizedLinAlg = "0448d7d9-159c-5637-8537-fd72090fea46" +SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" [compat] NonNegLeastSquares = "0.2.0, 0.3.0, 0.4.0" RandomizedLinAlg = "0.1.0" +SnoopPrecompile = "1" StatsBase = "0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33" -julia = "0.7, 1" +julia = "1.6" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/NMF.jl b/src/NMF.jl index a0c45c6..8804d9f 100644 --- a/src/NMF.jl +++ b/src/NMF.jl @@ -22,4 +22,18 @@ module NMF include("interf.jl") + using SnoopPrecompile + + let + @precompile_setup begin + X = rand(8, 6) + @precompile_all_calls begin + for alg in (:multmse, :multdiv, :projals, :alspgrad, :cd, :greedycd) + for init in (:random, :nndsvd, :nndsvda, :nndsvdar, :spa) + nnmf(X, 4, alg=alg, init=init) + end + end + end + end + end end # module