lucasavila00
I’m hacking around, trying to support Elixir as a target for m2cgen.
To be able to merge the support for Elixir on m2cgen, the test suite needs to pass and execute in a reasonable amount of time.
So far, with the help of @josevalim I was able to optimize the tree-based models well enough that they’re no longer a problem for running the test suite.
However, SVM-Like models are too slow to compile.
Here there are 4 examples of the same model, exported with varying max line-lengths for the sub-expressions.
Varying the max length of the lines made no difference in compilation times, but the super_small version makes it easier to read and understand what the code is doing.
In the end, I need help figuring out if there’s a way to generate better code for these expressions, in order to make compilation times faster.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










First Post!- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
josevalim
The first thing that comes to mind in the SVM code is:
you are converting everything to a binary first thing. don’t do that for anything from m2cgen. if the goal is to work with large amounts of data, lists are not a good representation, at all. Instead expect the input to be a binary.
you are reading the same input multiple times. This was not a problem in the other examples but seems to be one for SVM. So I would do this as the first thing on top:
And then use v1, v2, instead of calling read. Not sure how much it helps, but it should help a bit.
Last Post!
lucasavila00
I created a “benchmark” for the compiler, where I have a function return one expression. I control the length of said expression (the 1+1+1 part)
I benchmarked and charted it, where X is the amount of "1"s and Y is seconds to compile.
The compiler presents quadratic behaviour, given the expression size:
Then, I decided to try to wrap the each line in https://github.com/lucasavila00/ex_m2cgen_examples/blob/main/nusvm_model/super_small_lines.ex with an anonymous function.
When wrapped, the quadratic behaviour is gone, and the file compiles in ~3s now.
For the record, I can now run the entire test suite (186 models) in 10 minutes, which is totally fine for m2cgen CI, I guess. All tests passing