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 https://news.ycombinator.com/item?id=19240243 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

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
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 th...
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
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New

We're in Beta

About us Mission Statement