Pre-allocating memory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Pre-allocating memory

Rick Payne-2

I'm running the beam under OSv - a unikernel that tries to be ABI compatible with Linux, modulo a few things (such as no fork). Unfortunately, I'm seeing lots of memory fragmentation with my workload, probably due to issues in OSv's memory management.

I had thought there was a way to get erlang to preallocate memory in advance using super-carriers, such that i could then rely on the beam to manage memory and hopefully not suffer the same fragmentation issues. However, I am failing to make this work.

From my reading of the erts_alloc page, I have tried setting +MMscs to 8192 (as I want to allocate 8GB). This doesn't seem to happen (looking at the OSv stats - the memory isn't allocated). Have I misunderstood?

It could also be that some facilities are not supported by OSv (but it does support mmap for instance) - so a pointer as to what to check would be most useful.

Cheers,
Rick
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Pre-allocating memory

Mikael Pettersson-5
By default mmap() only sets up address space, but doesn't necessarily bind that address space to actual RAM.  Normally that binding is populated "on demand" via page faults.  (There are various flags to mmap() to modify this behaviour.)

Perhaps check if /proc/$pid/maps contains an 8GB anonymous mapping? (where $pid is the pid of your beam process)

On Mon, Nov 6, 2017 at 7:10 AM, Rick Payne <[hidden email]> wrote:

I'm running the beam under OSv - a unikernel that tries to be ABI compatible with Linux, modulo a few things (such as no fork). Unfortunately, I'm seeing lots of memory fragmentation with my workload, probably due to issues in OSv's memory management.

I had thought there was a way to get erlang to preallocate memory in advance using super-carriers, such that i could then rely on the beam to manage memory and hopefully not suffer the same fragmentation issues. However, I am failing to make this work.

From my reading of the erts_alloc page, I have tried setting +MMscs to 8192 (as I want to allocate 8GB). This doesn't seem to happen (looking at the OSv stats - the memory isn't allocated). Have I misunderstood?

It could also be that some facilities are not supported by OSv (but it does support mmap for instance) - so a pointer as to what to check would be most useful.

Cheers,
Rick
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Pre-allocating memory

Rick Payne-2


> On 7 Nov 2017, at 04:13, Mikael Pettersson <[hidden email]> wrote:
>
> By default mmap() only sets up address space, but doesn't necessarily bind that address space to actual RAM.  Normally that binding is populated "on demand" via page faults.  (There are various flags to mmap() to modify this behaviour.)

Ah, that could be it - it looks like adding MAP_POPULATE may help me. I'll see if modifying erts to do that will help...

Cheers,
Rick
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions