Skip to content

JuliaComputing/CthulhuJETWorkshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cthulu.jl + JET.jl workshop

This repository contains some examples and code snippets. Tested and developed with Julia version 1.12.0-rc3 and:

Cthulhu@v2.17.8
JET@v0.10.7
JuliaSyntax@v1.0.2

Common issues related to --trim

Specific code issues:

  1. (vec...,)
    • this operation requires an awkward for-loop code to --trim
    • often causes downstream inference issues due to Tuple{Vararg{...}}
  2. [vec_a..., vec_b...]
    • this is "Vector{Int}" all the way down, but poor apply_iterate support breaks this (takeaway: only ever splat Tuples, not Vectors)
    • JuliaLang/julia#57830
  3. return (; attributes...)
    • very easy for this to become type-unstable when considering multiple return values
    • best to explicitly write the @NamedTuple{...} type you want to return and use that (similar to an anonymous struct)
  4. eval(...) (CPUSummary.jl / HostCPUFeatures.jl are the notable examples in the community)
    • CPUSummary.jl has been fixed already, HostCPUFeatures.jl has not

Common patterns that cause issues:

  1. Returning different types based on a runtime value
  2. De-serializing data
    • if it can be done at top-level, this is a "compile-time" operation and (mostly) trimmable for free!
    • be careful about using heavy de-serialization libraries, since the binaries will ship with your --trim code
  3. Manual specialization required
  4. (Advanced) Manual de-specialization required

Good patterns:

  1. Returning a Const(...) value (Tuple / Integer / Symbol / Type) based on a value's type
    • this is the "Tim Holy Trait trick"
  2. Make all struct fields "concretely-typed" (i.e. parameterized or a specific concrete type)

Good "natural-feeling" examples:

About

A demo repository of introductory examples and materials for JET / Cthulhu

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •