mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Make mmap() scalable
It's now possible to create thousands of thousands of sparse independent memory mappings, without any slowdown. The memory manager is better with tracking memory protection now, particularly on Windows in a precise way that can be restored during fork(). You now have the highest quality mem manager possible. It's even better than some OSes like XNU, where mmap() is implemented as an O(n) operation which means sadly things aren't much improved over there. With this change the llamafile HTTP server endpoint at /tokenize with a prompt of 50 tokens is now able to handle 2.6m r/sec
This commit is contained in:
parent
3756870635
commit
8c645fa1ee
59 changed files with 1238 additions and 1067 deletions
11
third_party/nsync/common.internal.h
vendored
11
third_party/nsync/common.internal.h
vendored
|
@ -24,19 +24,11 @@ void nsync_yield_(void);
|
|||
/* Retrieve the per-thread cache of the waiter object. Platform specific. */
|
||||
void *nsync_per_thread_waiter_(void (*dest)(void *));
|
||||
|
||||
/* Used in spinloops to delay resumption of the loop.
|
||||
Usage:
|
||||
unsigned attempts = 0;
|
||||
while (try_something) {
|
||||
attempts = nsync_spin_delay_ (attempts);
|
||||
} */
|
||||
unsigned nsync_spin_delay_(unsigned attempts);
|
||||
|
||||
/* Spin until (*w & test) == 0, then atomically perform *w = ((*w | set) &
|
||||
~clear), perform an acquire barrier, and return the previous value of *w.
|
||||
*/
|
||||
uint32_t nsync_spin_test_and_set_(nsync_atomic_uint32_ *w, uint32_t test,
|
||||
uint32_t set, uint32_t clear);
|
||||
uint32_t set, uint32_t clear, void *symbol);
|
||||
|
||||
/* Abort after printing the nul-temrinated string s[]. */
|
||||
void nsync_panic_(const char *s) wontreturn;
|
||||
|
@ -210,6 +202,7 @@ typedef struct waiter_s {
|
|||
struct wait_condition_s cond; /* A condition on which to acquire a mu. */
|
||||
struct Dll same_condition; /* Links neighbours in nw.q with same
|
||||
non-nil condition. */
|
||||
struct waiter_s * next_free;
|
||||
} waiter;
|
||||
static const uint32_t WAITER_TAG = 0x0590239f;
|
||||
static const uint32_t NSYNC_WAITER_TAG = 0x726d2ba9;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue