Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hissssst/tria
Elixir optimizing compiler
https://github.com/hissssst/tria
compiler elixir optimization transpiler
Last synced: about 1 month ago
JSON representation
Elixir optimizing compiler
- Host: GitHub
- URL: https://github.com/hissssst/tria
- Owner: hissssst
- License: gpl-3.0
- Created: 2020-10-06T08:37:30.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-08T13:07:46.000Z (9 months ago)
- Last Synced: 2024-04-08T14:28:11.684Z (9 months ago)
- Topics: compiler, elixir, optimization, transpiler
- Language: Elixir
- Homepage:
- Size: 436 KB
- Stars: 54
- Watchers: 5
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Tria
> WARNING This is a development version
> Compiler is unstable and may break some codeAn optimizing compiler for elixir.
## How to use
1. Add a dependency
```elixir
def deps do
[
{:tria, github: "hissssst/tria"}
]
end
```2. Add a compiler and remove protocol consolidation
```elixir
def project do
[
...
consolidate_protocols: false,
compilers: [:erlang, :tria, :app]
]
end
```3. `mix compile && mix tria.warmup --available`
This compiles the deps, and warms up the cache of used functions4. Project is ready to use now
## Features
1. Constant evaluation. Plain Elixir and Erlang are unable to evaluate so-called remote call. Tria evalutes what can be evaluated in runtime
2. Enum fusion. Tria joins multiple consequent Enum or Stream calls to most optimal form.
3. `map.field` optimization. This construction is now 3 times faster
## Reporting bugs
Just use `mix tria.report "INSERT BUG TITLE HERE"` and it will automatically open tracker with information about system and env prefilled
## How to debug
```sh
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 language
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.