Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Precompilation setup? #217

Open
Open

Description

@juliohm

I am experimenting with the package for the first time, and noticed that the precompilation time is quite large:

julia> @time average(gt); # first execution
 26.373887 seconds (206.77 M allocations: 9.999 GiB, 3.68% gc time, 99.96% compilation time)

julia> @time average(gt); # second execution
  0.014517 seconds (330.02 k allocations: 18.696 MiB)

Should we add a precompilation script to get a better first-time experience?

Activity

  1. mikeingold commented on Feb 2, 2026

    @mikeingold
    Collaborator

    Do you have a MWE for the above result? I've noticed some suboptimal compilation times before but 26 seconds for a first-use is definitely not a great experience.

    I'd considered working on precompilation before but didn't know enough about it to have a good sense of what would actually be beneficial, e.g. will the precompiled code remain valid/useful for non-identical integrand functions?

  2. juliohm commented on Feb 2, 2026

    @juliohm
    MemberAuthor

    Hi @mikeingold, thank you for looking into it.

    Below is a MWE with a single triangle:

    using Meshes
    using MeshIntegrals
    
    function integrand(tri::Triangle, f)
      p -> let
        # retrieve vertices
        v = vertices(tri)
    
        # linear system for barycentric coordinates
        A = [(v[2] - v[1]) (v[3] - v[1])]
        b = (p - v[1])
    
        # normalize by maximum absolute coordinate
        m = maximum(abs, A)
        Aₘ = A / m
        bₘ = b / m
    
        # solve for barycentric coordinates
        w₂, w₃ = Aₘ \ bₘ
    
        # linear interpolation inside triangle
        f[1] + w₂ * (f[2] - f[1]) + w₃ * (f[3] - f[1])
      end
    end
    
    t = rand(Triangle)
    
    @time integral(integrand(t, [1, 2, 3]), t, GaussLegendre(2));

    The actual example repeats this call for all triangles in a mesh. You can find the test here and the definition of the average function here.

  3. JoshuaLampert commented on Apr 8, 2026

    @JoshuaLampert
    Member

    This is much better with the version in Meshes.jl v0.57, right?

  4. juliohm commented on Apr 8, 2026

    @juliohm
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions