1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 03:08:13 +00:00

LibC+UE: Keep more unused chunked blocks around

Previously each malloc size class would keep around a limited number of
unused blocks which were marked with MADV_SET_VOLATILE which could then
be reinitialized when additional blocks were needed.

This changes malloc() so that it also keeps around a number of blocks
without marking them with MADV_SET_VOLATILE. I termed these "hot"
blocks whereas blocks which were marked as MADV_SET_VOLATILE are called
"cold" blocks because they're more expensive to reinitialize.

In the worst case this could increase memory usage per process by
1MB when a program requests a bunch of memory and frees all of it.

Also, in order to make more efficient use of these unused blocks
they're now shared between size classes.
This commit is contained in:
Gunnar Beutner 2021-05-23 12:52:19 +02:00 committed by Andreas Kling
parent bd2b17a70e
commit 39f0739381
4 changed files with 93 additions and 35 deletions

View file

@ -1121,6 +1121,9 @@ int Emulator::virt$emuctl(FlatPtr arg1, FlatPtr arg2, FlatPtr arg3)
case 3:
tracer->target_did_realloc({}, arg3, arg2);
return 0;
case 4:
tracer->target_did_change_chunk_size({}, arg3, arg2);
return 0;
default:
return -EINVAL;
}