-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
command line flag to limit heap memory usage? #17987
Comments
What kind of memory should the options limit? |
Limit on the heap would be the most useful I suppose. |
What heap though? A GC option to do GC more aggressively when approaching a user defined memory limit is possible, although there's a lot of memory that is allocated by user/C library as well as LLVM that we can't control. |
Yes more aggressive GC when approaching a user specified limit would significantly reduce memory consumption on JuliaBox. |
Also useful for running Julia in many shared settings where otherwise we will end up consuming all memory before the GC pressure kicks in. |
I think the limit that we pass as command line argument should be checked here:
And here:
Is that right? |
No,. It should be folded to how allocd is updated. |
Based on conversation with @yuyichao, the idea is to try and add a condition to detect memory pressure in the heuristic for full collection at
|
Also the decision of collection interval a few lines below (assignment to |
We call We use |
I think we can also update
|
There are requests on the mailing lists for something similar: https://groups.google.com/d/msg/julia-users/CNE3xBjpCEk/Je6zi-mxBAAJ |
I'm don't think I'm knowledgeable enough about any of this to make this PR, but I just thought I'd comment to say that there are definitely still people who can't use Julia in their HPC environment because of the sorts of problems referenced in #10390 / here. If I run 'julia -p 8' on either 0.5.1 or master, on a 64GB machine, the job hangs or I get "libsuitesparseconfig.so: failed to map segment from shared object: Cannot allocate memory" or reports that the processes didn't connect to Master within 60 seconds, etc. It was easy enough when I had to recompile from scratch just deleting "16*" in gc.c. Is there some sort of nasty quick fix like that I could do to just force it to work, or am I just going to have to pretend like every Julia process is going to eat 8GB of RAM? :P Edit: I just found the 16* thing in the gc-pages.c, |
That PR changes the GC to only allocate heap memory (RLIMIT_AS) as you use it. Thus the user-facing option is now simply not to allocate larger arrays than you intended to allocate. |
The two are actually unrelated since the option is about heap usage not about pool size. |
And FWIW #17987 (comment) is NOT what this issue is about. |
Thanks for the explanation Jameson. That helps in many situations. But for this issue, the following is what I had in mind: Say I own a machine with 8GB ram. I start a Julia process, and in that I run a program written by someone else. What I want to control is: if that program allocates anything more than 2Gb, throw an OutOfMemory error. Also, if the program has allocated 1.8GB, run the GC. How can I achieve that? |
@yuyichao You said in #10390 that the issue remaining last September there (at the end of the thread) was no longer #10390 but was instead this #17987. Yet deleting the 16* as I described in my comment above (and was given as a "fix" in #10390) fixed the issue I (and others on that thread) was having. I came here with my comment only because of your comment on 10390 when you closed the issue. If #21135 resolves any/all problems potentially stemming from the 16* in gc-pages.c (by making it unnecessary/etc.), then it solves #10390 (or whatever lingering problems from there, which you identified as being this issue). I'm sorry if this issue isn't actually the one now covering the problem people were having in 10390; it wasn't intentional. |
|
No. It's also pretty wrong since the GC would have to guess how much memory other libraries uses. OpenBLAS might allocate a lot at start up but it's very far from the library that can allocate the most memory. |
That would also roughly apply to the current usage of |
Kind of but not really. The current usage of total memory only set the max collection interval which is very different from total memory consumption. |
just chipping in to say that I still face exactly the same problem as in my comment on #10390. I have julia showing up as consuming about 4GB of resident ram, but virtual memory required is more than twice that - hence kills my job on a 8GB compute node. |
Bumping this back to awareness. In particular, the OOM killer of docker/kubernetes is nasty. Obviously it would be nicer if the attempt to allocate memory over a certain limit failed at the OS level, but it seems that requires changes to the Linux kernel that no one is interested in doing. In lieu of that, having arguments or autodetection in Julia that lets it know when to get more aggressive in GC and/or throw an exception when the memory limit is exceeded would be a godsend. Any idea where this is on the priority list? I would volunteer to implement it myself, but the learning curve of that area of the Julia source is rather sharp. |
I also have run into this on a slurm cluster. Would be nice to have some way to set the max memory of a node at process creation. |
while this is impossible to perfectly address ( |
added in #45369 |
To be fair, the new option |
It's a little stronger than "trigger collection if current memory usage is higher than limit". What it does (currently) is to make the GC collect much more frequently when memory is above the limit. I wouldn't be surprised if in the coming months it becomes more forceful, but we aren't there yet. |
That's fair enough, but doesn't this still mean that this issue is not resolved (yet), and so should not be closed just yet? |
heap-size-hint is now stronger. But perhaps it should be made even stronger by prohibiting any attempt to directly |
Should there be a command line flag to limit heap memory used by a Julia process?
Similar to
-Xms
and-Xmx
for the JVM.This may be useful while running Julia inside containers (docker) with memory limits or
running multiple Julia processes on the same machine.
The text was updated successfully, but these errors were encountered: