[Git][ghc/ghc][wip/T23312] nonmoving: Account for mutator allocations in bytes_allocated

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Thu Apr 27 12:39:39 UTC 2023



Ben Gamari pushed to branch wip/T23312 at Glasgow Haskell Compiler / GHC


Commits:
5bfbff20 by Ben Gamari at 2023-04-27T08:39:32-04:00
nonmoving: Account for mutator allocations in bytes_allocated

Previously we failed to account direct mutator allocations into the
nonmoving heap against the mutator's allocation limit and
`cap->total_allocated`. This only manifests during CAF evaluation (since
we allocate the CAF's blackhole directly into the nonmoving heap).

Fixes #23312.

- - - - -


3 changed files:

- rts/sm/NonMovingAllocate.c
- rts/sm/Storage.c
- rts/sm/Storage.h


Changes:

=====================================
rts/sm/NonMovingAllocate.c
=====================================
@@ -253,5 +253,9 @@ void *nonmovingAllocateGC(Capability *cap, StgWord sz)
 GNUC_ATTR_HOT
 void *nonmovingAllocate(Capability *cap, StgWord sz)
 {
+    // Handle "bytes allocated" accounting in the same way we
+    // do in Storage.c:allocate. See #23312.
+    accountAllocation(cap, sz);
+    cap->total_allocated += sz;
     return nonmovingAllocate_(SM_LOCK, cap, sz);
 }


=====================================
rts/sm/Storage.c
=====================================
@@ -966,7 +966,7 @@ move_STACK (StgStack *src, StgStack *dest)
     dest->sp = (StgPtr)dest->sp + diff;
 }
 
-STATIC_INLINE void
+void
 accountAllocation(Capability *cap, W_ n)
 {
     TICK_ALLOC_HEAP_NOCTR(WDS(n));


=====================================
rts/sm/Storage.h
=====================================
@@ -125,6 +125,8 @@ StgWord genLiveBlocks (generation *gen);
 StgWord calcTotalLargeObjectsW (void);
 StgWord calcTotalCompactW (void);
 
+void accountAllocation(Capability *cap, W_ n);
+
 /* ----------------------------------------------------------------------------
    Storage manager internal APIs and globals
    ------------------------------------------------------------------------- */



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bfbff20d9c867a50299c3ffd2b07da510cce31a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bfbff20d9c867a50299c3ffd2b07da510cce31a
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230427/7afe5684/attachment-0001.html>


More information about the ghc-commits mailing list