jasonmonroe

jasonmonroe

Runtime Compilation of Dynamic Modules

I am building an application which compiles new functions based on user input. For performance reasons, I would like to compile each function separately since there will be a large quantity of functions which can change individually. I already have the application working with Module.create and :ets lookups for the modules; however, I know that the design is not ideal since the module names are dynamic. This means I am creating atoms based on user input which is obviously bad.

From what I can tell, there is no way to recompile only a piece of a module which requires me to separate out the functions. I would like to avoid polluting the atom table in this way so I have come up with a possible solution.

My current idea is to create a registry process which assigns atoms to functions which they can use for their modules. As functions are removed, the atom it was assigned would be freed for the next created function to use. This way I will limit the atoms I use to the most atoms I used at any one point in time. I know entirely how I would build this but I would love to find a more elegant way of doing it.

Any suggestions would be greatly appreciated.

Most Liked

chrismcg

chrismcg

Discord moved away from fastglobal according to We've since ditched fastglobal actually, as we found that it'd take too long to ... | Hacker News their reasons might be relevant to what you’re doing.

jasonmonroe

jasonmonroe

Hi Axelson,

Thanks for the suggestion. For my scenario I am looking to run these functions at a really high rate and performance/throughput is my #1 goal. The benefit of compiling in my scenario is that my running processes can actually call the function directly through a naming convention rather than looking them up using an expensive process call.

To elaborate a little bit, I would like to be able to recompile an individual function while heavy execution is happening. So I need to optimize in 2 areas: execution and compilation with an emphasis on execution. If I have to send a process message to get an in-memory function, I’m certain I will be sacrificing performance.

Where Next?

Popular in Questions Top

Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement