# Tria - the Elixir optimizer

**URL:** <https://forum.elixirforum.com/t/tria-the-elixir-optimizer/53250>\
**Category:** Announcing\
**Tags:** library, optimization, tria\
**Created:** [January 18, 2023, 1:13am UTC](https://forum.elixirforum.com/t/tria-the-elixir-optimizer/53250 "2023-01-18T01:13:03Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![josevalim](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/32/1787_2.png) [@josevalim](https://forum.elixirforum.com/u/josevalim)\
**Post date:** [January 18, 2023, 12:27pm UTC](https://forum.elixirforum.com/t/tria-the-elixir-optimizer/53250/11 "2023-01-18T12:27:06Z")

</div>

> [@hst337](#):
>
> This is a big questions. Generally, there are two types of functions: functions which are defined in Erlang or Elixir, or functions which are undefined (thus contain `erlang:nif_error` or call to themselves in their bodies like in Elixir bootstrap).

What we could do in Elixir itself is to keep a list of the functions in its standard library that are pure. Erlang also keeps a similar list for its standard library and inlines those. WDYT?

We can make this generally applicable but it is worth keeping in mind that each inlined modules becomes a compile-time dependency, and enlarging the compile time graphic can have huge impacts on performance. This is not a concern for Elixir stdlib itself though.

It is also not possible to know if something is pure or not when calling Erlang functions (unless we have an FFI layer where you also explicitly declare those).

> [@hst337](#):
>
> It translates `Enum.reduce() |> :lists.reverse` to `Enum.map`.

Ah, thank you. [We had a previous discussion about this](https://forum.elixirforum.com/t/enum-fusion/36193/31). At the time, the cost of traversal in `for` comparing Enum.reduce vs Enum.map was roughly 13% faster. However, your benchmarks show the body recursive version can be even faster and we could emit Erlang AST with a body recursive version using Erlang’s “named anonymous functions”. Is this something you have an interest in contributing? Or should I open up an issue for someone else to pick?

---

_[View the full topic](https://forum.elixirforum.com/t/tria-the-elixir-optimizer/53250)._
