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
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
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








