Make dlmalloc 2.4x faster for multithreading

This change adds a TLS freelist for small dynamic memory allocations.
Cosmopolitan's TIB is now 512 bytes in size. Single-threaded malloc()
performance isn't impacted by this, until pthread_create() is called.
Single-threaded programs may also want to consider using:

    #include "libc/mem/tinymalloc.inc"

Which will shave 30k off the executable size and sometimes go faster.
This commit is contained in:
Justine Tunney 2024-05-28 11:13:12 -07:00
parent deaef81463
commit 07cef612c3
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
9 changed files with 150 additions and 6 deletions

View file

@ -121,7 +121,7 @@ vfork:
// } else {
// __get_tls()->tib_flags &= ~TIB_FLAG_VFORKED;
// }
sub x1,x28,#192 // sizeof(CosmoTib)
sub x1,x28,#512 // sizeof(CosmoTib)
ldr x2,[x1,64]
cbnz x0,2f
orr x2,x2,#TIB_FLAG_VFORKED