Notes

Performance

Access of attributes (e.g., by vattr) should be "statically typed" to avoid dynamic dispatch. The Attributes) section provides hints:

  • Access attributes early and pass attributes (not attribute names) to methods.
  • Use Val(:x) for name literals or use helpers such as provided for Geometry.

This is effective for attribute lists that are represented as NamedTuple (see also PMeshAttributes). For "dynamic" representations, e.g., based on Dict, you may require additional type assertions.

Note

The current implementation supports only the NamedTuple representation.

Note

Many avoidable runtime penalties stem from dynamic dispatch (slower) vs "static dispatch" (fast).

Tip

Use Traceur (@trace) and/or (preferably) JET (@report_opt) to discover potential problems. Cthulhu (@descend) provides interactive exploration.

Tip

Use BenchmarkTools to test for performance regressions.

Example

#
# Dynamic vs static dispatch
#

function f(mesh, attibute)
    # ...
end

using Traceur
@trace f(mesh, :name)

using JET
@report_opt f(mesh, :name)

# - Try again with passing Val(:name) or
#   attribute a (where a = vattr(mesh, Val(:name)))
# - Conduct benchmarks (see below)

using Cthuluh
@descend f(mesh, :name)

#
# Benchmark excluding setup time
#

b = @benchmark flip!(mesh, HHnd(1000)) setup=(mesh = clone(SOME_MESH)) evals=1
show(io, MIME("text/plain"), b)