config: limit lcore variable maximum size to 4k
PATCH 1/1 config: limit lcore variable maximum size to 4k
OVS locks all pages to avoid page faults while processing packets. 1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.
At the moment, the more demanding DPDK user of lcore variable is rte_service, with a 2112 bytes object.
Limit the lcore variable maximum size to 4k which looks more reasonable.
--- config/rte_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
config/rte_config.h +1 -1
@@ -41,7 +41,7 @@/* EAL defines */ #define RTE_CACHE_GUARD_LINES 1#define RTE_MAX_HEAPS 32 -#define RTE_MAX_LCORE_VAR 1048576 +#define RTE_MAX_LCORE_VAR 4096#define RTE_MAX_MEMSEG_LISTS 128#define RTE_MAX_MEMSEG_PER_LIST 8192#define RTE_MAX_MEM_MB_PER_LIST 32768
Signature · 1 line
2.47.0
Quoted 8 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets. 1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.
Quoted 5 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.Limit the lcore variable maximum size to 4k which looks more reasonable.
4 KB is not future proof.
Here's an example where 16 KB is cutting it close:
https://inbox.dpdk.org/dev/[email protected]/
Depends on how we are going to use it. 4 KB suffices if we only want to use it for "small" structures.
Would 64 KB work as a compromise?
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
It sounds smart, so I just took a look at how it does this. I'm not sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 3 lines
Quoted 3 lines
1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.
Is the root cause the lcore variables library itself, or the unit test using a lot of memory for testing the lcore variables? We don't want to fix the library if the problem is elsewhere.
Quoted 17 lines
Quoted 6 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.Limit the lcore variable maximum size to 4k which looks more reasonable.
4 KB is not future proof.
Here's an example where 16 KB is cutting it close:
https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F7D0@smart
server.smartshare.dk/Depends on how we are going to use it. 4 KB suffices if we only want to use it for "small" structures.
Would 64 KB work as a compromise?
Thomas Monjalon
Applied08/11/2024 20:53, Morten Brørup:
Quoted 8 lines
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
Quoted 8 lines
It sounds smart, so I just took a look at how it does this. I'm not sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 3 lines
Quoted 3 lines
1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.Is the root cause the lcore variables library itself, or the unit test using a lot of memory for testing the lcore variables? We don't want to fix the library if the problem is elsewhere.
The fix works for our urgent issue and we want to make a release candidate soon.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.Limit the lcore variable maximum size to 4k which looks more reasonable.
Quoted 8 lines
Quoted 8 lines
4 KB is not future proof.
Here's an example where 16 KB is cutting it close:
https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F7D0@smart
server.smartshare.dk/Depends on how we are going to use it. 4 KB suffices if we only want to use it for "small" structures.
This is what is stated in the doc:
"Lcore variables are suitable for small objects"
"The amount of data kept in lcore variables is projected to be small"
Quoted 1 line
Quoted 1 line
Would 64 KB work as a compromise?
Let's consider based on the need.
The lcore variables are new and we don't want it to degrade the DPDK footprint, at least not in this first version.
4 KB is a memory page on common systems,
it looks reasonnable and big enough for a "variable".
Applied, thanks.
Quoted 41 lines · Thomas Monjalon
08/11/2024 20:53, Morten Brørup:
Quoted 8 lines
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
Quoted 8 lines
It sounds smart, so I just took a look at how it does this. I'm not sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 3 lines
Quoted 3 lines
1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.Is the root cause the lcore variables library itself, or the unit test using a lot of memory for testing the lcore variables? We don't want to fix the library if the problem is elsewhere.
The fix works for our urgent issue and we want to make a release candidate soon.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.Limit the lcore variable maximum size to 4k which looks more reasonable.
Quoted 8 lines
Quoted 8 lines
4 KB is not future proof.
Here's an example where 16 KB is cutting it close:
https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F7D0@smart
server.smartshare.dk/Depends on how we are going to use it. 4 KB suffices if we only want to use it for "small" structures.
This is what is stated in the doc:
"Lcore variables are suitable for small objects"
"The amount of data kept in lcore variables is projected to be small"Quoted 1 line
Quoted 1 line
Quoted 1 line
Would 64 KB work as a compromise?
Quoted 9 lines
Let's consider based on the need.
The lcore variables are new and we don't want it to degrade the DPDK footprint, at least not in this first version.
4 KB is a memory page on common systems,
it looks reasonnable and big enough for a "variable".Applied, thanks.
Why do you have maintainers if you just ignore them?
08/11/2024 23:34, Mattias Rönnblom:
Quoted 48 lines · Thomas Monjalon
Quoted 47 lines
08/11/2024 20:53, Morten Brørup:
Quoted 8 lines
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
Quoted 8 lines
It sounds smart, so I just took a look at how it does this. I'm not sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 3 lines
Quoted 3 lines
1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.Is the root cause the lcore variables library itself, or the unit test using a lot of memory for testing the lcore variables? We don't want to fix the library if the problem is elsewhere.
The fix works for our urgent issue and we want to make a release candidate soon.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.Limit the lcore variable maximum size to 4k which looks more reasonable.
Quoted 8 lines
Quoted 8 lines
4 KB is not future proof.
Here's an example where 16 KB is cutting it close:
https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F7D0@smart
server.smartshare.dk/Depends on how we are going to use it. 4 KB suffices if we only want to use it for "small" structures.
This is what is stated in the doc:
"Lcore variables are suitable for small objects"
"The amount of data kept in lcore variables is projected to be small"Quoted 1 line
Quoted 1 line
Quoted 1 line
Would 64 KB work as a compromise?
Let's consider based on the need.
The lcore variables are new and we don't want it to degrade the DPDK footprint, at least not in this first version.
4 KB is a memory page on common systems,
it looks reasonnable and big enough for a "variable".
Quoted 3 lines
Quoted 1 line
Applied, thanks.
Why do you have maintainers if you just ignore them?
I didn't receive your replies when I started to write this.
Please be comprehensive.
We are in a hurry to stabilize this before the release candidate which is already late.
I'll change to 128 KB as you recommend before pushing to the repository.
PS: maybe I should not have merged this feature in 24.11.
Quoted 51 lines · Thomas Monjalon
08/11/2024 23:34, Mattias Rönnblom:
Quoted 50 lines · Thomas Monjalon
Quoted 48 lines
08/11/2024 20:53, Morten Brørup:
Quoted 8 lines
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
Quoted 8 lines
It sounds smart, so I just took a look at how it does this. I'm not sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 3 lines
Quoted 3 lines
1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.Is the root cause the lcore variables library itself, or the unit test using a lot of memory for testing the lcore variables? We don't want to fix the library if the problem is elsewhere.
The fix works for our urgent issue and we want to make a release candidate soon.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.Limit the lcore variable maximum size to 4k which looks more reasonable.
Quoted 8 lines
Quoted 8 lines
4 KB is not future proof.
Here's an example where 16 KB is cutting it close:
https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F7D0@smart
server.smartshare.dk/Depends on how we are going to use it. 4 KB suffices if we only want to use it for "small" structures.
This is what is stated in the doc:
"Lcore variables are suitable for small objects"
"The amount of data kept in lcore variables is projected to be small"Quoted 1 line
Quoted 1 line
Quoted 1 line
Would 64 KB work as a compromise?
Let's consider based on the need.
The lcore variables are new and we don't want it to degrade the DPDK footprint, at least not in this first version.
4 KB is a memory page on common systems,
it looks reasonnable and big enough for a "variable".Applied, thanks.
Quoted 8 lines
Quoted 1 line
Why do you have maintainers if you just ignore them?
I didn't receive your replies when I started to write this.
Please be comprehensive.
We are in a hurry to stabilize this before the release candidate which is already late.I'll change to 128 KB as you recommend before pushing to the repository.
Thanks.
Quoted 2 lines
PS: maybe I should not have merged this feature in 24.11.
Ideally, it should have been merged earlier in the release cycle. I did offer the documentation you asked for as a separate patch, to be delivered later.
Quoted 11 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, 8 November 2024 23.13Let's consider based on the need.
The lcore variables are new and we don't want it to degrade the DPDK footprint,
at least not in this first version.
4 KB is a memory page on common systems,
it looks reasonnable and big enough for a "variable".Applied, thanks.
Changing this breaks the API/ABI.
I consider the 4 KB patch a temporary fix, only to make progress on the release candidate, but not the value to go into the final LTS release. In other words: I formally NAK this patch for the LTS release, but ACK it for the release candidate.
Let's postpone the discussion until after the release candidate.
Quoted 10 lines · Morten Brørup
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
It sounds smart, so I just took a look at how it does this. I'm not sure, but it seems like it only locks pages that are actually mapped (current and future).
mlockall(MLOCK_CURRENT) will bring in the whole BSS, it seems. Plus all the rest like unused parts of the execution stacks, the data section and unused code (text) in the binary and all libraries it has linked to.
It makes a simple (e.g., a unit test) DPDK 24.07 program use ~33x more residential memory. After lcore variables, the same MLOCK_CURRENT-ed program is ~30% larger than before. So, a relatively modest increase.
The numbers are less drastic, obviously, for many real-world programs, which have large packet pools and other memory hogs.
Quoted 25 lines
Quoted 3 lines
Quoted 3 lines
1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.Is the root cause the lcore variables library itself, or the unit test using a lot of memory for testing the lcore variables? We don't want to fix the library if the problem is elsewhere.
Quoted 17 lines
Quoted 6 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.Limit the lcore variable maximum size to 4k which looks more reasonable.
4 KB is not future proof.
Here's an example where 16 KB is cutting it close:
https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F7D0@smart
server.smartshare.dk/Depends on how we are going to use it. 4 KB suffices if we only want to use it for "small" structures.
Would 64 KB work as a compromise?
Quoted 17 lines
From: Mattias Rönnblom [mailto:[email protected]]
Sent: Friday, 8 November 2024 23.23Quoted 9 lines · Morten Brørup
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
It sounds smart, so I just took a look at how it does this. I'm not
sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 1 line
Quoted 8 lines
mlockall(MLOCK_CURRENT)will bring in the whole BSS, it seems. Plus all the rest like unused parts of the execution stacks, the data section and
unused code (text) in the binary and all libraries it has linked to.It makes a simple (e.g., a unit test) DPDK 24.07 program use ~33x more residential memory. After lcore variables, the same MLOCK_CURRENT-ed program is ~30% larger than before. So, a relatively modest increase.
Thank you for testing this, Mattias.
What are the absolute numbers, i.e. in KB, to get an idea of the numbers I should be looking for?
I wonder why the footprint grows at all... Intuitively the same variables should consume approximately the same amount of RAM, regardless how they are allocated.
Speculating...
The lcore_states were allocated through rte_calloc() and thus used some space in the already allocated hugepages, so they didn't add more pages to the footprint. But they do when allocated and initialized as lcore variables. The first lcore variable allocated/initialized uses RTE_MAX_LCORE (128) pages of 4 KB each = 512 KB total. It seems unlikely that adding 512 KB increases the footprint by 30 %.
Quoted 3 lines
The numbers are less drastic, obviously, for many real-world programs, which have large packet pools and other memory hogs.
Agree.
However, it would be good to understand why switching to lcore variables has this effect on the footprint when using mlockall() like OVS.
Quoted 22 lines · Morten Brørup
Quoted 22 lines
From: Mattias Rönnblom [mailto:[email protected]]
Sent: Friday, 8 November 2024 23.23Quoted 9 lines · Morten Brørup
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
It sounds smart, so I just took a look at how it does this. I'm not
sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 1 line
mlockall(MLOCK_CURRENT)will bring in the whole BSS, it seems. Plus all the rest like unused parts of the execution stacks, the data section and
unused code (text) in the binary and all libraries it has linked to.
Quoted 7 lines
Quoted 3 lines
It makes a simple (e.g., a unit test) DPDK 24.07 program use ~33x more residential memory. After lcore variables, the same MLOCK_CURRENT-ed program is ~30% larger than before. So, a relatively modest increase.
Thank you for testing this, Mattias.
What are the absolute numbers, i.e. in KB, to get an idea of the numbers I should be looking for?
Hello world type program with static linking. Default DPDK config. x86_64.
DPDK version MAX_LCORE_VAR EAL params mlock RSS [MB] 22.11 - --no-huge -m 1000 no 22 24.11 1048576 --no-huge -m 1000 no 22 24.11 1048576 --no-huge -m 1000 yes 1576 24.11 4096 --no-huge -m 1000 yes 1445 22.11 - - yes 333* 24.11 1048576 - yes 542* 24.11 4096 - yes 411*
* Excluding huge pages
If you are more selective what libraries you bring in, the footprint will be lower. How large a fraction is effectively unavoidable, I don't know. The relative increase will depends on how much memory the application uses, obviously. The hello world app doesn't have any app-level state.
Quoted 2 lines
I wonder why the footprint grows at all... Intuitively the same variables should consume approximately the same amount of RAM, regardless how they are allocated. Speculating...
lcore variables use malloc(), which in turn does not bring in memory pages unless they are needed. Much of the lcore buffer will be unused, and not resident. I covered this, including some example calculation of the space savings, in an earlier thread. It may be in the programmer's guide as well, I don't remember.
Quoted 3 lines
The
lcore_stateswere allocated throughrte_calloc()and thus used some space in the already allocated hugepages, so they didn't add more pages to the footprint. But they do when allocated and initialized as lcore variables. The first lcore variable allocated/initialized usesRTE_MAX_LCORE(128) pages of 4 KB each = 512 KB total. It seems unlikely that adding 512 KB increases the footprint by 30 %.
mlockall() brings in all currently-untouched malloc()ed pages, growing the set of residential pages.
Quoted 7 lines
Quoted 3 lines
The numbers are less drastic, obviously, for many real-world programs, which have large packet pools and other memory hogs.
Agree.
However, it would be good to understand why switching to lcore variables has this effect on the footprint when usingmlockall()like OVS.
Quoted 50 lines · On Mon, 11 Nov 2024 08:22:46 +0100 Mattias Rönnblom <[email protected]>…
Quoted 22 lines · Morten Brørup
Quoted 22 lines
From: Mattias Rönnblom [mailto:[email protected]]
Sent: Friday, 8 November 2024 23.23Quoted 9 lines · Morten Brørup
Quoted 7 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.35Quoted 4 lines
From: David Marchand [mailto:[email protected]]
Sent: Friday, 8 November 2024 19.18OVS locks all pages to avoid page faults while processing packets.
It sounds smart, so I just took a look at how it does this. I'm not
sure, but it seems like it only locks pages that are actually mapped (current and future).
Quoted 1 line
mlockall(MLOCK_CURRENT)will bring in the whole BSS, it seems. Plus all the rest like unused parts of the execution stacks, the data section and
unused code (text) in the binary and all libraries it has linked to.Quoted 7 lines
Quoted 3 lines
It makes a simple (e.g., a unit test) DPDK 24.07 program use ~33x more residential memory. After lcore variables, the same MLOCK_CURRENT-ed program is ~30% larger than before. So, a relatively modest increase.
Thank you for testing this, Mattias.
What are the absolute numbers, i.e. in KB, to get an idea of the numbers I should be looking for?Hello world type program with static linking. Default DPDK config.
x86_64.DPDK version MAX_LCORE_VAR EAL params mlock RSS [MB] 22.11 - --no-huge -m 1000 no 22 24.11 1048576 --no-huge -m 1000 no 22 24.11 1048576 --no-huge -m 1000 yes 1576 24.11 4096 --no-huge -m 1000 yes 1445 22.11 - - yes 333* 24.11 1048576 - yes 542* 24.11 4096 - yes 411** Excluding huge pages
If you are more selective what libraries you bring in, the footprint will be lower. How large a fraction is effectively unavoidable, I don't know. The relative increase will depends on how much memory the application uses, obviously. The hello world app doesn't have any app-level state.
Quoted 8 lines
Quoted 2 lines
I wonder why the footprint grows at all... Intuitively the same variables should consume approximately the same amount of RAM, regardless how they are allocated. Speculating...
lcore variables use
malloc(), which in turn does not bring in memory pages unless they are needed. Much of the lcore buffer will be unused, and not resident. I covered this, including some example calculation of the space savings, in an earlier thread. It may be in the programmer's guide as well, I don't remember.
I suspect that glibc malloc assumes a virtual memory backed model. It is lazy about reclaiming memory and grows in large chunks. This is one of the reasons malloc() is faster than rte_malloc() for allocation.
Mattias Rönnblom
NAKQuoted 5 lines · David Marchand
OVS locks all pages to avoid page faults while processing packets. 1M for each lcore translates to allocating 128M with default build options on x86.
This resulted in OOM while running unit tests in parallel.
Could you give some more context. If you get OOM if you add 128 MB of RSS, how much memory have you budgeted for the app in total? What are the packet mempool sizes, for example?
If you are running tests in parallel it likely means these aren't characteristics tests, and thus you can disable the mlockall() call and fit many more copies under the OOM ceiling.
Another alternative might be to unlock the lcore variables area, or make the whole BSS MLOCK_ONFAULT.
Quoted 3 lines
At the moment, the more demanding DPDK user of lcore variable is
rte_service, with a 2112 bytes object.
<rte_lcore_var.h> is a public API, so the largest object may well be much larger than that.
That said, maybe 1 MB is too large.
Quoted 2 lines
Limit the lcore variable maximum size to 4k which looks more reasonable.
NAK
128 kB?
Quoted 2 lines
Fixes 5bce9bed67ad ("eal: add static per-lcore memory allocation facility")
I've mentioned this property of lcore variables a couple of times on the list, so it should come as no surprise to anyone.
Quoted 18 lines
Signed-off-by David Marchand <[email protected]>--- config/rte_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)config/rte_config.h +1
-1@@ -41,7 +41,7 @@/* EAL defines */ #define RTE_CACHE_GUARD_LINES 1#define RTE_MAX_HEAPS 32 -#define RTE_MAX_LCORE_VAR 1048576 +#define RTE_MAX_LCORE_VAR 4096#define RTE_MAX_MEMSEG_LISTS 128#define RTE_MAX_MEMSEG_PER_LIST 8192#define RTE_MAX_MEM_MB_PER_LIST 32768