jsm
Package: module_store | Hex
Source: GitHub - juulSme/ModuleStore: Compiled-at-runtime modules as high-read-performance key-value stores in Elixir · GitHub
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.
Trending in Announcing
WebAuthnLiveComponent WebAuthnComponents
See this post about renaming the package.
Passwordless authentication for Phoenix LiveView app...
New
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I released Doggo, a collection of unstyled Phoenix components.
https://github.com/woylie/doggo
Features
Unstyled Phoenix components....
New
Hi everyone,
I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
I’ll shortly be launching Text, a nascent text analysis library.
Current functionality
In this early version (not ready for prime time) ...
New
Following on from my CLDR lbraries I started work on Unicode transforms. But like everything related to CLDR there is a lot of yak-shavin...
New
Other Trending Topics
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
What IDE or editor are you using for Elixir development?
Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
ltd
Is there a reason to not use the erlang builtin :persistent_term.
https://www.erlang.org/doc/apps/erts/persistent_term.html
jsm
I’m aware of
it’s quite similar of course. The difference is that persistent term is global, and you have to namespace your items by using tuple keys. Here you can have one or more module stores with just your stuff, which is nice. Your code will read 
:persistent_termMySpecialStore.get(...and it’s absolutely the fastest possible thing to have, which is also nice. Apart from writes of coursebenwilson512
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.
jsm
Thanks for the feedback and taking an interest
can you elaborate on the problems you encountered? Do you have reason to believe this approach won’t work or cause problems under real world conditions? I know you can’t store everything this way, like refs.
I’m aware modules are global too. But we still consider MyAppWeb.Endpoint to be my endpoint, as opposed to Phoenix.Endpoint, and it has its own config. So I was thinking among those lines.
LostKobrakai
:persistent_termwas 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_termeither.jsm
Ah I hadn’t realized that. I thought I was doing something similar but with slightly different runtime characteristics. I figured it would be a nice little self-contained thing to contribute back, just trying to help out. It seems I’m reinventing the wheel in a way that is less round then the original so it’s probably best to pull the lib
jsm
Then again, I the benchmark results do return some different results for compiled module vs persistent_term, especially with regards to the standard deviation (if the difference is significant is another question of course). That’s why I figured there might be a case for it.
I guess my question is: will this go horribly wrong in some way that I’m missing? If so, I’m really not to proud to pull the lib. If not, then why can’t this be out there as an alternative, apart from the fact that this is not what the compiler is meant to do?
stevensonmt
If we’re discussing abusing features of the language have you benchmarked against using the process dictionary? Using it for configs is specifically called out as a possible appropriate use case in this post:
wojtekmach
For some more prior art, also check out GitHub - discord/fastglobal: Fast no copy globals for Elixir & Erlang. · GitHub. But yeah, I believe persistent_term was designed to solve problems like these.
jsm
That’s really interesting, thanks for the link