From f956d20f1b39e22a5c7aac3c0b5d46a94d8670f6 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Mon, 3 Aug 2020 03:52:45 -0500 Subject: [PATCH] Slim down to SnoopCompile and SnoopCompileCore This will be version 2.0 of SnoopCompile. It excises the bot, which should move to a separate repository. It also merges SnoopCompileAnalysis back into SnoopCompile itself. --- .github/workflows/Documenter.yml | 4 +- .github/workflows/ci.yml | 4 +- .github/workflows/workflow_ci.yml | 157 ------- .gitignore | 2 - Project.toml | 15 +- SnoopCompileAnalysis/LICENSE.md | 22 - SnoopCompileAnalysis/Project.toml | 14 - SnoopCompileAnalysis/README.md | 3 - .../src/SnoopCompileAnalysis.jl | 28 -- SnoopCompileBot/LICENSE.md | 22 - SnoopCompileBot/Project.toml | 26 -- SnoopCompileBot/README.md | 3 - SnoopCompileBot/src/SnoopCompileBot.jl | 182 -------- SnoopCompileBot/src/botutils.jl | 311 ------------- SnoopCompileBot/src/deprecations.jl | 179 ------- SnoopCompileBot/src/precompile_activation.jl | 48 -- SnoopCompileBot/src/precompile_include.jl | 249 ---------- SnoopCompileBot/src/snoop_bench.jl | 169 ------- SnoopCompileBot/src/snoop_bot.jl | 209 --------- .../test/TestPackage0.jl/src/TestPackage0.jl | 8 - .../test/TestPackage1.jl/Project.toml | 11 - .../deps/SnoopCompile/snoop_bench.jl | 5 - .../deps/SnoopCompile/snoop_bot.jl | 4 - .../test/TestPackage1.jl/src/TestPackage1.jl | 7 - .../test/TestPackage1.jl/test/Project.toml | 2 - .../test/TestPackage1.jl/test/runtests.jl | 4 - .../test/TestPackage2.jl/Project.toml | 11 - .../deps/SnoopCompile/snoop_bench.jl | 5 - .../deps/SnoopCompile/snoop_bot.jl | 4 - .../test/TestPackage2.jl/src/TestPackage2.jl | 12 - .../test/TestPackage2.jl/test/Project.toml | 2 - .../test/TestPackage2.jl/test/runtests.jl | 8 - .../test/TestPackage3.jl/Project.toml | 11 - .../deps/SnoopCompile/snoop_bench.jl | 5 - .../deps/SnoopCompile/snoop_bot.jl | 4 - .../test/TestPackage3.jl/src/TestPackage3.jl | 15 - .../test/TestPackage3.jl/test/Project.toml | 2 - .../test/TestPackage3.jl/test/runtests.jl | 10 - .../test/TestPackage4.jl/Project.toml | 11 - .../deps/SnoopCompile/example_script.jl | 5 - .../deps/SnoopCompile/snoop_bench.jl | 6 - .../deps/SnoopCompile/snoop_bot.jl | 9 - .../test/TestPackage4.jl/src/TestPackage4.jl | 7 - .../TestPackage4.jl/src/example_script.jl | 5 - .../.github/workflows/SnoopCompile.yml | 82 ---- .../test/TestPackage5.jl/Project.toml | 11 - .../deps/SnoopCompile/example_script.jl | 0 .../deps/SnoopCompile/snoop_bot.jl | 13 - .../test/TestPackage5.jl/src/TestPackage5.jl | 6 - SnoopCompileBot/test/botutils.jl | 27 -- SnoopCompileBot/test/runtests.jl | 438 ------------------ SnoopCompileCore/Project.toml | 2 +- SnoopCompileCore/src/snoopr.jl | 2 +- docs/make.jl | 4 +- docs/src/bot.md | 191 -------- docs/src/reference.md | 15 - docs/src/snoopr.md | 57 ++- src/SnoopCompile.jl | 38 +- .../src => src}/invalidations.jl | 0 .../src => src}/parcel_snoopc.jl | 2 +- .../src => src}/parcel_snoopi.jl | 0 {SnoopCompileAnalysis/src => src}/write.jl | 0 test/runtests.jl | 3 - utils/dev.jl | 2 - utils/register.jl | 4 +- 65 files changed, 69 insertions(+), 2648 deletions(-) delete mode 100644 .github/workflows/workflow_ci.yml delete mode 100644 SnoopCompileAnalysis/LICENSE.md delete mode 100644 SnoopCompileAnalysis/Project.toml delete mode 100644 SnoopCompileAnalysis/README.md delete mode 100644 SnoopCompileAnalysis/src/SnoopCompileAnalysis.jl delete mode 100644 SnoopCompileBot/LICENSE.md delete mode 100644 SnoopCompileBot/Project.toml delete mode 100644 SnoopCompileBot/README.md delete mode 100644 SnoopCompileBot/src/SnoopCompileBot.jl delete mode 100644 SnoopCompileBot/src/botutils.jl delete mode 100644 SnoopCompileBot/src/deprecations.jl delete mode 100644 SnoopCompileBot/src/precompile_activation.jl delete mode 100644 SnoopCompileBot/src/precompile_include.jl delete mode 100644 SnoopCompileBot/src/snoop_bench.jl delete mode 100644 SnoopCompileBot/src/snoop_bot.jl delete mode 100644 SnoopCompileBot/test/TestPackage0.jl/src/TestPackage0.jl delete mode 100644 SnoopCompileBot/test/TestPackage1.jl/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bench.jl delete mode 100644 SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bot.jl delete mode 100644 SnoopCompileBot/test/TestPackage1.jl/src/TestPackage1.jl delete mode 100644 SnoopCompileBot/test/TestPackage1.jl/test/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage1.jl/test/runtests.jl delete mode 100644 SnoopCompileBot/test/TestPackage2.jl/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bench.jl delete mode 100644 SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bot.jl delete mode 100644 SnoopCompileBot/test/TestPackage2.jl/src/TestPackage2.jl delete mode 100644 SnoopCompileBot/test/TestPackage2.jl/test/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage2.jl/test/runtests.jl delete mode 100644 SnoopCompileBot/test/TestPackage3.jl/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bench.jl delete mode 100644 SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bot.jl delete mode 100644 SnoopCompileBot/test/TestPackage3.jl/src/TestPackage3.jl delete mode 100644 SnoopCompileBot/test/TestPackage3.jl/test/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage3.jl/test/runtests.jl delete mode 100644 SnoopCompileBot/test/TestPackage4.jl/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/example_script.jl delete mode 100644 SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bench.jl delete mode 100644 SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bot.jl delete mode 100644 SnoopCompileBot/test/TestPackage4.jl/src/TestPackage4.jl delete mode 100644 SnoopCompileBot/test/TestPackage4.jl/src/example_script.jl delete mode 100644 SnoopCompileBot/test/TestPackage5.jl/.github/workflows/SnoopCompile.yml delete mode 100644 SnoopCompileBot/test/TestPackage5.jl/Project.toml delete mode 100644 SnoopCompileBot/test/TestPackage5.jl/deps/SnoopCompile/example_script.jl delete mode 100644 SnoopCompileBot/test/TestPackage5.jl/deps/SnoopCompile/snoop_bot.jl delete mode 100644 SnoopCompileBot/test/TestPackage5.jl/src/TestPackage5.jl delete mode 100644 SnoopCompileBot/test/botutils.jl delete mode 100644 SnoopCompileBot/test/runtests.jl delete mode 100644 docs/src/bot.md rename {SnoopCompileAnalysis/src => src}/invalidations.jl (100%) rename {SnoopCompileAnalysis/src => src}/parcel_snoopc.jl (99%) rename {SnoopCompileAnalysis/src => src}/parcel_snoopi.jl (100%) rename {SnoopCompileAnalysis/src => src}/write.jl (100%) diff --git a/.github/workflows/Documenter.yml b/.github/workflows/Documenter.yml index ea823a76c..9d16b2894 100644 --- a/.github/workflows/Documenter.yml +++ b/.github/workflows/Documenter.yml @@ -18,9 +18,7 @@ jobs: - uses: julia-actions/setup-julia@latest with: version: nightly - - run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path="SnoopCompileCore"), - PackageSpec(path="SnoopCompileAnalysis"), - PackageSpec(path="SnoopCompileBot")])' + - run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path="SnoopCompileCore")])' - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-docdeploy@releases/v1 env: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69c730b2d..42ffd8eea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,9 +30,7 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path="SnoopCompileCore"), - PackageSpec(path="SnoopCompileAnalysis"), - PackageSpec(path="SnoopCompileBot")])' + - run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path="SnoopCompileCore")])' - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest diff --git a/.github/workflows/workflow_ci.yml b/.github/workflows/workflow_ci.yml deleted file mode 100644 index 36ea6a50f..000000000 --- a/.github/workflows/workflow_ci.yml +++ /dev/null @@ -1,157 +0,0 @@ -name: workflow_CI -on: - - push - - pull_request -defaults: - run: - shell: bash -jobs: - Simple: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - test_package: - - ./SnoopCompileBot/test/TestPackage1.jl - steps: - - run: | - if [ -z "${{github.head_ref}}" ]; then - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${GITHUB_REF#refs/heads/}\")") - else - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${{ github.head_ref }}\")") - fi - - uses: actions/checkout@v2 - - name: Add SnoopCompileBot - run: | - julia -e 'using Pkg; Pkg.develop( PackageSpec(path="SnoopCompileBot") )' - - name: Install dependencies - working-directory: ${{ matrix.test_package }} - run: | - julia --project -e 'using Pkg; Pkg.instantiate();' - julia -e "using Pkg; Pkg.add($SnoopCompilePackageSpec); Pkg.develop(PackageSpec(; path=pwd())); using SnoopCompile; SnoopCompile.addtestdep();" - - name: Generating precompile files - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bot.jl")' - - name: Running Benchmark - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bench.jl")' - - MultiOS: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - windows-latest - test_package: - - ./SnoopCompileBot/test/TestPackage2.jl - steps: - - run: | - if [ -z "${{github.head_ref}}" ]; then - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${GITHUB_REF#refs/heads/}\")") - else - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${{ github.head_ref }}\")") - fi - - uses: actions/checkout@v2 - - name: Add SnoopCompileBot - run: | - julia -e 'using Pkg; Pkg.develop( PackageSpec(path="SnoopCompileBot") )' - - name: Install dependencies - working-directory: ${{ matrix.test_package }} - run: | - julia --project -e 'using Pkg; Pkg.instantiate();' - julia -e "using Pkg; Pkg.add($SnoopCompilePackageSpec); Pkg.develop(PackageSpec(; path=pwd())); using SnoopCompile; SnoopCompile.addtestdep();" - - name: Generating precompile files - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bot.jl")' - - name: Running Benchmark - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bench.jl")' - - - MultiVersion: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - '1.0.5' # WARNING: this fails - - '1.2' - - '1.4.2' - test_package: - - ./SnoopCompileBot/test/TestPackage3.jl - steps: - - run: | - if [ -z "${{github.head_ref}}" ]; then - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${GITHUB_REF#refs/heads/}\")") - else - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${{ github.head_ref }}\")") - fi - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.version }} - - name: Add SnoopCompileBot - run: | - julia -e 'using Pkg; Pkg.develop( PackageSpec(path="SnoopCompileBot") )' - - name: Install dependencies - working-directory: ${{ matrix.test_package }} - run: | - julia --project -e 'using Pkg; Pkg.instantiate();' - julia -e "using Pkg; Pkg.add($SnoopCompilePackageSpec); Pkg.develop(PackageSpec(; path=pwd())); using SnoopCompile; SnoopCompile.addtestdep();" - - name: Generating precompile files - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bot.jl")' - - name: Running Benchmark - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bench.jl")' - - Presplit_Compatibility: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - version: - - '1.0.5' - - '1.2' - - '1.4.2' - os: - - ubuntu-latest - - windows-latest - test_package: - - ./SnoopCompileBot/test/TestPackage4.jl - steps: - - run: | - if [ -z "${{github.head_ref}}" ]; then - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${GITHUB_REF#refs/heads/}\")") - else - echo ::set-env name=SnoopCompilePackageSpec::$(echo "PackageSpec(url = \"https://github.com/${{github.actor}}/SnoopCompile.jl\", rev = \"${{ github.head_ref }}\")") - fi - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.version }} - - name: Install dependencies - working-directory: ${{ matrix.test_package }} - run: | - julia --project -e 'using Pkg; Pkg.instantiate();' - julia -e "using Pkg; Pkg.add($SnoopCompilePackageSpec); Pkg.develop(PackageSpec(; path=pwd())); using SnoopCompile; SnoopCompile.addtestdep();" - - name: Generating precompile files - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bot.jl")' - - name: Running Benchmark - working-directory: ${{ matrix.test_package }} - run: julia --project -e 'include("deps/SnoopCompile/snoop_bench.jl")' - - - Skip: - if: "contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ubuntu-latest - steps: - - name: Skip CI 🚫 - run: echo skip ci diff --git a/.gitignore b/.gitignore index 3e3a8f217..3f02ca741 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,3 @@ *.jl.*.cov *.jl.mem Manifest.toml -SnoopCompileBot/test/*/deps/SnoopCompile/precompile/* -SnoopCompileBot/test/*/src/precompile_includer.jl diff --git a/Project.toml b/Project.toml index d2260d0f3..7f709e7b5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,19 +1,19 @@ name = "SnoopCompile" uuid = "aa65fe97-06da-5843-b5b1-d5d13cad87d2" author = ["Tim Holy "] -version = "1.7.2" +version = "2.0.0" [deps] +Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f" +OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" -SnoopCompileAnalysis = "9ea4277c-da97-4c3a-afb0-537c066769de" -SnoopCompileBot = "1d5e0e55-7d74-4714-b8d8-efa80e938cf7" SnoopCompileCore = "e2b509da-e806-4183-be48-004708413034" [compat] -SnoopCompileAnalysis = "~1.7.2" -SnoopCompileBot = "~1.7.2" -SnoopCompileCore = "~1.7.2" +Cthulhu = "1.2" +OrderedCollections = "1" +SnoopCompileCore = "~2.0.0" julia = "1" [extras] @@ -22,11 +22,10 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JLD = "4138dd39-2aa7-5051-a626-17a0bb65d9c8" -MatLang = "05b439c0-bb3c-11e9-1d8d-1f0a9ebca87a" MethodAnalysis = "85b6ec6f-f7df-4429-9514-a64bcd9ee824" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["ColorTypes", "Documenter", "FixedPointNumbers", "InteractiveUtils", "JLD", "MatLang", "MethodAnalysis", "Pkg", "SparseArrays", "Test"] +test = ["ColorTypes", "Documenter", "FixedPointNumbers", "InteractiveUtils", "JLD", "MethodAnalysis", "Pkg", "SparseArrays", "Test"] diff --git a/SnoopCompileAnalysis/LICENSE.md b/SnoopCompileAnalysis/LICENSE.md deleted file mode 100644 index 3722d9aaa..000000000 --- a/SnoopCompileAnalysis/LICENSE.md +++ /dev/null @@ -1,22 +0,0 @@ -The SnoopCompile.jl package is licensed under the MIT "Expat" License: - -> Copyright (c) 2015: Tim Holy. -> -> Permission is hereby granted, free of charge, to any person obtaining -> a copy of this software and associated documentation files (the -> "Software"), to deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, merge, publish, -> distribute, sublicense, and/or sell copies of the Software, and to -> permit persons to whom the Software is furnished to do so, subject to -> the following conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/SnoopCompileAnalysis/Project.toml b/SnoopCompileAnalysis/Project.toml deleted file mode 100644 index e1e05375b..000000000 --- a/SnoopCompileAnalysis/Project.toml +++ /dev/null @@ -1,14 +0,0 @@ -name = "SnoopCompileAnalysis" -uuid = "9ea4277c-da97-4c3a-afb0-537c066769de" -author = ["Tim Holy "] -version = "1.7.2" - -[deps] -Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f" -OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[compat] -Cthulhu = "1.2" -OrderedCollections = "1" -julia = "1" diff --git a/SnoopCompileAnalysis/README.md b/SnoopCompileAnalysis/README.md deleted file mode 100644 index 4da2bba11..000000000 --- a/SnoopCompileAnalysis/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# SnoopCompileAnalysis - -SnoopCompileAnalysis is a component of [SnoopCompile](https://github.com/timholy/SnoopCompile.jl). diff --git a/SnoopCompileAnalysis/src/SnoopCompileAnalysis.jl b/SnoopCompileAnalysis/src/SnoopCompileAnalysis.jl deleted file mode 100644 index fd35cd6d4..000000000 --- a/SnoopCompileAnalysis/src/SnoopCompileAnalysis.jl +++ /dev/null @@ -1,28 +0,0 @@ -module SnoopCompileAnalysis - -using Core: MethodInstance, CodeInfo -using Serialization, OrderedCollections - -# Parcel Regex -const anonrex = r"#{1,2}\d+#{1,2}\d+" # detect anonymous functions -const kwrex = r"^#kw##(.*)$|^#([^#]*)##kw$" # detect keyword-supplying functions -const kwbodyrex = r"^##(\w[^#]*)#\d+" # detect keyword body methods -const genrex = r"^##s\d+#\d+$" # detect generators for @generated functions -const innerrex = r"^#[^#]+#\d+" # detect inner functions - -# Parcel -include("parcel_snoopc.jl") - -if VERSION >= v"1.2.0-DEV.573" - include("parcel_snoopi.jl") -end - -if VERSION >= v"1.6.0-DEV.154" - include("invalidations.jl") -end - -# Write -include("write.jl") - - -end # module diff --git a/SnoopCompileBot/LICENSE.md b/SnoopCompileBot/LICENSE.md deleted file mode 100644 index bee3f3c25..000000000 --- a/SnoopCompileBot/LICENSE.md +++ /dev/null @@ -1,22 +0,0 @@ -The SnoopCompile.jl package is licensed under the MIT "Expat" License: - -> Copyright (c) 2020: Amin Yahyaabadi -> -> Permission is hereby granted, free of charge, to any person obtaining -> a copy of this software and associated documentation files (the -> "Software"), to deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, merge, publish, -> distribute, sublicense, and/or sell copies of the Software, and to -> permit persons to whom the Software is furnished to do so, subject to -> the following conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/SnoopCompileBot/Project.toml b/SnoopCompileBot/Project.toml deleted file mode 100644 index c72c68404..000000000 --- a/SnoopCompileBot/Project.toml +++ /dev/null @@ -1,26 +0,0 @@ -name = "SnoopCompileBot" -uuid = "1d5e0e55-7d74-4714-b8d8-efa80e938cf7" -author = ["Amin Yahyaabadi "] -version = "1.7.2" - -[deps] -FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" -SnoopCompileAnalysis = "9ea4277c-da97-4c3a-afb0-537c066769de" -SnoopCompileCore = "e2b509da-e806-4183-be48-004708413034" - -[compat] -FilePathsBase = "0.9" -SnoopCompileAnalysis = "~1.7.2" -SnoopCompileCore = "~1.7.2" -YAML = "0.4" -julia = "1" - -[extras] -MatLang = "05b439c0-bb3c-11e9-1d8d-1f0a9ebca87a" # only for pathof_noload -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Pkg", "Test", "MatLang"] diff --git a/SnoopCompileBot/README.md b/SnoopCompileBot/README.md deleted file mode 100644 index 5ce705711..000000000 --- a/SnoopCompileBot/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# SnoopCompileBot - -SnoopCompileBot is a component of [SnoopCompile](https://github.com/timholy/SnoopCompile.jl). diff --git a/SnoopCompileBot/src/SnoopCompileBot.jl b/SnoopCompileBot/src/SnoopCompileBot.jl deleted file mode 100644 index d7f00542d..000000000 --- a/SnoopCompileBot/src/SnoopCompileBot.jl +++ /dev/null @@ -1,182 +0,0 @@ -module SnoopCompileBot - -export BotConfig, snoop_bot, snoop_bench - -using Core: MethodInstance, CodeInfo -using YAML - -if VERSION <= v"1.1" - isnothing(x) = x === nothing -end -if VERSION <= v"1.2" - Base.print(io, ::Nothing) = Base.print(io, "") - Base.print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Nothing) = Base.print(io, "") - Base.string(::Nothing) = "" -end - -################################################################ -const UStrings = Union{AbstractString,Regex,AbstractChar} - -""" - BotConfig(package_name::AbstractString ; exclusions, os, else_os, version, else_version, package_path, precompiles_rootpath, subst, tmin) - -Construct a SnoopCompile bot configuration. `package_name` is the name of the package. This object is passed to [`snoop_bot`](@ref) -and [`snoop_bench`](@ref). - -You may supply the following optional **keyword** arguments: - -- `exclusions` : A vector of of Strings (or RegExp) to exclude some functions from being precompiled - -- `os`: A vector of of Strings (or RegExp) to support with precompile statements. - -Example: `os = ["windows", "linux"]` - -- `else_os`: If you want to use a specific operating system's precompile file as the default, - set `else_os` to the name of that os. - Not passing this argument skips precompilation on any operating system other than those - explicitly listed in `os`. - -Example: `else_os = "linux"` - -- `version`: A vector of of Julia versions used to generate precompile signatures. - -Example: `version = [v"1.1", v"1.4.2", "nightly"]` - -It is assumed that the generated precompile signatures are valid for patch versions of Julia (e.g. giving v"1.4.2" supports v"1.4.0" to v"1.4.9"). - -- `else_version`: the Julia version used to generate the default signatures for other `version`s. -Not passing this argument skips precompilation on any Julia version other than those explicitly listed in `version`. - -Example: `else_version = v"1.4.2"` - -- `yml_path`: instead of directly passing `os` and `version` to BotConfig, you can pass `yml_path` which should be the GitHub actions YAML path or file name. -It assumes that the job name is `SnoopCompile`. - -Example: `yaml_path = "SnoopCompile.yml"` - -- `package_path`: path to the main `.jl` file of the package (similar to `pathof`). - Default path is `pathof_noload(package_name)`. - -- `precompiles_rootpath`: the path where precompile files are stored. - Default path is "\$(dirname(dirname(package_path)))/deps/SnoopCompile/precompile". - -- `subst` : A vector of pairs of Strings (or RegExp) to replace a packages precompile statements - with another's package like `["ImageTest" => "Images"]`. - -- `tmin`: Methods that take less time than `tmin` to be inferred will not be added to the - precompile statements. Defaults to 0. - -- `check_eval`: By default, the bot discards the precompile statements that cannot be `eval`ed. - -In rare cases (when snooping is very time consuming), you may want to do this manually by using the printed errors to add the problematic functions to `exclusions` and then set `check_eval=false` for the future runs. - - -# Example -```julia -botconfig1 = BotConfig( - "Zygote"; # package name (the one this configuration lives in) - os = ["linux", "windows", "macos"], # operating systems for which to precompile - version = [v"1.4.2", v"1.3.1"], # supported Julia versions - exclusions = ["SqEuclidean"], # exclude functions (by name) that would be problematic if precompiled -) - -botconfig2 = BotConfig( - "Zygote"; # package name (the one this configuration lives in) - yml_path = "SnoopCompile.yml" # parse `os` and `version` from `SnoopCompile.yml` - exclusions = ["SqEuclidean"], # exclude functions (by name) that would be problematic if precompiled -) - -# A full example: -BotConfig("MatLang", exclusions = ["badfunction"], os = ["linux", "windows", "macos"], else_os = "linux", version = ["1.4.2", "1.2", "1.0.5"], else_version = "1.4.2" ) - -# Different examples for other possibilities: -BotConfig("MatLang") - -BotConfig("MatLang", exclusions = ["badfunction"]) - -BotConfig("MatLang", os = ["linux", "windows"]) - -BotConfig("MatLang", os = ["windows", "linux"], else_os = "linux") - -BotConfig("MatLang", version = [v"1.1", v"1.4.2"]) - -BotConfig("MatLang", version = [v"1.1", v"1.4.2"], else_version = v"1.4.2") - -BotConfig("MatLang", os = ["linux", "windows"], version = [v"1.1", v"1.4.2"]) -``` -""" -struct BotConfig - package_name::AbstractString - exclusions::Vector{UStrings} - check_eval::Bool - os::Union{Vector{String}, Nothing} - else_os::Union{String, Nothing} - version::Union{Vector{VersionNumber}, Nothing} - else_version::Union{VersionNumber, Nothing} - package_path::AbstractString - precompiles_rootpath::AbstractString - subst::Vector{Pair{UStrings, UStrings}} - tmin::AbstractFloat -end - -function BotConfig( - package_name::AbstractString; - exclusions::AbstractVector = String[], - check_eval::Bool = true, - os::Union{Vector{String}, Nothing} = nothing, - else_os::Union{String, Nothing} = nothing, - version::Union{Vector{<:Union{VersionNumber,String}}, Nothing} = nothing, - else_version::Union{VersionNumber, String, Nothing} = nothing, - package_path::AbstractString = pathof_noload(package_name), - precompiles_rootpath::AbstractString = "$(dirname(dirname(package_path)))/deps/SnoopCompile/precompile", - subst::AbstractVector = Vector{Pair{UStrings, UStrings}}(), - tmin::AbstractFloat = 0.0, - yml_path::Union{String, Nothing} = nothing, - blacklist = nothing # deprecated keyword - ) - - if blacklist !== nothing - Base.depwarn("`blacklist` is deprecated, please use `exclusions` to pass a list of excluded names", :BotConfig) - append!(exclusions, blacklist) - end - - # Parse os and version from the yaml file - if !isnothing(yml_path) - package_root_path = dirname(dirname(package_path)) - yml_path = searchdirsboth([ pwd(), package_root_path, "$package_root_path/.github/workflows/"], yml_path) - if !isfile(yml_path) - error("$yml_path not found") - end - - # TODO This can be an option - workflow_job = "SnoopCompile" - - yml = YAML.load_file(yml_path) - matrix = yml["jobs"][workflow_job]["strategy"]["matrix"] - if haskey(matrix, "os") - os = matrix["os"] - end - if haskey(matrix, "version") - version = matrix["version"] - end - end - - if !isnothing(version) - version = JuliaVersionNumber.(version) - end - if !isnothing(else_version) - else_version = JuliaVersionNumber(else_version) - end - - return BotConfig(package_name, exclusions, check_eval, os, else_os, version, else_version, GoodPath(package_path), GoodPath(precompiles_rootpath), subst, tmin) -end - -include("botutils.jl") -include("precompile_include.jl") -include("precompile_activation.jl") -include("snoop_bot.jl") -include("snoop_bench.jl") -include("deprecations.jl") - - -end # module diff --git a/SnoopCompileBot/src/botutils.jl b/SnoopCompileBot/src/botutils.jl deleted file mode 100644 index 04bc34a67..000000000 --- a/SnoopCompileBot/src/botutils.jl +++ /dev/null @@ -1,311 +0,0 @@ -export timesum -################################################################ -""" - timesum(snoop::Vector{Tuple{Float64, Core.MethodInstance}}, unit = :s) - -Calculates the total time measured by a snoop macro. `unit` can be :s or :ms. - -# Examples -```julia -using SnoopCompile -data = @snoopi begin - using MatLang - MatLang_rootpath = dirname(dirname(pathof("MatLang"))) - - include("\$MatLang_rootpath/test/runtests.jl") -end -println(timesum(data, :ms)) -``` -""" -function timesum(snoop::Vector{Tuple{Float64, Core.MethodInstance}}, unit::Symbol = :s) - if isempty(snoop) - t = 0.0 - else - t = sum(first, snoop) - end - if unit == :s - t = round(t, digits = 6) - elseif unit == :ms - t = round(t * 1000, digits = 3) - else - throw(ArgumentError("unit should be `:s` or `:ms`")) - end - return t -end -################################################################ -""" - os_string, os_func = detectOS() - -Returns Operating System of a machine as a string and a function `os_func()` that will return -`true` on the current OS. - -# Examples -```julia -julia> detectOS() -("windows", Base.Sys.iswindows) -``` -""" -function detectOS() -allos_funs = [ - Sys.iswindows, - Sys.isapple, - Sys.islinux, - Sys.isbsd] - if VERSION >= v"1.1" - allos_funs = [allos_funs..., - Sys.isdragonfly, - Sys.isfreebsd, - Sys.isnetbsd, - Sys.isopenbsd] - end - if VERSION >= v"1.2" - push!(allos_funs, Sys.isjsvm) - end - - os = "" - osfun = allos_funs[1] # temp - for osfun in allos_funs - if osfun() - os = split(string(osfun), '.')[end][3:end] - return os, osfun - end - end - @error "os is not detected" -end -################################################################ -""" - standardize_osname(input::String) - standardize_osname(inputs::Vector{String}) - -Standardize different names from Github actions, Travis, etc - -https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources - -# Examples -```jldoctest; setup=:(using SnoopCompile) -julia> SnoopCompile.standardize_osname("ubuntu-latest") -"linux" - -julia> SnoopCompile.standardize_osname(["ubuntu-latest", "macos-latest"]) -2-element Array{String,1}: - "linux" - "apple" -``` -""" -function standardize_osname(input::String) - for (key, standard) in OS_MAP - if occursin(key, input) - input = standard - end - end - return input -end -standardize_osname(inputs::Vector{String}) = standardize_osname.(inputs) -standardize_osname(input::Nothing) = input - -const OS_MAP = Dict( - "macos" => "apple", - "mac" => "apple", - "osx" => "apple", - "apple" => "apple", - "ubuntu" => "linux", - "linux" => "linux", - "win" => "windows", - "windows" => "windows", -) -################################################################ - -using FilePathsBase - -export GoodPath -# to convert WindowsPath before they get inside the SnoopCompile code -# GoodPath(inp::String) = inp |> Path |> _GoodPath |> string -# _GoodPath(path::WindowsPath) = PosixPath((path.drive, path.segments...)) -# _GoodPath(path) = path -GoodPath(x::String) = replace(x, "\\" => "/") # doesn't remove / from the end of the strings -goodjoinpath(args...) = GoodPath(joinpath(args...)) - -################################################################ -""" - searchdir(rootpath::String, pattern::AbstractString) -a function to search a directory. -```julia -julia> searchdir("src", "/bot.jl") -1-element Array{String,1}: - "src/bot.jl" -``` -""" -function searchdir(rootpath::String, pattern::AbstractString) - found_files = String[] - for file in walkpath(Path(rootpath)) - if occursin(pattern, GoodPath(string(file))) - push!(found_files, GoodPath(string(file))) - end - end - return found_files -end - -""" -Searches for the file rather a path. -""" -searchdirfile(rootpath::String, file::AbstractString) = searchdir(rootpath, string(Path(file).segments[end])) - -""" - searchdirs(rootpaths::Array{String}, pattern::AbstractString) - -a function to search multiple directories. - -```julia -julia> searchdirs(["./src", "./test"], "/bot.jl") -2-element Array{String,1}: - "./src/bot.jl" - "./test/bot/bot.jl" -``` -""" -function searchdirs(rootpaths::Array{String}, pattern::AbstractString) - unique( - reduce(vcat, - searchdir.(rootpaths, pattern) - ) - ) -end - -""" -Searches for the file rather a path. -""" -searchdirsfile(rootpaths::Array{String}, file::AbstractString) = searchdirs(rootpaths, basename(file)) - -""" -search for the script! - needed because of confusing paths when referencing pattern_or_file in CI -""" -function searchdirsboth(rootpaths::Array{String}, pattern_or_file::AbstractString) - if isfile(pattern_or_file) - return pattern_or_file - elseif isfile("../../$pattern_or_file") # if in deps/SnoopCompile - return "../../$pattern_or_file" - else - found_files = searchdirs(rootpaths, pattern_or_file) - if length(found_files) === 0 - found_files = searchdirsfile(rootpaths, pattern_or_file) - if length(found_files) === 0 - @error "Couldn't find $(pattern_or_file)" - elseif length(found_files) > 1 - @error "Multiple $(pattern_or_file) exists at the current directory." - else - pattern_or_file = found_files[1] - end - elseif length(found_files) > 1 - @error "Multiple $(pattern_or_file) exists at the current directory." - else - pattern_or_file = found_files[1] - end - end - return pattern_or_file -end -################################################################ - -export pathof_noload - -""" -Returns a package's path without loading the package in the main Julia process. -May launch a separate Julia process to find the package. - -# Examples -```julia -pathof_noload("MatLang") -``` -""" -function pathof_noload(package_name::String) - path = Base.find_package(package_name) - if isnothing(path) - cmd = "import $package_name; print(pathof($package_name))" - try - path = Base.read(`julia -e $cmd`, String) - return GoodPath(path) - catch - try - path = Base.read(`julia --project=@. -e $cmd`, String) - return GoodPath(path) - catch - @error "Couldn't find the path of $package_name" - end - end - else - return GoodPath(path) - end -end - -################################################################ - -import Pkg -""" -Should be removed once Pkg allows adding test dependencies to the current environment - -Used in Github Action workflow yaml file -""" -function addtestdep() - - if isfile("test/Test.toml") - toml = Pkg.TOML.parsefile("test/Test.toml") - test_deps = get(toml, "deps", nothing) - elseif isfile("test/Project.toml") - toml = Pkg.TOML.parsefile("test/Project.toml") - test_deps = get(toml, "deps", nothing) - else - toml = Pkg.TOML.parsefile("Project.toml") - test_deps = get(toml, "extras", nothing) - end - - if !isnothing(test_deps) - for (name, uuid) in test_deps - Pkg.add(Pkg.PackageSpec(name = name, uuid = uuid)) - end - end -end - -################################################################ -""" -Get the float version from semver version -``` -julia> VersionFloat(v"1.4.2") -"1.4" -``` -""" -VersionFloat(v::VersionNumber) = join(split(string(v),'.')[1:2],'.') - -# https://github.com/JuliaLang/julia/pull/36223: -""" - JuliaVersionNumber(v::String) - JuliaVersionNumber(v::VersionNumber) -returns the Julia version number by following the same specifications as VersionNumber. -`JuliaVersionNumber` will fetch the latest nightly version number if `"nightly"` or `"latest"` is given as the input. -# Examples -```julia -julia> SnoopCompile.JuliaVersionNumber("nightly") -v"1.6.0-DEV" -``` -```jldoctest; setup=:(using SnoopCompile) -julia> SnoopCompile.JuliaVersionNumber("1.2.3") -v"1.2.3" -julia> SnoopCompile.JuliaVersionNumber(v"1.2.3") -v"1.2.3" -``` -""" -JuliaVersionNumber(v::VersionNumber) = v -function JuliaVersionNumber(v::String) - if in(v, ["nightly", "latest"]) - version_path = download( - "https://raw.githubusercontent.com/JuliaLang/julia/master/VERSION", - joinpath(tempdir(), "VERSION.txt"), - ) - version_str = replace(Base.read(version_path, String), "\n" => "") - return VersionNumber(version_str) - else - return VersionNumber(v) - end -end - -################################################################ -# TODO we need to remove begin and end manually -# https://github.com/timholy/SnoopCompile.jl/pull/98#issuecomment-645969610 -toplevel_string(expr::Expr) = replace(string(expr), r"^begin([\s\S]*)end$"=>s"\1") diff --git a/SnoopCompileBot/src/deprecations.jl b/SnoopCompileBot/src/deprecations.jl deleted file mode 100644 index 31cad4b22..000000000 --- a/SnoopCompileBot/src/deprecations.jl +++ /dev/null @@ -1,179 +0,0 @@ -export @snoopi_bot, @snoopi_bench - -""" - @snoopi_bot config::BotConfig snoop_script::Expr - @snoopi_bot config::BotConfig - -!!! warning - This macro isn't recommend. Use the function form instead: `snoopi_bot(config::BotConfig, path_to_example_script::String)`. - -# Examples -```julia -using SnoopCompile - - -@snoopi_bot BotConfig("MatLang") begin - using MatLang - MatLang_rootpath = dirname(dirname(pathof("MatLang"))) - - include("\$MatLang_rootpath/examples/Language_Fundamentals/usage_Matrices_and_Arrays.jl") - include("\$MatLang_rootpath/examples/Language_Fundamentals/Data_Types/usage_Numeric_Types.jl") -end -``` -""" -macro snoopi_bot(configExpr, snoop_script::Expr) - Base.depwarn("This macro isn't recommend. Use the function form instead: `snoopi_bot(config::BotConfig, path_to_example_script::String)`.", Symbol("@snoopi_bot")) - config = eval(configExpr) - out = _snoopi_bot(config, snoop_script, __module__) - return out -end - -macro snoopi_bot(package_name::String, snoop_script::Expr) - Base.depwarn("This macro isn't recommend. Use the function form instead: `snoopi_bot(config::BotConfig, path_to_example_script::String)`.", Symbol("@snoopi_bot")) - - f, l = __source__.file, __source__.line - @warn "Replace `\"$package_name\"` with `BotConfig(\"$package_name\")`. That syntax will be deprecated in future versions. \n Happens at $f:$l" - - config = BotConfig(package_name) - out = _snoopi_bot(config, snoop_script, __module__) - return out -end - -""" - @snoopi_bot config::BotConfig - -!!! warning - This macro isn't recommend. Use the function form instead: `snoopi_bot(config::BotConfig)`. - -Ues tests for snooping: -```julia -@snoopi_bot BotConfig("MatLang") -``` -""" -macro snoopi_bot(configExpr) - Base.depwarn("This macro isn't recommend. Use the function form instead: `snoopi_bot(config::BotConfig)`.", Symbol("@snoopi_bot")) - - config = eval(configExpr) - out = _snoopi_bot(config, __module__) - return out -end - -macro snoopi_bot(package_name::String) - f, l = __source__.file, __source__.line - Base.depwarn("This macro isn't recommend. Use the function form instead: `snoopi_bot(config::BotConfig)`.", Symbol("@snoopi_bot")) - - @warn "Replace `\"$package_name\"` with `BotConfig(\"$package_name\")`. That syntax will be deprecated in future versions. \n Happens at $f:$l" - - config = BotConfig(package_name) - out = _snoopi_bot(config, __module__) - return out -end - -################################################################ -################################################################ -""" - @snoopi_bench botconfig::BotConfig, snoop_script::Expr - - -!!! warning - This method isn't recommend. Use `snoopi_bench(config::BotConfig, path_to_example_script::String)` instead. - -# Examples -Benchmarking the load infer time -```julia -using SnoopCompile - -println("loading infer benchmark") -@snoopi_bench BotConfig("MatLang") begin - using MatLang -end -``` - -Benchmarking the example infer time -```julia -SnoopCompile - -println("examples infer benchmark") -@snoopi_bench BotConfig("MatLang") begin - using MatLang - MatLang_rootpath = dirname(dirname(pathof("MatLang"))) - - include("\$MatLang_rootpath/examples/Language_Fundamentals/usage_Matrices_and_Arrays.jl") - include("\$MatLang_rootpath/examples/Language_Fundamentals/Data_Types/usage_Numeric_Types.jl") -end -``` -""" -macro snoopi_bench(configExpr, snoop_script) - Base.depwarn("This method isn't recommend. Use `snoop_bench(config::BotConfig, path_to_example_script::String)` instead.", Symbol("@snoopi_bench")) - - config = eval(configExpr) - out = _snoopi_bench_cmd(config, snoop_script, __module__) - return out -end - -macro snoopi_bench(package_name::AbstractString, snoop_script) - Base.depwarn("This method isn't recommend. Use `snoop_bench(config::BotConfig, path_to_example_script::String)` instead.", Symbol("@snoopi_bench")) - - f, l = __source__.file, __source__.line - @warn "Replace `\"$package_name\"` with `BotConfig(\"$package_name\")`. That syntax will be deprecated in future versions. \n Happens at $f:$l" - - config = BotConfig(package_name) - - out = _snoopi_bench_cmd(config, snoop_script, __module__) - return out -end - -""" - @snoopi_bench config::BotConfig - -!!! warning - This macro isn't recommend. Use the function form instead: `snoopi_bench(config::BotConfig)`. - -Benchmarking the infer time of the tests: -```julia -@snoopi_bench BotConfig("MatLang") -``` -""" -macro snoopi_bench(configExpr) - Base.depwarn("This macro isn't recommend. Use the function form instead: `snoop_bench(config::BotConfig)`.", Symbol("@snoopi_bench")) - - config = eval(configExpr) - out = _snoopi_bench_cmd(config, __module__) - return out -end - -macro snoopi_bench(package_name::AbstractString) - Base.depwarn("This macro isn't recommend. Use the function form instead: `snoop_bench(config::BotConfig)`.", Symbol("@snoopi_bench")) - - f, l = __source__.file, __source__.line - @warn "Replace `\"$package_name\"` with `BotConfig(\"$package_name\")`. That syntax will be deprecated in future versions. \n Happens at $f:$l" - - config = BotConfig(package_name) - - out = _snoopi_bench_cmd(config, __module__) - return out -end - -################################################################ -################################################################ - -# deprecation and backward compatiblity -macro snoopiBot(args...) - f, l = __source__.file, __source__.line - Base.depwarn("`@snoopiBot` at $f:$l and its replacement `@snoopi_bot` are deprecated.", Symbol("@snoopiBot")) - return esc(:(@snoopi_bot($(args...)))) -end -macro snoopiBench(args...) - f, l = __source__.file, __source__.line - Base.depwarn("`@snoopiBench` at $f:$l and its replacement `@snoopi_bench` are deprecated.", Symbol("@snoopiBench")) - return esc(:(@snoopi_bench($(args...)))) -end - -################################################################ -################################################################ -# old deprecations -@eval @deprecate $(Symbol("@snoopiBot")) $(Symbol("@snoopi_bot")) -@eval @deprecate $(Symbol("@snoopiBench")) $(Symbol("@snoopi_bench")) -# new deprecations -@eval @deprecate $(Symbol("@snoopi_bot")) $(Symbol("snoopi_bot")) -@eval @deprecate $(Symbol("@snoopi_bench")) $(Symbol("snoopi_bench")) diff --git a/SnoopCompileBot/src/precompile_activation.jl b/SnoopCompileBot/src/precompile_activation.jl deleted file mode 100644 index 7826ac09d..000000000 --- a/SnoopCompileBot/src/precompile_activation.jl +++ /dev/null @@ -1,48 +0,0 @@ - -""" - precompile_activator(package_path) - -Activates precompile of a package by setting `should_precompile = true` - -`package_path = pathof_noload(package_name)` -""" -function precompile_activator(package_path::AbstractString) - includer_file = "$(dirname(package_path))/precompile_includer.jl" - if !isfile(includer_file) - error("$includer_file doesn't exists") - else - file_text = Base.read(includer_file, String) - regp = r"(should_precompile\s*=\s*)(true|false)" - m = match(regp, file_text) - if m !== nothing - file_text = replace(file_text, regp => s"\1 true") - Base.write(includer_file, file_text) - else - error("\"should_precompile = ...\" doesn't exist") - end - end -end - -""" - precompile_deactivator(package_path) - -Deactivates precompile of a package by setting `should_precompile = false` - -`package_path = pathof_noload(package_name)` -""" -function precompile_deactivator(package_path::AbstractString) - includer_file = "$(dirname(package_path))/precompile_includer.jl" - if !isfile(includer_file) - error("$includer_file doesn't exists") - else - file_text = Base.read(includer_file, String) - regp = r"(should_precompile\s*=\s*)(true|false)" - m = match(regp, file_text) - if m !== nothing - file_text = replace(file_text, regp => s"\1 false") - Base.write(includer_file, file_text) - else - error("\"should_precompile = ...\" doesn't exist") - end - end -end diff --git a/SnoopCompileBot/src/precompile_include.jl b/SnoopCompileBot/src/precompile_include.jl deleted file mode 100644 index ff54dbe12..000000000 --- a/SnoopCompileBot/src/precompile_include.jl +++ /dev/null @@ -1,249 +0,0 @@ -""" - new_includer_file( - package_name::AbstractString, - package_path:: AbstractString, - precompiles_rootpath::AbstractString, - os::Union{Vector{String}, Nothing}, - else_os::Union{String, Nothing}, - version::Union{Vector{VersionNumber}, Nothing}, - else_version::Union{VersionNumber, Nothing}) - -Creates a "precompile_includer.jl" file. - -`package_path = pathof_noload(package_name)` -`precompiles_rootpath`: where the precompile files are stored. - -# # Examples -```julia -SnoopCompile.new_includer_file("MatLang", "./src/MatLang.jl", "./deps/SnoopCompile/precompile", ["windows", "linux"], "linux", [v"1.0", v"1.4"], v"1.4") -``` -""" -function new_includer_file( - package_name::AbstractString, - package_path:: AbstractString, - precompiles_rootpath_in::AbstractString, - os::Union{Vector{String}, Nothing}, - else_os::Union{String, Nothing}, - version::Union{Vector{VersionNumber}, Nothing}, - else_version::Union{VersionNumber, Nothing}) - - # make the precompile path relative to src folder - # this is the only path that is written to the disk by the bot, and it should be relative to make it generic. - precompiles_rootpath = GoodPath(relpath(precompiles_rootpath_in, dirname(package_path))) - - os = standardize_osname(os) - else_os = standardize_osname(else_os) - - # find multistr, ismultiversion, ismultios - if isnothing(os) - ismultios = false - multistr = "" - if isnothing(version) - ismultiversion = false - multiversionstr = "" - else - ismultiversion = true - multiversionstr = _multiversion(package_name, precompiles_rootpath, version, else_version) - multistr = multiversionstr - end #if nothing vesion - else - ismultios = true - if isnothing(version) - ismultiversion = false - multistr = _multios(package_name, precompiles_rootpath, os, else_os, ismultiversion) - else - ismultiversion = true - multistr = _multios(package_name, precompiles_rootpath, os, else_os, ismultiversion, version, else_version) - end # if nothing version - end # if nothing os - - precompile_config = """ - should_precompile = true - - - # Don't edit the following! Instead change the script for `snoop_bot`. - ismultios = $ismultios - ismultiversion = $ismultiversion - # precompile_enclosure - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath/precompile_$package_name.jl") - _precompile_() - else - $multistr - end # precompile_enclosure - """ - - includer_file = "$(dirname(package_path))/precompile_includer.jl" - @info "$includer_file file will be created/overwritten" - Base.write(includer_file, precompile_config) -end - -""" -Helper function for multios code generation -""" -function _multios(package_name, precompiles_rootpath, os_in, else_os, ismultiversion, version = nothing, else_version = nothing) - os = similar(os_in, Any) - os[:] = os_in[:] - - push!(os, string(else_os)) - - os_length = length(os) - multistr = "" - for (iOs, eachos) in enumerate(os) - - if iOs == 1 - os_phrase = "@static if Sys.is$eachos()" - elseif iOs == os_length - os_phrase = "else" - else - os_phrase = "elseif Sys.is$eachos()" - end - multistr = multistr * "$os_phrase \n" - - if iOs == os_length && isnothing(else_os) - continue - end - - if ismultiversion - multiversionstr = _multiversion(package_name, precompiles_rootpath, version, else_version, eachos) - multistr = multistr * """ - $multiversionstr - """ - else - multistr = multistr * """ - include("$precompiles_rootpath/$eachos/precompile_$package_name.jl") - _precompile_() - """ - end - end # for os - - multistr = multistr * """ - end - """ - return multistr -end - - -""" -Helper function for multi Julia version code generation -""" -function _multiversion(package_name, precompiles_rootpath, version_in, else_version, eachos = "") - version = similar(version_in, Any) - version[:] = version_in[:] - - sort!(version) - - push!(version, else_version) - - version_length = length(version) - multiversionstr = "" - for (iversion, eachversion) in enumerate(version) - - if iversion == 1 - lowerbound = VersionNumber(eachversion.major, eachversion.minor, 0, ("DEV",)) - higherbound = VersionNumber(eachversion.major, eachversion.minor, 9) - version_phrase = "@static if v\"$lowerbound\" <= VERSION <= v\"$higherbound\"" - elseif iversion == version_length - version_phrase = "else" - else - lowerbound = VersionNumber(eachversion.major, eachversion.minor, 0, ("DEV",)) - higherbound = VersionNumber(eachversion.major, eachversion.minor, 9) - version_phrase = "elseif v\"$lowerbound\" <= VERSION <= v\"$higherbound\"" - end - multiversionstr = multiversionstr * "$version_phrase \n" - - if iversion == version_length && isnothing(else_version) - continue - end - - multiversionstr = multiversionstr * """ - include("$precompiles_rootpath/$eachos/$(VersionFloat(eachversion))/precompile_$package_name.jl") - _precompile_() - """ - end # for version - - multiversionstr = multiversionstr * """ - end - """ - return multiversionstr -end -################################################################ -""" - add_includer(package_name::AbstractString, package_path::AbstractString) - -Writes the `include(precompile_includer.jl)` to the package file. - -`package_path = pathof_noload(package_name)` -""" -function add_includer(package_name::AbstractString, package_path::AbstractString) - if !isfile(package_path) - error("$package_path file doesn't exist") - end - - # read package - package_text = Base.read(package_path, String) - - # Checks if any other precompile code already exists (only finds explicitly written _precompile_) - if occursin("_precompile_()",package_text) - if occursin("""include("../deps/SnoopCompile/precompile/precompile_$package_name.jl")""", package_text) - @warn """removing SnoopCompile < v"1.2.2" code""" # For backward compatibility - replace(package_text, "_precompile_()"=>"") - replace(package_text, """include("../deps/SnoopCompile/precompile/precompile_$package_name.jl")"""=>"") - else - error("""Please remove `_precompile_()` and any other code that includes a `_precompile_()` function from $package_path - SnoopCompile automatically creates the code. - """) - end - elseif occursin(r"#\s*include\(\"precompile_includer.jl\"\)", package_text) - error("""Please uncomment `\"include(\"precompile_includer.jl\")\"` - Set `should_precompile = false` instead for disabling precompilation. - """) - end - - # Adding include to source - if occursin("include(\"precompile_includer.jl\")", package_text) - # has precompile_includer - @info "Package already has \"include(\"precompile_includer.jl\")\"" - return nothing - else - # no precompile_includer - @info "SnoopCompile will try to write \"include(\"precompile_includer.jl\")\" before end of the module in $package_path. Assume that the last `end` is the end of a module." - - # open lines - package_lines = Base.open(package_path) do io - Base.readlines(io, keep=true) - end - - ## find end of a module - # assumes that the last `end` is the end of a module - endline = length(package_lines) - for iLine = endline:-1:1 - if any(occursin.(["end # module", "end"], Ref(package_lines[iLine]))) - endline = iLine - break - end - end - - # add line or error - try - code = """ - include("precompile_includer.jl") - """ - insert!(package_lines,endline,code) # add new empty line before the end - catch e - @error("Error occured during writing", e) - return nothing - end - - # write the lines - if package_lines != nothing - open(package_path, "w") do io - for l in package_lines - Base.write(io, l) - end - end - end - end -end diff --git a/SnoopCompileBot/src/snoop_bench.jl b/SnoopCompileBot/src/snoop_bench.jl deleted file mode 100644 index 986bc5111..000000000 --- a/SnoopCompileBot/src/snoop_bench.jl +++ /dev/null @@ -1,169 +0,0 @@ -# Snooping functions -function _snoopi_bench_cmd(snoop_script) - tmin = 0.0 # For benchmarking - return quote - global SnoopCompile_ENV = true - - using SnoopCompile - - data = @snoopi tmin=$tmin begin - $snoop_script - end - - global SnoopCompile_ENV = false - - using SnoopCompile: timesum - @info( "\nTotal inference time (ms): \t" * string(timesum(data, :ms))) - end -end - -function _snoopv_bench_cmd(snoop_script, package_name) - return quote - using $package_name - @info("Script execution time:") - @timev begin - $snoop_script - end - end -end - -function _snoop_bench(config::BotConfig, snoop_script::Expr, test_modul::Module = Main; snoop_mode::Symbol) - - package_name = config.package_name - package_path = config.package_path - - # automatic (based on Julia version) - if snoop_mode == :auto - if VERSION < v"1.2" - snoop_mode = :run_time - else - snoop_mode = :snoopi - end - end - - if snoop_mode == :snoopi - snooping_code = _snoopi_bench_cmd(snoop_script) - elseif snoop_mode == :run_time - snooping_code = _snoopv_bench_cmd(snoop_script, package_name) - else - error("snoop_mode $snoop_mode is unkown") - end - snooping_code = toplevel_string(snooping_code) - - ################################################################ - julia_cmd = `julia --project=@. -e $snooping_code` - - out = quote - package_sym = Symbol($package_name) - ################################################################ - using SnoopCompile - @info("""------------------------ - Benchmark Started - ------------------------ - """) - ################################################################ - @info("""------------------------ - Precompile Deactivated Benchmark - ------------------------ - """) - $precompile_deactivator($package_path); - ### Log the compiles - run($julia_cmd) - ################################################################ - @info("""------------------------ - Precompile Activated Benchmark - ------------------------ - """) - $precompile_activator($package_path); - ### Log the compiles - run($julia_cmd) - @info("""------------------------ - Benchmark Finished - ------------------------ - """) - end - return out -end - -function _snoop_bench(config::BotConfig, test_modul::Module = Main; snoop_mode::Symbol) - - package_name = config.package_name - package_rootpath = dirname(dirname(config.package_path)) - - package = Symbol(package_name) - runtestpath = "$package_rootpath/test/runtests.jl" - - snoop_script = quote - using $(package); - include($runtestpath); - end - out = _snoop_bench(config, snoop_script, test_modul; snoop_mode = snoop_mode) - return out -end - -################################################################ -""" - snoop_bench(config::BotConfig, path_to_example_script::String, test_modul::Module=Main; snoop_mode=:auto) - -Benchmark the impact of precompile statements, by running a script with and without the precompiles. -`config` can be generated by [`BotConfig`](@ref). -`path_to_example_script` is preferred to be an absolute path. -The example script will be run in the module specified by `test_modul`. -`snoop_mode` can be `:auto`, `:snoopi` (to test with [`SnoopCompileCore.@snoopi`](@ref)), -or `:runtime` (to measure total script run time with `@timev`). -`:auto` chooses `:snoopi` on supported versions of Julia. - -See the [online documentation](https://timholy.github.io/SnoopCompile.jl/stable/bot/) -for a more complete overview. - -# Extended help - -## Example - -In this case, the benchmarking script is placed in the same directory as the -precompile script, so we can use `@__DIR__` to find it: - -```julia -using SnoopCompile - -snoop_bench(BotConfig("MatLang"), "\$(@__DIR__)/example_script.jl") -``` - -As an alternative to `@__DIR__` (for example, if you store your benchmarking script(s) outside -the package itself), you can find the package with [`pathof_noload`](@ref). -""" -function snoop_bench(config::BotConfig, path_to_example_script::String, test_modul::Module=Main; snoop_mode::Symbol=:auto) - # search for the script! - needed because of confusing paths when referencing pattern_or_file in CI - path_to_example_script = searchdirsboth([pwd(),dirname(dirname(config.package_path))], path_to_example_script) - snoop_script = quote - include($path_to_example_script) - end - out = _snoop_bench(config, snoop_script, test_modul; snoop_mode = snoop_mode) - Core.eval( test_modul, out ) -end - -""" - snoop_bench(config::BotConfig, test_modul::Module = Main) - -Benchmark your precompile files using the package's `runtests.jl` file. - -During snooping, `snoop_bench` sets the global variable `SnoopCompile_ENV` to `true`. -If needed, your `runtests.jl` can check for the existence and value of this variable to -customize test behavior specifically for snooping. -``` -""" -function snoop_bench(config::BotConfig, test_modul::Module = Main; snoop_mode::Symbol = :auto) - out = _snoop_bench(config, test_modul; snoop_mode = snoop_mode) - Core.eval( test_modul, out ) -end - -""" - snoop_bench(config::BotConfig, expression::Expr, test_modul::Module = Main) - -Benchmark your precompile files by evaluating an expression, for example `:(using MyPackage)`. -Interpolation and macros are not supported. -""" -function snoop_bench(config::BotConfig, snoop_script::Expr, test_modul::Module = Main; snoop_mode::Symbol = :auto) - out = _snoop_bench(config, snoop_script, test_modul; snoop_mode = snoop_mode) - Core.eval( test_modul, out ) -end diff --git a/SnoopCompileBot/src/snoop_bot.jl b/SnoopCompileBot/src/snoop_bot.jl deleted file mode 100644 index a45e9810c..000000000 --- a/SnoopCompileBot/src/snoop_bot.jl +++ /dev/null @@ -1,209 +0,0 @@ -# Snooping functions -function _snoopi_bot(snoop_script, tmin) - return quote - using SnoopCompile - - data = @snoopi tmin=$tmin begin - $snoop_script - end - end -end - -function _snoopc_bot(snoop_script) - return quote - using SnoopCompile - - @snoopc "compiles.log" begin - $snoop_script - end - - data = SnoopCompile.read("compiles.log")[2] - Base.rm("compiles.log", force = true) - end -end - -function _snoop_analysis_bot(snooping_code, package_name, precompile_folder, subst, exclusions, check_eval) - return quote - packageSym = Symbol($package_name) - - ################################################################ - @info "Processsing the generated precompile signatures" - - using SnoopCompile - - ### Parse the compiles and generate precompilation scripts - pc = SnoopCompile.parcel(data; subst = $subst, exclusions = $exclusions, check_eval = $check_eval) - if !haskey(pc, packageSym) - @error "no precompile signature is found for $($package_name). Don't load the package before snooping. Restart your Julia session." - end - onlypackage = Dict( packageSym => sort(pc[packageSym]) ) - SnoopCompile.write($precompile_folder, onlypackage) - @info "precompile signatures were written to $($precompile_folder)" - end -end - -function _snoop_bot_expr(config::BotConfig, snoop_script, test_modul::Module; snoop_mode::Symbol) - package_name = config.package_name - exclusions = config.exclusions - check_eval = config.check_eval - os = config.os - else_os = config.else_os - version = config.version - else_version = config.else_version - package_path = config.package_path - precompiles_rootpath = config.precompiles_rootpath - subst = config.subst - tmin = config.tmin - - if test_modul != Main && string(test_modul) == package_name - @error "Your example/test shouldn't be in the same module!. Use `Main` instead." - end - - ################################################################ - package_rootpath = dirname(dirname(package_path)) - - new_includer_file(package_name, package_path, precompiles_rootpath, os, else_os, version, else_version) # create an precompile includer file - add_includer(package_name, package_path) # add the code to packages source for including the includer - - # precompile folder for writing - if isnothing(os) - if isnothing(version) - precompile_folder = precompiles_rootpath - else - precompile_folder = "$precompiles_rootpath/$(VersionFloat(VERSION))" - end - else - if isnothing(version) - precompile_folder = "$precompiles_rootpath/$(detectOS()[1])" - else - precompile_folder = "$precompiles_rootpath/$(detectOS()[1])/$(VersionFloat(VERSION))" - end - end - - # automatic (based on Julia version) - if snoop_mode == :auto - if VERSION < v"1.2" - snoop_mode = :snoopc - else - snoop_mode = :snoopi - end - end - - if snoop_mode == :snoopi - snooping_code = _snoopi_bot(snoop_script, tmin) - elseif snoop_mode == :snoopc - snooping_code = _snoopc_bot(snoop_script) - else - error("snoop_mode $snoop_mode is unkown") - end - snooping_code = toplevel_string(snooping_code) - - analysis_code = _snoop_analysis_bot(snooping_code, package_name, precompile_folder, subst, exclusions, check_eval) - analysis_code = toplevel_string(analysis_code) - - snooping_analysis_code = "$snooping_code; $analysis_code;" - - julia_cmd = `julia --project=@. -e $snooping_analysis_code` - - out = quote - ################################################################ - using SnoopCompile - - # Environment variable to detect SnoopCompile bot - global SnoopCompile_ENV = true - - ################################################################ - $precompile_deactivator($package_path); - ################################################################ - - ### Log the compiles and analyze the compiles - run($julia_cmd) - - ################################################################ - $precompile_activator($package_path) - - global SnoopCompile_ENV = false - end - return out -end - -function _snoop_bot_expr(config::BotConfig, test_modul::Module; snoop_mode::Symbol) - - package_name = config.package_name - package_rootpath = dirname(dirname(pathof_noload(package_name))) - runtestpath = "$package_rootpath/test/runtests.jl" - - package = Symbol(package_name) - snoop_script = quote - using $(package) - include($runtestpath) - end - return _snoop_bot_expr(config, snoop_script, test_modul; snoop_mode = snoop_mode) -end - -################################################################ - -""" - snoop_bot(config::BotConfig, path_to_example_script::String, test_modul=Main; snoop_mode=:auto) - -Generate precompile statements using a precompile script. -`config` can be generated by [`BotConfig`](@ref). -`path_to_example_script` is preferred to be an absolute path. -The example script will be run in the module specified by `test_modul`. -`snoop_mode` can be `:auto`, `:snoopi` (to run [`SnoopCompileCore.@snoopi`](@ref)), -or `:snoopc` (to run [`SnoopCompileCore.@snoopc`](@ref)), -where `:auto` chooses `:snoopi` on supported versions of Julia. - -See the [online documentation](https://timholy.github.io/SnoopCompile.jl/stable/bot/) -for a more complete overview. - -# Extended help - -## Example - -In this case, the bot-running script is placed in the same directory as the -precompile script, so we can use `@__DIR__` to find it: - -```julia -using SnoopCompile - -snoop_bot(BotConfig("MatLang"), "\$(@__DIR__)/example_script.jl") -``` -""" -function snoop_bot(config::BotConfig, path_to_example_script::String, test_modul::Module=Main; snoop_mode::Symbol=:auto) - # search for the script! - needed because of confusing paths when referencing pattern_or_file in CI - path_to_example_script = searchdirsboth([pwd(),dirname(dirname(config.package_path))], path_to_example_script) - snoop_script = quote - include($path_to_example_script) - end - out = _snoop_bot_expr(config, snoop_script, test_modul; snoop_mode=snoop_mode) - Core.eval( test_modul, out ) -end - -################################################################ -""" - snoop_bot(config::BotConfig, test_modul::Module = Main) - -Generate precompile statements using the package's `runtests.jl` file. - -During snooping, `snoop_bot` sets the global variable `SnoopCompile_ENV` to `true`. -If needed, your `runtests.jl` can check for the existence and value of this variable to -customize test behavior specifically for snooping. -""" -function snoop_bot(config::BotConfig, test_modul::Module = Main; snoop_mode::Symbol = :auto) - out = _snoop_bot_expr(config, test_modul; snoop_mode = snoop_mode) - Core.eval( test_modul, out ) -end - -################################################################ - -""" - snoop_bot(config::BotConfig, expression::Expr, test_modul::Module = Main) - -Generate precompile statements by evaluating an expression, for example `:(using MyPackage)`. -Interpolation and macros are not supported. -""" -function snoop_bot(config::BotConfig, snoop_script::Expr, test_modul::Module = Main; snoop_mode::Symbol = :auto) - out = _snoop_bot_expr(config, snoop_script, test_modul; snoop_mode = snoop_mode) - Core.eval( test_modul, out ) -end diff --git a/SnoopCompileBot/test/TestPackage0.jl/src/TestPackage0.jl b/SnoopCompileBot/test/TestPackage0.jl/src/TestPackage0.jl deleted file mode 100644 index 5ddf65b45..000000000 --- a/SnoopCompileBot/test/TestPackage0.jl/src/TestPackage0.jl +++ /dev/null @@ -1,8 +0,0 @@ -module TestPackage0 -export hello, domath - -hello(who::String) = "Hello, $who" -domath(x::Number) = x + 5 -include("precompile_includer.jl") - -end diff --git a/SnoopCompileBot/test/TestPackage1.jl/Project.toml b/SnoopCompileBot/test/TestPackage1.jl/Project.toml deleted file mode 100644 index 15a15ab59..000000000 --- a/SnoopCompileBot/test/TestPackage1.jl/Project.toml +++ /dev/null @@ -1,11 +0,0 @@ -name = "TestPackage1" -uuid = "9065cccb-c020-4d69-8e72-36b399042d86" -version = "0.5.4" -[compat] -julia = "1" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test"] diff --git a/SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bench.jl b/SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bench.jl deleted file mode 100644 index 94008aa60..000000000 --- a/SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bench.jl +++ /dev/null @@ -1,5 +0,0 @@ -using SnoopCompileBot - -println("tests infer benchmark") - -snoop_bench(BotConfig("TestPackage1")) diff --git a/SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bot.jl b/SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bot.jl deleted file mode 100644 index 0018d4d1b..000000000 --- a/SnoopCompileBot/test/TestPackage1.jl/deps/SnoopCompile/snoop_bot.jl +++ /dev/null @@ -1,4 +0,0 @@ -using SnoopCompileBot - -# using runtests: -snoop_bot(BotConfig("TestPackage1")) diff --git a/SnoopCompileBot/test/TestPackage1.jl/src/TestPackage1.jl b/SnoopCompileBot/test/TestPackage1.jl/src/TestPackage1.jl deleted file mode 100644 index 0eb729653..000000000 --- a/SnoopCompileBot/test/TestPackage1.jl/src/TestPackage1.jl +++ /dev/null @@ -1,7 +0,0 @@ -module TestPackage1 -export hello, domath - -hello(who::String) = "Hello, $who" -domath(x::Number) = x + 5 - -end diff --git a/SnoopCompileBot/test/TestPackage1.jl/test/Project.toml b/SnoopCompileBot/test/TestPackage1.jl/test/Project.toml deleted file mode 100644 index 0c363327c..000000000 --- a/SnoopCompileBot/test/TestPackage1.jl/test/Project.toml +++ /dev/null @@ -1,2 +0,0 @@ -[deps] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/SnoopCompileBot/test/TestPackage1.jl/test/runtests.jl b/SnoopCompileBot/test/TestPackage1.jl/test/runtests.jl deleted file mode 100644 index 5076fece1..000000000 --- a/SnoopCompileBot/test/TestPackage1.jl/test/runtests.jl +++ /dev/null @@ -1,4 +0,0 @@ -using Test, TestPackage1 - -@test hello("Julia") == "Hello, Julia" -@test domath(2.0) ≈ 7.0 diff --git a/SnoopCompileBot/test/TestPackage2.jl/Project.toml b/SnoopCompileBot/test/TestPackage2.jl/Project.toml deleted file mode 100644 index d7eeb37b6..000000000 --- a/SnoopCompileBot/test/TestPackage2.jl/Project.toml +++ /dev/null @@ -1,11 +0,0 @@ -name = "TestPackage2" -uuid = "e96a28cf-4dd7-4c6b-9ef5-ef7977717e23" -version = "0.5.4" -[compat] -julia = "1" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test"] diff --git a/SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bench.jl b/SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bench.jl deleted file mode 100644 index 9a9b31b3b..000000000 --- a/SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bench.jl +++ /dev/null @@ -1,5 +0,0 @@ -using SnoopCompileBot - -println("tests infer benchmark") - -snoop_bench(BotConfig("TestPackage2")) diff --git a/SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bot.jl b/SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bot.jl deleted file mode 100644 index 99fcbc3fc..000000000 --- a/SnoopCompileBot/test/TestPackage2.jl/deps/SnoopCompile/snoop_bot.jl +++ /dev/null @@ -1,4 +0,0 @@ -using SnoopCompileBot - -# using runtests: -snoop_bot(BotConfig("TestPackage2", os = ["windows", "linux"])) diff --git a/SnoopCompileBot/test/TestPackage2.jl/src/TestPackage2.jl b/SnoopCompileBot/test/TestPackage2.jl/src/TestPackage2.jl deleted file mode 100644 index 1f35aa271..000000000 --- a/SnoopCompileBot/test/TestPackage2.jl/src/TestPackage2.jl +++ /dev/null @@ -1,12 +0,0 @@ -module TestPackage2 -export hello2, domath2 - -@static if Sys.iswindows() - hello2(who::String) = "Hello, $who" - -else - domath2(x::Number) = x + 5 - -end - -end diff --git a/SnoopCompileBot/test/TestPackage2.jl/test/Project.toml b/SnoopCompileBot/test/TestPackage2.jl/test/Project.toml deleted file mode 100644 index 0c363327c..000000000 --- a/SnoopCompileBot/test/TestPackage2.jl/test/Project.toml +++ /dev/null @@ -1,2 +0,0 @@ -[deps] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/SnoopCompileBot/test/TestPackage2.jl/test/runtests.jl b/SnoopCompileBot/test/TestPackage2.jl/test/runtests.jl deleted file mode 100644 index 5d86be252..000000000 --- a/SnoopCompileBot/test/TestPackage2.jl/test/runtests.jl +++ /dev/null @@ -1,8 +0,0 @@ -using Test, TestPackage2 - - -@static if Sys.iswindows() - @test hello2("Julia") == "Hello, Julia" -else - @test domath2(2.0) ≈ 7.0 -end diff --git a/SnoopCompileBot/test/TestPackage3.jl/Project.toml b/SnoopCompileBot/test/TestPackage3.jl/Project.toml deleted file mode 100644 index 73740712f..000000000 --- a/SnoopCompileBot/test/TestPackage3.jl/Project.toml +++ /dev/null @@ -1,11 +0,0 @@ -name = "TestPackage3" -uuid = "e4e5126f-87fb-4ad8-8278-7d97677acfc1" -version = "0.5.4" -[compat] -julia = "1" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test"] diff --git a/SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bench.jl b/SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bench.jl deleted file mode 100644 index 125e61ddb..000000000 --- a/SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bench.jl +++ /dev/null @@ -1,5 +0,0 @@ -using SnoopCompileBot - -println("tests infer benchmark") - -snoop_bench(BotConfig("TestPackage3")) diff --git a/SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bot.jl b/SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bot.jl deleted file mode 100644 index 5c17d4bc5..000000000 --- a/SnoopCompileBot/test/TestPackage3.jl/deps/SnoopCompile/snoop_bot.jl +++ /dev/null @@ -1,4 +0,0 @@ -using SnoopCompileBot - -# using runtests: -snoop_bot(BotConfig("TestPackage3", version = [v"1.0.5", v"1.2", v"1.4.2"], else_version = v"1.2")) diff --git a/SnoopCompileBot/test/TestPackage3.jl/src/TestPackage3.jl b/SnoopCompileBot/test/TestPackage3.jl/src/TestPackage3.jl deleted file mode 100644 index 917a00634..000000000 --- a/SnoopCompileBot/test/TestPackage3.jl/src/TestPackage3.jl +++ /dev/null @@ -1,15 +0,0 @@ -module TestPackage3 -export hello3, domath3, multiply3 - -@static if VERSION > v"1.3" - hello3(who::String) = "Hello, $who" - -elseif VERSION > v"1.2" - domath3(x::Number) = x + 5 - -else - multiply3(x::Float64) = x + 6 - -end - -end diff --git a/SnoopCompileBot/test/TestPackage3.jl/test/Project.toml b/SnoopCompileBot/test/TestPackage3.jl/test/Project.toml deleted file mode 100644 index 0c363327c..000000000 --- a/SnoopCompileBot/test/TestPackage3.jl/test/Project.toml +++ /dev/null @@ -1,2 +0,0 @@ -[deps] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/SnoopCompileBot/test/TestPackage3.jl/test/runtests.jl b/SnoopCompileBot/test/TestPackage3.jl/test/runtests.jl deleted file mode 100644 index 099bdde66..000000000 --- a/SnoopCompileBot/test/TestPackage3.jl/test/runtests.jl +++ /dev/null @@ -1,10 +0,0 @@ -using Test, TestPackage3 - - -@static if VERSION > v"1.3" - @test hello3("Julia") == "Hello, Julia" -elseif VERSION > v"1.2" - @test domath3(2.0) ≈ 7.0 -else - multiply3(2.0) == 8.0 -end diff --git a/SnoopCompileBot/test/TestPackage4.jl/Project.toml b/SnoopCompileBot/test/TestPackage4.jl/Project.toml deleted file mode 100644 index 1378328e5..000000000 --- a/SnoopCompileBot/test/TestPackage4.jl/Project.toml +++ /dev/null @@ -1,11 +0,0 @@ -name = "TestPackage4" -uuid = "687e737b-d6fd-4621-a7ed-af90f28ff546" -version = "0.5.4" -[compat] -julia = "1" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test"] diff --git a/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/example_script.jl b/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/example_script.jl deleted file mode 100644 index dc5992d7a..000000000 --- a/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/example_script.jl +++ /dev/null @@ -1,5 +0,0 @@ -using TestPackage4 - -x = TestPackage4.hello4("Julia") - -y = TestPackage4.domath4(2.0) diff --git a/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bench.jl b/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bench.jl deleted file mode 100644 index e1966806b..000000000 --- a/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bench.jl +++ /dev/null @@ -1,6 +0,0 @@ -using SnoopCompile # for backward compatibiity test - -println("tests infer benchmark") - -exmaple_path = joinpath(dirname(dirname(SnoopCompile.pathof_noload("TestPackage4"))), "src", "example_script.jl") -snoop_bench(BotConfig("TestPackage4"), exmaple_path) diff --git a/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bot.jl b/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bot.jl deleted file mode 100644 index 83ca72efc..000000000 --- a/SnoopCompileBot/test/TestPackage4.jl/deps/SnoopCompile/snoop_bot.jl +++ /dev/null @@ -1,9 +0,0 @@ -# for backward compatibiity test -SnoopCompile_path = dirname(dirname(dirname(dirname(dirname(@__DIR__))))) -if dirname(Base.current_project()) !== SnoopCompile_path - using Pkg; Pkg.develop(PackageSpec(path=SnoopCompile_path)) -end -using SnoopCompile # for backward compatibiity test - -# using runtests: -snoop_bot(BotConfig("TestPackage4"), "$(@__DIR__)/example_script.jl") diff --git a/SnoopCompileBot/test/TestPackage4.jl/src/TestPackage4.jl b/SnoopCompileBot/test/TestPackage4.jl/src/TestPackage4.jl deleted file mode 100644 index fbf8f30c8..000000000 --- a/SnoopCompileBot/test/TestPackage4.jl/src/TestPackage4.jl +++ /dev/null @@ -1,7 +0,0 @@ -module TestPackage4 -export hello4, domath4 - -hello4(who::String) = "Hello, $who" -domath4(x::Number) = x + 5 -include("precompile_includer.jl") -end diff --git a/SnoopCompileBot/test/TestPackage4.jl/src/example_script.jl b/SnoopCompileBot/test/TestPackage4.jl/src/example_script.jl deleted file mode 100644 index dc5992d7a..000000000 --- a/SnoopCompileBot/test/TestPackage4.jl/src/example_script.jl +++ /dev/null @@ -1,5 +0,0 @@ -using TestPackage4 - -x = TestPackage4.hello4("Julia") - -y = TestPackage4.domath4(2.0) diff --git a/SnoopCompileBot/test/TestPackage5.jl/.github/workflows/SnoopCompile.yml b/SnoopCompileBot/test/TestPackage5.jl/.github/workflows/SnoopCompile.yml deleted file mode 100644 index 089abd32e..000000000 --- a/SnoopCompileBot/test/TestPackage5.jl/.github/workflows/SnoopCompile.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: SnoopCompile - -on: - push: - branches: - # - 'master' # NOTE: to run the bot only on pushes to master - -defaults: - run: - shell: bash - -jobs: - SnoopCompile: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - version: # NOTE: the versions below should match those in your botconfig - - '1.4.2' - - '1.3.1' - os: # NOTE: should match the os setting of your botconfig - - ubuntu-latest - - windows-latest - - macos-latest - arch: - - x64 - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.version }} - - name: Install dependencies - run: | - julia --project -e 'using Pkg; Pkg.instantiate();' - julia -e 'using Pkg; Pkg.add(PackageSpec(url = "https://github.com/timholy/SnoopCompile.jl")); Pkg.develop(PackageSpec(; path=pwd())); using SnoopCompileBot; SnoopCompile.addtestdep();' - - name: Generating precompile files - run: julia --project -e 'include("deps/SnoopCompile/snoop_bot.jl")' # NOTE: must match path - - name: Running Benchmark - run: julia --project -e 'include("deps/SnoopCompile/snoop_bench.jl")' # NOTE: optional, if have benchmark file - - name: Upload all - uses: actions/upload-artifact@v2 - with: - path: ./ - - Create_PR: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - needs: SnoopCompile - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Download all - uses: actions/download-artifact@v2 - - name: Move the content of the directory to the root - run: | - rsync -a artifact/* ./ - rm -d -r artifact - - name: Discard unrelated changes - run: | - test -f 'Project.toml' && git checkout -- 'Project.toml' - git ls-files 'Manifest.toml' | grep . && git checkout -- 'Manifest.toml' - (git diff -w --no-color || git apply --cached --ignore-whitespace && git checkout -- . && git reset && git add -p) || echo done - - name: Format precompile_includer.jl - run: julia -e 'using Pkg; Pkg.add("JuliaFormatter"); using JuliaFormatter; format_file("src/precompile_includer.jl")' - - name: Create Pull Request - # https://github.com/marketplace/actions/create-pull-request - uses: peter-evans/create-pull-request@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update precompile_*.jl file - committer: YOUR NAME # NOTE: change `committer` to your name and your email. - title: "[AUTO] Update precompiles" - labels: SnoopCompile - branch: "SnoopCompile_AutoPR" - - - Skip: - if: "contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ubuntu-latest - steps: - - name: Skip CI 🚫 - run: echo skip ci diff --git a/SnoopCompileBot/test/TestPackage5.jl/Project.toml b/SnoopCompileBot/test/TestPackage5.jl/Project.toml deleted file mode 100644 index 192051548..000000000 --- a/SnoopCompileBot/test/TestPackage5.jl/Project.toml +++ /dev/null @@ -1,11 +0,0 @@ -name = "TestPackage5" -uuid = "523531c9-3163-4d6f-9229-6a0f79991ecd" -version = "0.5.4" -[compat] -julia = "1" - -[extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["Test"] diff --git a/SnoopCompileBot/test/TestPackage5.jl/deps/SnoopCompile/example_script.jl b/SnoopCompileBot/test/TestPackage5.jl/deps/SnoopCompile/example_script.jl deleted file mode 100644 index e69de29bb..000000000 diff --git a/SnoopCompileBot/test/TestPackage5.jl/deps/SnoopCompile/snoop_bot.jl b/SnoopCompileBot/test/TestPackage5.jl/deps/SnoopCompile/snoop_bot.jl deleted file mode 100644 index fcf1fd19d..000000000 --- a/SnoopCompileBot/test/TestPackage5.jl/deps/SnoopCompile/snoop_bot.jl +++ /dev/null @@ -1,13 +0,0 @@ -using SnoopCompileBot - -bcs = Vector{BotConfig}(undef, 3) - -bcs[1] = BotConfig("TestPackage5", yml_path = "SnoopCompile.yml") - -bcs[2] = BotConfig("TestPackage5", yml_path = "../../.github/workflows/SnoopCompile.yml") - -bcs[3] = BotConfig("TestPackage5", yml_path = ".github/workflows/SnoopCompile.yml") - -if !( VERSION <= v"1.2" && Base.Sys.iswindows() ) - push!(bcs, BotConfig("TestPackage5", yml_path = "../../$(@__DIR__)/.github/workflows/SnoopCompile.yml")) -end diff --git a/SnoopCompileBot/test/TestPackage5.jl/src/TestPackage5.jl b/SnoopCompileBot/test/TestPackage5.jl/src/TestPackage5.jl deleted file mode 100644 index e5c2d2db0..000000000 --- a/SnoopCompileBot/test/TestPackage5.jl/src/TestPackage5.jl +++ /dev/null @@ -1,6 +0,0 @@ -module TestPackage5 -export hello5, domath5 - -hello5(who::String) = "Hello, $who" -domath5(x::Number) = x + 5 -end diff --git a/SnoopCompileBot/test/botutils.jl b/SnoopCompileBot/test/botutils.jl deleted file mode 100644 index bff4b7e4e..000000000 --- a/SnoopCompileBot/test/botutils.jl +++ /dev/null @@ -1,27 +0,0 @@ -@testset "pathof_noload" begin - pnl = SnoopCompileBot.pathof_noload("MatLang") - import MatLang - p = GoodPath(pathof(MatLang)) - @test p == pnl -end - -################################################################ - -@testset "detectOS" begin - if Base.Sys.iswindows() - @test ("windows", Base.Sys.iswindows) == SnoopCompileBot.detectOS() - elseif Base.Sys.islinux() - @test ("linux", Base.Sys.islinux) == SnoopCompileBot.detectOS() - elseif Base.Sys.isapple() - @test ("apple", Base.Sys.isapple) == SnoopCompileBot.detectOS() - end -end -################################################################ -# JuliaVersionNumber - -# https://github.com/JuliaLang/julia/pull/36223: -# @test SnoopCompileBot.JuliaVersionNumber("nightly") == - # VersionNumber(replace(Base.read("VERSION", String), "\n" => "")) -# @test thispatch(SnoopCompileBot.JuliaVersionNumber("nightly")) == thispatch(VERSION) -@test SnoopCompileBot.JuliaVersionNumber("1.2.3") == v"1.2.3" -@test SnoopCompileBot.JuliaVersionNumber(v"1.2.3") == v"1.2.3" diff --git a/SnoopCompileBot/test/runtests.jl b/SnoopCompileBot/test/runtests.jl deleted file mode 100644 index 6122e2c60..000000000 --- a/SnoopCompileBot/test/runtests.jl +++ /dev/null @@ -1,438 +0,0 @@ -using SnoopCompile, Test -using SnoopCompile.SnoopCompileBot -import SnoopCompileBot.goodjoinpath -stripall(x::String) = replace(x, r"\s|\n"=>"") - -snoopcompiledir = pwd() -bottestdir = GoodPath(@__DIR__) - -@testset "bot" begin - - @testset "add_includer" begin - package_name = "TestPackage0" - package_path = goodjoinpath(bottestdir,"$package_name.jl","src","$package_name.jl") - includer_path = goodjoinpath(dirname(package_path), "precompile_includer.jl") - - SnoopCompileBot.add_includer(package_name, package_path) - - @test occursin("include(\"precompile_includer.jl\")", stripall(Base.read(package_path, String))) - end - - @testset "precompile de/activation" begin - package_name = "TestPackage0" - package_path = goodjoinpath(bottestdir,"$package_name.jl","src","$package_name.jl") - precompiles_rootpath = goodjoinpath(bottestdir,"$package_name.jl","deps/SnoopCompile/precompile") - includer_path = goodjoinpath(dirname(package_path), "precompile_includer.jl") - - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, nothing, nothing, nothing, nothing) - - SnoopCompileBot.precompile_deactivator(package_path) - @test occursin("should_precompile=false", stripall(Base.read(includer_path, String))) - - SnoopCompileBot.precompile_activator(package_path) - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("should_precompile=true", includer_text) - - rm(includer_path) - end - - @testset "precompile new_includer_file" begin - package_name = "TestPackage0" - package_path = goodjoinpath(bottestdir,"$package_name.jl","src","$package_name.jl") - precompiles_rootpath = "$(dirname(dirname(package_path)))/deps/SnoopCompile/precompile" - precompiles_rootpath_rel = GoodPath(relpath( precompiles_rootpath , dirname(package_path))) - includer_path = goodjoinpath(dirname(package_path), "precompile_includer.jl") - - - @testset "no os, no else_os, no version, no else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, nothing, nothing, nothing, nothing) - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=false", includer_text) - @test occursin("ismultiversion=false", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_$package_name.jl") - _precompile_() - else - - end - """), includer_text) - end - - @testset "yes os, no else_os, no version, no else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, ["linux", "windows"], nothing, nothing, nothing) - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=true", includer_text) - @test occursin("ismultiversion=false", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_$package_name.jl") - _precompile_() - else - @static if Sys.islinux() - include("$precompiles_rootpath_rel/linux/precompile_$package_name.jl") - _precompile_() - elseif Sys.iswindows() - include("$precompiles_rootpath_rel/windows/precompile_$package_name.jl") - _precompile_() - else - end - - end - """), includer_text) - end - - @testset "yes os, yes else_os, no version, no else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, ["linux", "windows"], "linux", nothing, nothing) - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=true", includer_text) - @test occursin("ismultiversion=false", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_$package_name.jl") - _precompile_() - else - @static if Sys.islinux() - include("$precompiles_rootpath_rel/linux/precompile_$package_name.jl") - _precompile_() - elseif Sys.iswindows() - include("$precompiles_rootpath_rel/windows/precompile_$package_name.jl") - _precompile_() - else - include("$precompiles_rootpath_rel/linux/precompile_$package_name.jl") - _precompile_() - end - - end - """), includer_text) - end - - @testset "no os, no else_os, yes version, no else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, nothing, nothing, [v"1.2", v"1.4.2"], nothing) - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=false", includer_text) - @test occursin("ismultiversion=true", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_TestPackage0.jl") - _precompile_() - else - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel//1.2/precompile_TestPackage0.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel//1.4/precompile_TestPackage0.jl") - _precompile_() - else - end - - end - """), includer_text) - end - - - @testset "no os, no else_os, yes version, yes else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, nothing, nothing, [v"1.2", v"1.4.2"], v"1.4.2") - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=false", includer_text) - @test occursin("ismultiversion=true", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_$package_name.jl") - _precompile_() - else - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel//1.2/precompile_$package_name.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel//1.4/precompile_$package_name.jl") - _precompile_() - else - include("$precompiles_rootpath_rel//1.4/precompile_$package_name.jl") - _precompile_() - end - - end - """), includer_text) - end - - @testset "yes os, yes else_os, yes version, no else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, ["linux", "windows"], "linux", [v"1.2", v"1.4.2"], nothing) - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=true", includer_text) - @test occursin("ismultiversion=true", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_$package_name.jl") - _precompile_() - else - @static if Sys.islinux() - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/linux/1.2/precompile_$package_name.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/linux/1.4/precompile_$package_name.jl") - _precompile_() - else - end - - elseif Sys.iswindows() - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/windows/1.2/precompile_$package_name.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/windows/1.4/precompile_$package_name.jl") - _precompile_() - else - end - - else - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/linux/1.2/precompile_$package_name.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/linux/1.4/precompile_$package_name.jl") - _precompile_() - else - end - - end - - end - """), includer_text) - end - - @testset "yes os, yes else_os, yes version, yes else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, ["linux", "windows"], "linux", [v"1.2", v"1.4.2"], v"1.4.2") - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=true", includer_text) - @test occursin("ismultiversion=true", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_$package_name.jl") - _precompile_() - else - @static if Sys.islinux() - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/linux/1.2/precompile_$package_name.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/linux/1.4/precompile_$package_name.jl") - _precompile_() - else - include("$precompiles_rootpath_rel/linux/1.4/precompile_$package_name.jl") - _precompile_() - end - - elseif Sys.iswindows() - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/windows/1.2/precompile_$package_name.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/windows/1.4/precompile_$package_name.jl") - _precompile_() - else - include("$precompiles_rootpath_rel/windows/1.4/precompile_$package_name.jl") - _precompile_() - end - - else - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/linux/1.2/precompile_$package_name.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/linux/1.4/precompile_$package_name.jl") - _precompile_() - else - include("$precompiles_rootpath_rel/linux/1.4/precompile_$package_name.jl") - _precompile_() - end - - end - - end - """), includer_text) - end - - @testset "yes os, no else_os, yes version, no else_version" begin - SnoopCompileBot.new_includer_file(package_name, package_path, precompiles_rootpath, ["linux", "windows"], nothing, [v"1.2", v"1.4.2"], nothing) - includer_text = stripall(Base.read(includer_path, String)) - @test occursin("ismultios=true", includer_text) - @test occursin("ismultiversion=true", includer_text) - - @test occursin(stripall(""" - @static if !should_precompile - # nothing - elseif !ismultios && !ismultiversion - include("$precompiles_rootpath_rel/precompile_TestPackage0.jl") - _precompile_() - else - @static if Sys.islinux() - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/linux/1.2/precompile_TestPackage0.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/linux/1.4/precompile_TestPackage0.jl") - _precompile_() - else - end - - elseif Sys.iswindows() - @static if v"1.2.0-DEV" <= VERSION <= v"1.2.9" - include("$precompiles_rootpath_rel/windows/1.2/precompile_TestPackage0.jl") - _precompile_() - elseif v"1.4.0-DEV" <= VERSION <= v"1.4.9" - include("$precompiles_rootpath_rel/windows/1.4/precompile_TestPackage0.jl") - _precompile_() - else - end - - else - end - - end - """), includer_text) - end - rm(includer_path) - end - - - - using Pkg - package_rootpath = String[] - for (i, package_name) in enumerate(["TestPackage1", "TestPackage2", "TestPackage3", "TestPackage4", "TestPackage5"]) - Pkg.develop(PackageSpec(path=joinpath(bottestdir,"$package_name.jl"))) - push!(package_rootpath, goodjoinpath(bottestdir,"$package_name.jl")) - end - @show package_rootpath - - @testset "snoop_bot" begin - - include("$(package_rootpath[1])/deps/SnoopCompile/snoop_bot.jl") - - @test isfile("$(package_rootpath[1])/deps/SnoopCompile/precompile/precompile_TestPackage1.jl") - - precompile_text = Base.read("$(package_rootpath[1])/deps/SnoopCompile/precompile/precompile_TestPackage1.jl", String) - - @test occursin("hello", precompile_text) - @test occursin("domath", precompile_text) - end - - @testset "snoop_bench" begin - include("$(package_rootpath[1])/deps/SnoopCompile/snoop_bench.jl") - end - - @testset "snoop_bot_multios" begin - os, osfun = SnoopCompileBot.detectOS() - - include("$(package_rootpath[2])/deps/SnoopCompile/snoop_bot.jl") - - @test isfile("$(package_rootpath[2])/deps/SnoopCompile/precompile/$os/precompile_TestPackage2.jl") - - precompile_text = Base.read("$(package_rootpath[2])/deps/SnoopCompile/precompile/$os/precompile_TestPackage2.jl", String) - - if os == "windows" - @test occursin("hello2", precompile_text) - @test !occursin("domath2", precompile_text) - else - @test !occursin("hello2", precompile_text) - @test occursin("domath2", precompile_text) - end - end - - @testset "snoop_bench-multios" begin - include("$(package_rootpath[2])/deps/SnoopCompile/snoop_bench.jl") - end - - @testset "snoop_bot_multiversion" begin - os, osfun = SnoopCompileBot.detectOS() - - include("$(package_rootpath[3])/deps/SnoopCompile/snoop_bot.jl") - - @test isfile("$(package_rootpath[3])/deps/SnoopCompile/precompile/$(SnoopCompileBot.VersionFloat(VERSION))/precompile_TestPackage3.jl") - - precompile_text = Base.read("$(package_rootpath[3])/deps/SnoopCompile/precompile/$(SnoopCompileBot.VersionFloat(VERSION))/precompile_TestPackage3.jl", String) - - if VERSION > v"1.3" - @test occursin("hello3", precompile_text) - @test !occursin("domath3", precompile_text) - @test !occursin("multiply3", precompile_text) - elseif VERSION > v"1.2" - @test !occursin("hello3", precompile_text) - @test occursin("domath3", precompile_text) - @test !occursin("multiply3", precompile_text) - else - @test !occursin("hello3", precompile_text) - @test !occursin("domath3", precompile_text) - @test occursin("multiply3", precompile_text) - end - end - - if VERSION <= v"1.4.2" # What is this about? - @testset "snoop_bench-multiversion" begin - include("$(package_rootpath[3])/deps/SnoopCompile/snoop_bench.jl") - end - else - @warn "else version is set to 1.2, so we should not run the benchmark test on nightly, when we have not generated such files yet (unlike in the realworld tests)." - end - - @testset "snoop_bot_presplit_compatibility" begin - - include("$(package_rootpath[4])/deps/SnoopCompile/snoop_bot.jl") - - @test isfile("$(package_rootpath[4])/deps/SnoopCompile/precompile/precompile_TestPackage4.jl") - - precompile_text = Base.read("$(package_rootpath[4])/deps/SnoopCompile/precompile/precompile_TestPackage4.jl", String) - - @test occursin("hello4", precompile_text) - @test occursin("domath4", precompile_text) - end - - @testset "snoop_bench_presplit_compatibility" begin - include("$(package_rootpath[4])/deps/SnoopCompile/snoop_bench.jl") - end - - @testset "yaml os and version parse" begin - include("$(package_rootpath[5])/deps/SnoopCompile/snoop_bot.jl") - for bc in bcs - @test [v"1.4.2", v"1.3.1"] == bc.version - @test ["ubuntu-latest", "windows-latest", "macos-latest"] == bc.os - end - end - - # Clean Test remainder - for (i, package_name) in enumerate(["TestPackage1", "TestPackage2", "TestPackage3", "TestPackage4", "TestPackage5"]) - Pkg.rm(package_name) - main_file= goodjoinpath(package_rootpath[i], "src/$package_name.jl") - run(`git checkout -- $main_file`) - end - Pkg.resolve() - project_toml_path = "$(dirname(bottestdir))/Project.toml" - run(`git checkout -- $project_toml_path`) - - # just in case - cd(snoopcompiledir) - - include("botutils.jl") -end diff --git a/SnoopCompileCore/Project.toml b/SnoopCompileCore/Project.toml index 63619fbac..43e692676 100644 --- a/SnoopCompileCore/Project.toml +++ b/SnoopCompileCore/Project.toml @@ -1,7 +1,7 @@ name = "SnoopCompileCore" uuid = "e2b509da-e806-4183-be48-004708413034" author = ["Tim Holy "] -version = "1.7.2" +version = "2.0.0" [deps] Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" diff --git a/SnoopCompileCore/src/snoopr.jl b/SnoopCompileCore/src/snoopr.jl index 6b728c569..fb9dd20d9 100644 --- a/SnoopCompileCore/src/snoopr.jl +++ b/SnoopCompileCore/src/snoopr.jl @@ -8,7 +8,7 @@ Capture method cache invalidations triggered by evaluating `expr`. of integers (encoding depth) and strings (documenting the source of an invalidation). Unless you are working at a low level, you essentially always want to pass `list` -directly to [`SnoopCompileAnalysis.invalidation_trees`](@ref). +directly to [`SnoopCompile.invalidation_trees`](@ref). # Extended help diff --git a/docs/make.jl b/docs/make.jl index 09b895fca..9460d72c8 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,8 +6,8 @@ makedocs( format = Documenter.HTML( prettyurls = get(ENV, "CI", nothing) == "true" ), - modules = [SnoopCompile.SnoopCompileCore, SnoopCompile.SnoopCompileAnalysis, SnoopCompile.SnoopCompileBot, SnoopCompile], - pages = ["index.md", "snoopi.md", "snoopc.md", "userimg.md", "bot.md", "snoopr.md", "reference.md"] + modules = [SnoopCompile.SnoopCompileCore, SnoopCompile], + pages = ["index.md", "snoopi.md", "snoopc.md", "userimg.md", "snoopr.md", "reference.md"] ) deploydocs( diff --git a/docs/src/bot.md b/docs/src/bot.md deleted file mode 100644 index 922c0d9fc..000000000 --- a/docs/src/bot.md +++ /dev/null @@ -1,191 +0,0 @@ -# SnoopCompile Bot - -As you change the code in your package, the precompile statements likely need to be updated too. -You can use SnoopCompile bot to automatically and continuously create precompile files. -This bot can be used offline or online. - -Follow these steps to set up SnoopCompile bot for your package. - -## 1 - Setting up the SnoopCompile bot configuration folder - -Here, we will configure the bot in a directory `deps/SnoopCompile/` that should be added to your repository. -All configuration files for the SnoopCompile bot should go in this directory. -If you choose a different name for this directory, be sure to change the path in the configuration steps below. - -## 2 - Create the precompile script - -You will need a [precompile script](@ref pcscripts), here called `example_script.jl`, that "exercises" the functionality you'd like to precompile. -If you write a dedicated precompile script, place it in the bot configuration folder. - -Alternatively, you may use your package's `"runtests.jl"` file. -While less precise about which functionality is worthy of precompilation, -this can slightly simplify configuration as described below. - -## 3 - Create the script that runs `snoop_bot` - -The `snoop_bot` function generates precompile statements and writes them to -a file that will be incorporated into your package. -`snoop_bot` requires a few settings, which can be most easily generated by [`BotConfig`](@ref). -The script that runs `snoop_bot` should be saved in your configuration directory, -with a name like `snoop_bot.jl`. - -The example below (from [here](https://github.com/aminya/Zygote.jl/blob/SnoopCompile/deps/SnoopCompile/snoop_bot.jl)) supports multiple operating systems, multiple Julia versions, and excludes a function whose precompilation would be problematic: - -```julia -using SnoopCompile - -botconfig = BotConfig( - "Zygote"; # package name (the one this configuration lives in) - yml_path = "SnoopCompile.yml" # parse `os` and `version` from `SnoopCompile.yml` - exclusions = ["SqEuclidean"], # exclude functions (by name) that would be problematic if precompiled -) - -snoop_bot( - botconfig, - "$(@__DIR__)/example_script.jl", -) -``` - -If you choose to use your "runtests.jl" file as your precompile script, configuration can be as simple as specifying just the name of the package: - -```julia -using SnoopCompile - -snoop_bot(BotConfig("MyPackage")) -``` - -!!! note - Some of your regular tests may not be appropriate for `snoop_bot`. - `snoop_bot` sets a global variable `SnoopCompile_ENV` to `true` during snooping, - and sets it to `false` when finished. - You can exploit this in your tests to determine whether snooping is on: - - ```julia - if !isdefined(Main, :SnoopCompile_ENV) || SnoopCompile_ENV == false - # Tests that you want to skip when snooping - end - ``` - -Finally, you could use package loading as the only operation, -with `snoop_bot(config, :(using MyPackage))`. - -`snoop_bot` uses different strategies depending on the Julia version: - -- On Julia 1.2 or higher, it identifies methods for precompilation based on [`@snoopi`](@ref macro-snoopi); -- On Julia 1.0 or 1.1 (which do not support `@snoopi`), it identifies methods for precompilation based on [`@snoopc`](@ref macro-snoopc). - -You can override this default behavior with a keyword argument, see [`snoop_bot`](@ref) for details. - -## 4 - Optionally test the impact of your precompiles with `snoop_bench` - -Call [`snoop_bench`](@ref) to measure the effect of adding precompile files. -It takes the same parameters as `snoop_bot` above. -You can run this manually, or choose to run it during automatic precompile file generation. -To perform it automatically, create a `snoop_bench.jl` script in the bot configuration directory. -This should be nearly identical to your `snoop_bot.jl` file, but calling `snoop_bench` -instead. -Note that benchmarking has the option of different performance metrics, -`snoop_mode=:snoopi` or `snoop_mode=:run_time` depending on whether you want to measure inference time or the run time of your precompile script. - -## 5 - Configure the bot to run with a GitHub Action file - -You can create the precompile files automatically when you merge pull requests to `master` by adding a workflow file under `.github/workflows/SnoopCompile.yml`. -This file should have content such as the example below. -Lines marked with `NOTE` deserve special attention as likely places you may -need to adjust the configuration. - -```yaml -name: SnoopCompile - -on: - push: - branches: - # - 'master' # NOTE: to run the bot only on pushes to master - -defaults: - run: - shell: bash - -jobs: - SnoopCompile: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - version: # NOTE: the versions below should match those in your botconfig - - '1.4.2' - - '1.3.1' - os: # NOTE: should match the os setting of your botconfig - - ubuntu-latest - - windows-latest - - macos-latest - arch: - - x64 - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.version }} - - name: Install dependencies - run: | - julia --project -e 'using Pkg; Pkg.instantiate();' - julia -e 'using Pkg; Pkg.add(PackageSpec(url = "https://github.com/timholy/SnoopCompile.jl")); Pkg.develop(PackageSpec(; path=pwd())); using SnoopCompile; SnoopCompile.addtestdep();' - - name: Generating precompile files - run: julia --project -e 'include("deps/SnoopCompile/snoop_bot.jl")' # NOTE: must match path - - name: Running Benchmark - run: julia --project -e 'include("deps/SnoopCompile/snoop_bench.jl")' # NOTE: optional, if have benchmark file - - name: Upload all - uses: actions/upload-artifact@v2 - with: - path: ./ - - Create_PR: - if: "!contains(github.event.head_commit.message, '[skip ci]')" - needs: SnoopCompile - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Download all - uses: actions/download-artifact@v2 - - name: Move the content of the directory to the root - run: | - rsync -a artifact/* ./ - rm -d -r artifact - - name: Discard unrelated changes - run: | - test -f 'Project.toml' && git checkout -- 'Project.toml' - git ls-files 'Manifest.toml' | grep . && git checkout -- 'Manifest.toml' - (git diff -w --no-color || git apply --cached --ignore-whitespace && git checkout -- . && git reset && git add -p) || echo done - - name: Format precompile_includer.jl - run: julia -e 'using Pkg; Pkg.add("JuliaFormatter"); using JuliaFormatter; format_file("src/precompile_includer.jl")' - - name: Create Pull Request - # https://github.com/marketplace/actions/create-pull-request - uses: peter-evans/create-pull-request@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update precompile_*.jl file - committer: YOUR NAME # NOTE: change `committer` to your name and your email. - title: "[AUTO] Update precompiles" - labels: SnoopCompile - branch: "SnoopCompile_AutoPR" - - - Skip: - if: "contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ubuntu-latest - steps: - - name: Skip CI 🚫 - run: echo skip ci -``` - -You can learn more about these files and the workflow process in the [documentation](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow). -Examples of such files in projects can be found in other packages, for example -[Zygote](https://github.com/aminya/Zygote.jl/blob/SnoopCompile/.github/workflows/SnoopCompile.yml). - - -!!! note - - Upgrading from an old SnoopCompile bot: - - In addition to the previous steps, you should also remove `_precompile_()` and any other code that includes a `_precompile_()` function. In the new version, SnoopCompile automatically creates the appropriate code. diff --git a/docs/src/reference.md b/docs/src/reference.md index ef6ac679a..4a2e449b5 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -10,22 +10,7 @@ SnoopCompile.parcel SnoopCompile.write SnoopCompile.read SnoopCompile.format_userimg -timesum invalidation_trees filtermod findcaller ``` - -## Snoop bot - -```@docs -BotConfig -snoop_bot -snoop_bench -``` - -## Snoop bot utilities - -```@docs -pathof_noload -``` diff --git a/docs/src/snoopr.md b/docs/src/snoopr.md index 043d93174..817ef1ee8 100644 --- a/docs/src/snoopr.md +++ b/docs/src/snoopr.md @@ -14,16 +14,26 @@ end Invalidations occur when there is a danger that new methods would supersede older methods in previously-compiled code. -To record the invalidations caused by defining new methods, use `@snoopr` from SnoopCompileCore: +To record the invalidations caused by defining new methods, use `@snoopr`. +`@snoopr` is exported by SnoopCompile, but the recommended approach is to record invalidations using the minimalistic `SnoopCompileCore` package: + ```julia using SnoopCompileCore invalidations = @snoopr begin # new methods definition end +using SnoopCompile # now that we've collected the data, load the complete package ``` -and use `invalidation_trees` from SnoopCompileAnalysis to aggregate the information as a collection of [tree structures](https://en.wikipedia.org/wiki/Tree_structure): +and then load `SnoopCompile` itself. + +!!! note + A larger package like `SnoopCompile` itself has greater risk of itself triggering invalidations, + and anything that gets invalidated before using `@snoopr` will not be invalidated by whatever definitions + you put inside the `@snoopr`. + Thus, using `SnoopCompileCore` may give you more complete results than if you get `@snoopr` by loading all of `SnoopCompile`. + +Use `invalidation_trees` to aggregate the information as a collection of [tree structures](https://en.wikipedia.org/wiki/Tree_structure): ```julia -using SnoopCompileAnalysis trees = invalidation_trees(invalidations) ``` @@ -58,11 +68,10 @@ So we can see the consequences for the compiled code, we'll make this definition ```jldoctest invalidations julia> trees = invalidation_trees(@snoopr f(::Float64) = 2) -1-element Array{SnoopCompileAnalysis.MethodInvalidations,1}: +1-element Vector{SnoopCompile.MethodInvalidations}: inserting f(::Float64) in Main at REPL[9]:1 invalidated: backedges: 1: superseding f(::Real) in Main at REPL[2]:1 with MethodInstance for f(::Float64) (2 children) 2: superseding f(::Real) in Main at REPL[2]:1 with MethodInstance for f(::AbstractFloat) (2 children) - 2 mt_cache ``` The list of `MethodInvalidations` indicates that some previously-compiled code got invalidated. @@ -81,17 +90,17 @@ MethodInstance for f(::Float64) at depth 0 with 2 children julia> show(root) MethodInstance for f(::Float64) (2 children) - MethodInstance for callf(::Array{Float64,1}) (1 children) + MethodInstance for callf(::Vector{Float64}) (1 children) ⋮ julia> show(root; minchildren=0) MethodInstance for f(::Float64) (2 children) - MethodInstance for callf(::Array{Float64,1}) (1 children) - MethodInstance for call2f(::Array{Float64,1}) (0 children) + MethodInstance for callf(::Vector{Float64}) (1 children) + MethodInstance for call2f(::Vector{Float64}) (0 children) ``` You can see that the sequence of invalidations proceeded all the way up to `call2f`. -Examining `root2 = method_invalidations.backedges[2]` yields similar results, but for `Array{AbstractFloat,1}`. +Examining `root2 = method_invalidations.backedges[2]` yields similar results, but for `Vector{AbstractFloat}`. The structure of these trees can be considerably more complicated. For example, if `callf` also got called by some other method, and that method had also been executed (forcing it to be compiled), @@ -100,7 +109,7 @@ This is often seen with more complex, real-world tests: ```julia julia> trees = invalidation_trees(@snoopr using SIMD) -4-element Array{SnoopCompileAnalysis.MethodInvalidations,1}: +4-element Vector{SnoopCompile.MethodInvalidations}: inserting convert(::Type{Tuple{Vararg{R,N}}}, v::Vec{N,T}) where {N, R, T} in SIMD at /home/tim/.julia/packages/SIMD/Am38N/src/SIMD.jl:182 invalidated: mt_backedges: 1: signature Tuple{typeof(convert),Type{Tuple{DataType,DataType,DataType}},Any} triggered MethodInstance for Pair{DataType,Tuple{DataType,DataType,DataType}}(::Any, ::Any) (0 children) 2: signature Tuple{typeof(convert),Type{NTuple{8,DataType}},Any} triggered MethodInstance for Pair{DataType,NTuple{8,DataType}}(::Any, ::Any) (0 children) @@ -115,9 +124,9 @@ julia> trees = invalidation_trees(@snoopr using SIMD) inserting <<(x1::T, v2::Vec{N,T}) where {N, T<:Union{Bool, Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}} in SIMD at /home/tim/.julia/packages/SIMD/Am38N/src/SIMD.jl:1061 invalidated: mt_backedges: 1: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for <<(::UInt64, ::Integer) (0 children) - 2: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for copy_chunks_rtol!(::Array{UInt64,1}, ::Integer, ::Integer, ::Integer) (0 children) - 3: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for copy_chunks_rtol!(::Array{UInt64,1}, ::Int64, ::Int64, ::Integer) (0 children) - 4: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for copy_chunks_rtol!(::Array{UInt64,1}, ::Integer, ::Int64, ::Integer) (0 children) + 2: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for copy_chunks_rtol!(::Vector{UInt64}, ::Integer, ::Integer, ::Integer) (0 children) + 3: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for copy_chunks_rtol!(::Vector{UInt64}, ::Int64, ::Int64, ::Integer) (0 children) + 4: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for copy_chunks_rtol!(::Vector{UInt64}, ::Integer, ::Int64, ::Integer) (0 children) 5: signature Tuple{typeof(<<),UInt64,Any} triggered MethodInstance for <<(::UInt64, ::Unsigned) (16 children) 20 mt_cache @@ -125,12 +134,12 @@ julia> trees = invalidation_trees(@snoopr using SIMD) mt_backedges: 1: signature Tuple{typeof(+),Ptr{UInt8},Any} triggered MethodInstance for handle_err(::JuliaInterpreter.Compiled, ::JuliaInterpreter.Frame, ::Any) (0 children) 2: signature Tuple{typeof(+),Ptr{UInt8},Any} triggered MethodInstance for #methoddef!#5(::Bool, ::typeof(LoweredCodeUtils.methoddef!), ::Any, ::Set{Any}, ::JuliaInterpreter.Frame) (0 children) 3: signature Tuple{typeof(+),Ptr{UInt8},Any} triggered MethodInstance for #get_def#94(::Set{Tuple{Revise.PkgData,String}}, ::typeof(Revise.get_def), ::Method) (0 children) - 4: signature Tuple{typeof(+),Ptr{Nothing},Any} triggered MethodInstance for filter_valid_cachefiles(::String, ::Array{String,1}) (0 children) + 4: signature Tuple{typeof(+),Ptr{Nothing},Any} triggered MethodInstance for filter_valid_cachefiles(::String, ::Vector{String}) (0 children) 5: signature Tuple{typeof(+),Ptr{Union{Int64, Symbol}},Any} triggered MethodInstance for pointer(::Array{Union{Int64, Symbol},N} where N, ::Int64) (1 children) 6: signature Tuple{typeof(+),Ptr{Char},Any} triggered MethodInstance for pointer(::Array{Char,N} where N, ::Int64) (2 children) 7: signature Tuple{typeof(+),Ptr{_A} where _A,Any} triggered MethodInstance for pointer(::Array{T,N} where N where T, ::Int64) (4 children) - 8: signature Tuple{typeof(+),Ptr{Nothing},Any} triggered MethodInstance for _show_default(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Any) (49 children) - 9: signature Tuple{typeof(+),Ptr{Nothing},Any} triggered MethodInstance for _show_default(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Any) (336 children) + 8: signature Tuple{typeof(+),Ptr{Nothing},Any} triggered MethodInstance for _show_default(::IOContext{Base.GenericIOBuffer{Vector{UInt8}}}, ::Any) (49 children) + 9: signature Tuple{typeof(+),Ptr{Nothing},Any} triggered MethodInstance for _show_default(::Base.GenericIOBuffer{Vector{UInt8}}, ::Any) (336 children) 10: signature Tuple{typeof(+),Ptr{UInt8},Any} triggered MethodInstance for pointer(::String, ::Integer) (1027 children) 2 mt_cache @@ -229,8 +238,8 @@ Then: julia> ascend(root) Choose a call for analysis (q to quit): > f(::AbstractFloat) - callf(::Array{AbstractFloat,1}) - call2f(::Array{AbstractFloat,1}) + callf(::Vector{AbstractFloat}) + call2f(::Vector{AbstractFloat}) ``` This is an interactive menu: press the down arrow to go down, the up arrow to go up, and `Enter` to select an item for more detailed analysis. @@ -242,8 +251,8 @@ For example, if we press the down arrow once, we get julia> ascend(root) Choose a call for analysis (q to quit): f(::AbstractFloat) - > callf(::Array{AbstractFloat,1}) - call2f(::Array{AbstractFloat,1}) + > callf(::Vector{AbstractFloat}) + call2f(::Vector{AbstractFloat}) ``` Now hit `Enter` to select it: @@ -270,10 +279,10 @@ Choose caller of MethodInstance for f(::AbstractFloat) or proceed to typed code: and then hit `Enter`, this is what you see: ```julia -│ ─ %-1 = invoke callf(::Array{AbstractFloat,1})::Int64 +│ ─ %-1 = invoke callf(::Vector{AbstractFloat})::Int64 Variables #self#::Core.Compiler.Const(callf, false) - container::Array{AbstractFloat,1} + container::Vector{AbstractFloat} Body::Int64 @ REPL[3]:1 within callf @@ -286,7 +295,7 @@ Toggles: [o]ptimize, [w]arn, [d]ebuginfo, [s]yntax highlight for Source/LLVM/Nat Show: [S]ource code, [A]ST, [L]LVM IR, [N]ative code Advanced: dump [P]arams cache. - • %1 = invoke getindex(::Array{AbstractFloat,1},::Int64)::AbstractFloat + • %1 = invoke getindex(::Vector{AbstractFloat},::Int64)::AbstractFloat %2 = call #f(::AbstractFloat)::Int64 ↩ ``` @@ -327,7 +336,7 @@ julia> ex = :(Array{Float32,3}) julia> dump(ex) Expr head: Symbol curly - args: Array{Any}((3,)) + args: Vector{Any(3,)) 1: Symbol Array 2: Symbol Float32 3: Int64 3 diff --git a/src/SnoopCompile.jl b/src/SnoopCompile.jl index c59c5bfa6..178824f49 100644 --- a/src/SnoopCompile.jl +++ b/src/SnoopCompile.jl @@ -2,29 +2,33 @@ module SnoopCompile using SnoopCompileCore export @snoopc +isdefined(SnoopCompileCore, Symbol("@snoopi")) && export @snoopi +if isdefined(SnoopCompileCore, Symbol("@snoopr")) + export @snoopr, uinvalidated, invalidation_trees, filtermod, findcaller, ascend +end -using SnoopCompileAnalysis +using Core: MethodInstance, CodeInfo +using Serialization, OrderedCollections -# needed for processing the output of snoopc (avoids a breaking change in scoping) -using SnoopCompileAnalysis: parcel, read, write, parse_call, format_userimg +# Parcel Regex +const anonrex = r"#{1,2}\d+#{1,2}\d+" # detect anonymous functions +const kwrex = r"^#kw##(.*)$|^#([^#]*)##kw$" # detect keyword-supplying functions +const kwbodyrex = r"^##(\w[^#]*)#\d+" # detect keyword body methods +const genrex = r"^##s\d+#\d+$" # detect generators for @generated functions +const innerrex = r"^#[^#]+#\d+" # detect inner functions -if isdefined(SnoopCompileCore, Symbol("@snoopi")) - export @snoopi - using SnoopCompileAnalysis: topmodule, lookup_kwbody_ex, exclusions_remover! -end +# Parcel +include("parcel_snoopc.jl") -if isdefined(SnoopCompileCore, Symbol("@snoopr")) - export @snoopr, uinvalidated, invalidation_trees, filtermod, findcaller, ascend - using SnoopCompileAnalysis: getroot, remove_if_not_eval! +if VERSION >= v"1.2.0-DEV.573" + include("parcel_snoopi.jl") end -using SnoopCompileBot -export BotConfig, snoop_bot, snoop_bench -export timesum, pathof_noload, GoodPath -if isdefined(SnoopCompileBot, Symbol("@snoopiBench")) - # deprecated names - export @snoopiBench, @snoopiBot, @snoopi_bench, @snoopi_bot +if VERSION >= v"1.6.0-DEV.154" + include("invalidations.jl") end -using SnoopCompileBot: standardize_osname, JuliaVersionNumber, addtestdep + +# Write +include("write.jl") end # module diff --git a/SnoopCompileAnalysis/src/invalidations.jl b/src/invalidations.jl similarity index 100% rename from SnoopCompileAnalysis/src/invalidations.jl rename to src/invalidations.jl diff --git a/SnoopCompileAnalysis/src/parcel_snoopc.jl b/src/parcel_snoopc.jl similarity index 99% rename from SnoopCompileAnalysis/src/parcel_snoopc.jl rename to src/parcel_snoopc.jl index ca6b36a6c..eaabc609f 100644 --- a/SnoopCompileAnalysis/src/parcel_snoopc.jl +++ b/src/parcel_snoopc.jl @@ -195,7 +195,7 @@ julia> SnoopCompile.remove_if_not_eval!(pcstatements, Base) ┌ Warning: Faulty precompile statement: precompile(sum, (CustomVector{Int},)) │ exception = UndefVarError: CustomVector not defined └ @ Base precompile_Base.jl:375 -1-element Array{String,1}: +1-element Vector{String}: "precompile(sum, (Vector{Int},))" ``` """ diff --git a/SnoopCompileAnalysis/src/parcel_snoopi.jl b/src/parcel_snoopi.jl similarity index 100% rename from SnoopCompileAnalysis/src/parcel_snoopi.jl rename to src/parcel_snoopi.jl diff --git a/SnoopCompileAnalysis/src/write.jl b/src/write.jl similarity index 100% rename from SnoopCompileAnalysis/src/write.jl rename to src/write.jl diff --git a/test/runtests.jl b/test/runtests.jl index 67983d563..1fda2d0a3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -84,6 +84,3 @@ if isdefined(SnoopCompile, :invalidation_trees) include("snoopr.jl") end -# SnoopCompileBot tests: -# using Pkg; Pkg.test("SnoopCompileBot", coverage=true); -include("../SnoopCompileBot/test/runtests.jl") diff --git a/utils/dev.jl b/utils/dev.jl index e0360c799..776bcb0f8 100644 --- a/utils/dev.jl +++ b/utils/dev.jl @@ -2,7 +2,5 @@ using Pkg rootdir = dirname(@__DIR__) Pkg.develop([ PackageSpec(path=joinpath(rootdir,"SnoopCompileCore")), - PackageSpec(path=joinpath(rootdir,"SnoopCompileAnalysis")), - PackageSpec(path=joinpath(rootdir,"SnoopCompileBot")), PackageSpec(path=rootdir), ]) diff --git a/utils/register.jl b/utils/register.jl index ee8613ff0..21b694701 100644 --- a/utils/register.jl +++ b/utils/register.jl @@ -9,8 +9,6 @@ Bump the version number of all packages in the repository to `version`. """ function bump_version(version::VersionNumber) for dir in (__topdir__, - joinpath(__topdir__, "SnoopCompileAnalysis"), - joinpath(__topdir__, "SnoopCompileBot"), joinpath(__topdir__, "SnoopCompileCore")) projfile = joinpath(dir, "Project.toml") lines = readlines(projfile) @@ -42,7 +40,7 @@ function bump_version(version::VersionNumber) end function register_all() - for pkg in ("SnoopCompileCore", "SnoopCompileAnalysis", "SnoopCompileBot", "SnoopCompile") + for pkg in ("SnoopCompileCore", "SnoopCompile") pkgsym = Symbol(pkg) @eval Main using $pkgsym register(getfield(Main, pkgsym)::Module)