-
Notifications
You must be signed in to change notification settings - Fork 137
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
trim cache parameters for low memory operation #1883
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a heads up, with this change the tls klib cannot be used anymore in low-memory VMs, which means that such VMs won't be able to use the radar service, and won't be able to use HTTPS URLs to retrieve files or environment variables with the cloud_init klib.
Also, in low-memory VMs writes to network socket file descriptors will be limited to max 2KB (so the netsock and tun runtime tests will fail when run on a 64MB Qemu instance).
This comment no longer applies, since now we allow the use of arbitrary sizes for the malloc-style interface.
743c056
to
c451584
Compare
In an effort to minimize VM sizes, this change will cause runtime test executables to be stripped, saving unstripped binaries under the ".dbg" extension. The LDFLAGS and LIBS variables specified for each program are also duplicated for the debug build.
This change reduces baseline memory requirements for various memory caches under "low memory" conditions. If the function is_low_memory_machine() returns true, then the following parameters are trimmed: - the pagecache will use PAGECACHE_LOWMEM_CONTIGUOUS_PAGESIZE (default 128KB) as its objcache pagesize instead of PAGESIZE_2M - the mcache high order is lowered to 11 (2KB), thus forcing PAGESIZE or larger allocations to be made directly from the backing heap - and thus not cached, nor available for situations that implement a malloc/free interface - similiarly, allocations for lwIP are limited to a maximum size of 2KB
Given that there is limited queueing within the network stack, we can reasonably predict that only up to virtqueue_entries(vn->rxq) rx buffers will need to be cached - and similarly for tx handler completions. This adjusts the objcache parent pagesizes to accommodate only these requirements, regardless of whether the machine is in a 'low memory' configuration.
c451584
to
e19d349
Compare
This modifies the mcache to allow using a malloc/free-style interface (where the allocation size is not specified on a free()) when allocation sizes exceed the largest objcache size. Such use would previously result in an error when attempting to free such large allocations. To accomplish this, the mcache now maintains a mapping of large allocation addresses to their corresponding sizes. When a deallocate with an unspecified (-1ull) size occurs, a table lookup/removal is made to check if the address corresponds to such a "fallback" allocation and, if so, recover the allocation size. The cost of using this fallback table is an insertion when making a fallback (large) allocation and a table lookup/removal when deallocating a fallback allocation of a known size, or on any deallocation (free) of an unknown size. This should not impact the vast majority of mcache uses, for which 1) the allocation size falls within the domain of the contained objcaches and 2) the size parameter is valid on deallocation.
e19d349
to
cca7818
Compare
LGTM |
This change reduces baseline memory requirements for various memory caches
under "low memory" conditions. If the function is_low_memory_machine() returns
true, then the following parameters are minimized:
as its objcache pagesize instead of PAGESIZE_2M
larger allocations to be made directly from the backing heap - and thus not
cached, nor available for situations that implement a malloc/free interface
In addition:
under the ".dbg" extension
tx completion caches is set according to the rx and tx queue sizes
With these changes, it is possible to run a nanos instance capable of running the
'webs' web server in as little as 16MB of system memory.