tcoopman

tcoopman

Should `Agent` support hibernate

I was reading the docs on Agent and noticed there is no mentions of hibernation at all.
Given that Agents are just wrappers around GenServers I was kinda surprised .

So I read through the code, but hibernate is not used at all.

Wouldn’t it make sense to support hibernate on Agent? I noticed that hibernation reduce memory consumption often a lot.

Most Liked

jeffheigl

jeffheigl

@tcoopman - Agent supports hibernate_after, I just tried and confirmed it works (using :observer I looked that the Processes → Current Function).

When you call Agent.start_link just pass in the hibernate_after option in miliseconds.

Looking at the code, Agent.start_link will pass through the options to GenServer.start_link

https://github.com/elixir-lang/elixir/blob/main/lib/elixir/lib/agent.ex#L276

dimitarvp

dimitarvp

You would think so, yep, but I’d say if you have enough Agents in memory that hibernating them would help you then you have a huge design problem. I mean, you would probably need 500K - 1M agents for this to make a tangible difference. And you absolutely should not have so many agents.

derek-zhou

derek-zhou

IMHO, Agent is just GenServer with training wheels. I moved to full GenServer for all Agents except the trivial ones. Maybe the core team think adding advanced features to a “training-wheel” API is not worth their time?

Where Next?

Popular in Discussions Top

lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
pdgonzalez872
If this has been asked here before, please point me to where it was asked as I didn’t find it when I searched the forum. Maybe a mailing ...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
slashdotdash
Phoenix Live View is now publicly available on GitHub. Here’s Chris McCord’s tweet announcing making it public.
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
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
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

We're in Beta

About us Mission Statement