fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.91k stars 284 forks source link

Periodic Memory Management #2781

Open pankgeorg opened 6 months ago

pankgeorg commented 6 months ago

Memory management on a Garbage Collected language is something people usually don't think about. Julia is a little bit different, in the sense that there isn't much memory monitoring going on the process, until the process starts feeling some memory pressure.

When the process does start to feel that memory pressure, it will aggressively run the GC when an allocation happens. This is not the time you'd want to run the GC, when a web request is inflight. Until julia is better at this (and if, because this approach is pretty good for a lot of use cases that julia addresses right now, e.g. doing math) we need to manage the GC a bit more manually.

Similar intent to https://github.com/fonsp/Pluto.jl/pull/2774#issuecomment-1895391327, but from the active size.

The methodology I'm describing seems to be a lot more important when big objects are being allocated periodically.

fonsp commented 6 months ago

Nice! Do you mean on the notebook process (https://github.com/fonsp/Pluto.jl/issues/1850) or the Pluto server? cc @BioTurboNick

fonsp commented 6 months ago

I think a useful first step is a MWE where memory goes up and a reproducible way to measure it

pankgeorg commented 6 months ago

Nice! Do you mean on the notebook process (https://github.com/fonsp/Pluto.jl/issues/1850) or the Pluto server? cc @BioTurboNick

I mainly have the server in mind. For the notebook process, the workload is not web-like/preemptive and in any case, it's much less predictable (And less statistically related to the one I've conducted analysis on)

I think a useful first step is a MWE where memory goes up and a reproducible way to measure it

Good point. The first step is adding observability, which is a whole new issue I'm going to open. Since OpenTelemetry seems to have a memory leak I wouldn't use that, but we can figure something simpler out.