WARNING This is a development version Compiler is unstable and may break some code
An optimizing compiler for elixir.
- Add a dependency
def deps do
[
{:tria, github: "hissssst/tria"}
]
end
- Add a compiler and remove protocol consolidation
def project do
[
...
consolidate_protocols: false,
compilers: [:erlang, :tria, :app]
]
end
-
mix compile && mix tria.warmup --available
This compiles the deps, and warms up the cache of used functions -
Project is ready to use now
-
Constant evaluation. Plain Elixir and Erlang are unable to evaluate so-called remote call. Tria evalutes what can be evaluated in runtime
-
Enum fusion. Tria joins multiple consequent Enum or Stream calls to most optimal form.
-
map.field
optimization. This construction is now 3 times faster
Just use mix tria.report "INSERT BUG TITLE HERE"
and it will automatically open tracker with information about system and env prefilled
export TRIA_DEBUG=1
export TRIA_TRACE="Module.function/1,Foo.bar/2"
This will print all steps of compilation of the Module.function/arity
function . Each step will be named and will be possible to grep in the exact same format.
Plus, TRIA_DEBUG
increases verbosity of compiler and generates tria_global_context.ex
file which contains the final version of the code after all optimizations.
Tria is a language, it differs from Elixir, but it is mostly Elixir
and it is represented similary to Macro.t()
. Tria is designed specifically
for optimizing transformations, like any IR language and has a specific
Single Static Assignment form translator.