jsm
ModuleStore - use a compiled module as a high-performance key-value store
Package: module_store | Hex
Source: GitHub - juulSme/ModuleStore: Compiled-at-runtime modules as high-read-performance key-value stores in Elixir
Docs: ModuleStore v0.0.1 — Documentation
I’ve created a small library that (mis)uses module (re)compilation to create very fast runtime storage. It performs extremely well for reads and extremely badly for writes, by design. The API is a simple key-value interface. It should be considered as being in a very early state, it’s not battle-tested at all at this point.
Most Liked
wojtekmach
For some more prior art, also check out GitHub - discord/fastglobal: Fast no copy globals for Elixir & Erlang.. But yeah, I believe persistent_term was designed to solve problems like these.
ltd
Is there a reason to not use the erlang builtin :persistent_term.
benwilson512
To be clear modules are also global. If you want a similarly ergonomic API you could just write a wrapper function around the persistent term lookup. As someone’s done a lot with compiled modules in Absinthe persistent term is just so much better.
LostKobrakai
:persistent_term was added in response to people creating modules at runtime to store data. It explicitly is an api to replace what you’re doing with a native api, which gives the otp team a bit of control over the usecase over abusing unrelated apis around modules.
Namespacing shouldn’t really prevent you from using :persistent_term either.
benwilson512
While I agree that a lot of the uses of app config do seem like good candidates for persistent term, I do want to note that the benchmark is still showing tens of millions of operations per second. “Poor” isn’t really the way to look at it here.
It is curious to see the module doing about twice as fast though. Absinthe had the opposite experience BUT it had very large values that were very tricky to compile into a module.








