# Coverage and precompilation

**URL:** <https://discourse.julialang.org/t/coverage-and-precompilation/77324>\
**Category:** General Usage\
**Created:** [March 2, 2022, 10:38pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324 "2022-03-02T22:38:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [March 2, 2022, 10:38pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324/1 "2022-03-02T22:38:44Z")

</div>

Hi!

When I add precompilation statements from SnoopCompile, I start to see weird coverage results. Take a look here:

 ![Captura de Tela 2022-03-02 às 19.35.59](https://global.discourse-cdn.com/julialang/original/3X/d/a/daf965a0d8d4d58cc0127c5df440a86b9e13bc47.png)

Everything seems fine when I remove those statements.

I saw that this can be improved if I run Julia with `--inline=no` when generating the coverage information. However, I am using the Github action `julia-actions/julia-processcoverage@v1`. Can anyone tell me what can I do to add this `--inline=no` option to that Github action?

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [March 2, 2022, 11:21pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324/2 "2022-03-02T23:21:06Z")

</div>

> [@Ronis\_BR](#):
>
> However, I am using the Github action `julia-actions/julia-processcoverage@v1` . Can anyone tell me what can I do to add this `--inline=no` option to that Github action?

That action actually just collects coverage files already generated by previous steps in your workflow, most likely from `julia-actions/julia-runtest`. To add `--inline=no` there, you change

```yaml
      - uses: julia-actions/julia-runtest@v1

```

to

```yaml
      - uses: julia-actions/julia-runtest@v1
        with:
          inline: no

```

Note: some code heavily depends on inlining for performance. I [saw](https://github.com/JuliaRegistries/RegistryCI.jl/pull/274#issuecomment-706773533) a test go from a few seconds to 300s+ with `--inline=no`! So you might want to be careful where you use it.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [March 3, 2022, 1:08pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324/3 "2022-03-03T13:08:34Z")

</div>

Thanks @ericphanson !

It does not have any time impact. However, the coverage did not improve ☹ I am still seeing things like this if I use precompilation directives:

 ![Captura de Tela 2022-03-03 às 10.08.26](https://global.discourse-cdn.com/julialang/original/3X/0/0/00d1c0525c56fb12f4b1c3d7a35b574cd6005a7c.png)

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [March 3, 2022, 1:11pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324/4 "2022-03-03T13:11:41Z")

</div>

I am wondering if I can remove the precompilation if I am running for coverage computation.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [March 3, 2022, 1:34pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324/5 "2022-03-03T13:34:48Z")

</div>

It is ugly, but seems to work:

First, I add the precompilation directive as follows:

```julia
if Base.VERSION >= v"1.4.2" && !haskey(ENV, "STRING_MANIPULATION_NO_PRECOMPILATION")
    # This try/catch is necessary in case the precompilation statements do not
    # exists. In this case, StringManipulation.jl will work correctly but
    # without the optimizations.
    try
        include("../precompilation/precompile_StringManipulation.jl")
        _precompile_()
    catch
    end
end

```

Then, I removed the coverage processing from the main GitHub action.

After that, I create another action for the coverage using the following file:

```nohighlight
name: Coverage
on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
    tags: '*'
jobs:
  test:
    name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        version:
          - '1' # This automatically expands to the latest stable 1.x release.
        os:
          - ubuntu-latest
        arch:
          - x64
    env:
      STRING_MANIPULATION_NO_PRECOMPILATION: ""
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1
        with:
          version: ${{ matrix.version }}
          arch: ${{ matrix.arch }}
      - uses: actions/cache@v1
        env:
          cache-name: cache-artifacts
        with:
          path: ~/.julia/artifacts
          key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
          restore-keys: |
            ${{ runner.os }}-test-${{ env.cache-name }}-
            ${{ runner.os }}-test-
            ${{ runner.os }}-
      - uses: julia-actions/julia-buildpkg@v1
      - uses: julia-actions/julia-runtest@v1
      - uses: julia-actions/julia-processcoverage@v1
      - uses: codecov/codecov-action@v2
        with:
          file: lcov.info

```

And now everything works 🙂

 ![Captura de Tela 2022-03-03 às 10.34.33](https://global.discourse-cdn.com/julialang/original/3X/8/e/8e241235c00cf066988b4695e728300c7950f558.png)

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 4, 2022, 12:13pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324/6 "2022-03-04T12:13:16Z")

</div>

It would be interesting to know if this also happens on nightly, which has major changes to precompilation.

Off the top of my head, the most likely culprit may be constant-propagation, and if different code gets generated depending on whether you precompile.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [March 4, 2022, 12:46pm UTC](https://discourse.julialang.org/t/coverage-and-precompilation/77324/7 "2022-03-04T12:46:26Z")

</div>

Hi @tim.holy !

Thanks for the information, I will check 🙂
