mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Make realloc() go 100x faster on Linux/NetBSD
Cosmopolitan now supports mremap(), which is only supported on Linux and NetBSD. First, it allows memory mappings to be relocated without copying them; this can dramatically speed up data structures like std::vector if the array size grows larger than 256kb. The mremap() system call is also 10x faster than munmap() when shrinking large memory mappings. There's now two functions, getpagesize() and getgransize() which help to write portable code that uses mmap(MAP_FIXED). Alternative sysconf() may be called with our new _SC_GRANSIZE. The madvise() system call now has a better wrapper with improved documentation.
This commit is contained in:
parent
196942084b
commit
f7780de24b
71 changed files with 1301 additions and 640 deletions
|
@ -41,11 +41,12 @@
|
|||
*
|
||||
* The following parameters are supported:
|
||||
*
|
||||
* - `_SC_PAGESIZE` returns page size for mmap()
|
||||
* - `_SC_GRANSIZE` returns addr alignment for mmap()
|
||||
* - `_SC_CLK_TCK` returns number of clock ticks per second
|
||||
* - `_SC_ARG_MAX` will perform expensive rlimit calculations
|
||||
* - `_SC_SIGSTKSZ` returns host platform's preferred SIGSTKSZ
|
||||
* - `_SC_MINSIGSTKSZ` returns host platform's required MINSIGSTKSZ
|
||||
* - `_SC_PAGESIZE` currently always returns 65536 due to Windows
|
||||
* - `_SC_AVPHYS_PAGES` returns average physical memory pages
|
||||
* - `_SC_PHYS_PAGES` returns physical memory pages available
|
||||
* - `_SC_NPROCESSORS_ONLN` returns number of effective CPUs
|
||||
|
@ -61,6 +62,8 @@ long sysconf(int name) {
|
|||
return CLK_TCK;
|
||||
case _SC_PAGESIZE:
|
||||
return getpagesize();
|
||||
case _SC_GRANSIZE:
|
||||
return getgransize();
|
||||
case _SC_ARG_MAX:
|
||||
return __get_arg_max();
|
||||
case _SC_SIGSTKSZ:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue