diff options
author | Fabian Thorand <fabian@channable.com> | 2022-01-14 16:54:02 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-04-27 10:03:03 -0400 |
commit | 5de6be0c9120550aaa15534d0a1466018eff137a (patch) | |
tree | 9bb5b07063e6662ca79f48f065b7a593177ec00d /rts | |
parent | e39cab6256706e23d1e16177913dae190fe32e4f (diff) | |
download | haskell-5de6be0c9120550aaa15534d0a1466018eff137a.tar.gz |
Add note about inefficiency in returnMemoryToOS
Diffstat (limited to 'rts')
-rw-r--r-- | rts/sm/BlockAlloc.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c index d5651db6d8..d99d01d743 100644 --- a/rts/sm/BlockAlloc.c +++ b/rts/sm/BlockAlloc.c @@ -1190,6 +1190,14 @@ uint32_t returnMemoryToOS(uint32_t n /* megablocks */) uint32_t init_n; init_n = n; + // TODO: This is inefficient because this loop will essentially result in + // quadratic runtime behavior: for each call to `freeMBlocks`, the + // USE_LARGE_ADDRESS_SPACE implementation of it will walk the internal free + // list to insert it at the right position, and thus traverse all previously + // inserted values to get to it. We can do better though: both the internal + // free list and the `free_mblock_list` here are sorted, so one walk should + // be enough. + // ToDo: not fair, we free all the memory starting with node 0. for (node = 0; n > 0 && node < n_numa_nodes; node++) { bd = free_mblock_list[node]; |