include JIT heap in used heap measurements
This commit is contained in:
parent
cc7b56ff30
commit
6f7e82e52b
@ -352,7 +352,7 @@ B heapStats_c1(B t, B x) {
|
||||
if (isC32(x)) {
|
||||
f64* rp; B r = m_f64arrv(&rp, 2);
|
||||
rp[0] = mm_heapAlloc;
|
||||
rp[1] = mm_heapUsed();
|
||||
rp[1] = tot_heapUsed();
|
||||
return r;
|
||||
}
|
||||
vfyStr(x, "•internal.HeapStats", "𝕩");
|
||||
|
||||
@ -48,7 +48,7 @@ void heap_PIFreedFn(Value* v) {
|
||||
void mm_forFreedHeap(V2v f);
|
||||
void heap_printInfo(bool sizes, bool types, bool freed, bool chain) {
|
||||
u64 total = mm_heapAlloc;
|
||||
u64 used = mm_heapUsed();
|
||||
u64 used = tot_heapUsed();
|
||||
fprintf(stderr, "RAM allocated: "N64u"\n", total);
|
||||
fprintf(stderr, "heap in use: "N64u"\n", used);
|
||||
#if MM!=0
|
||||
|
||||
2
src/h.h
2
src/h.h
@ -348,7 +348,7 @@ void gc_addFn(vfn f); // add function that calls mm_visit/mm_visitP for dynamic
|
||||
void gc_add_ref(B* x); // add x as a root reference
|
||||
bool gc_maybeGC(bool toplevel); // gc if that seems necessary; returns if did gc
|
||||
void gc_forceGC(bool toplevel); // force a gc; who knows what happens if gc is disabled (probably should error)
|
||||
u64 mm_heapUsed(void);
|
||||
u64 tot_heapUsed(void);
|
||||
#if HEAP_VERIFY
|
||||
void cbqn_heapVerify(void);
|
||||
#endif
|
||||
|
||||
@ -1,8 +1,15 @@
|
||||
#include "../core.h"
|
||||
#include "../vm.h"
|
||||
|
||||
u64 mm_heapUsed();
|
||||
#if JIT_START!=-1
|
||||
#include "nvm_x86_64.c"
|
||||
u64 tot_heapUsed() {
|
||||
return mm_heapUsed() + mmX_heapUsed();
|
||||
}
|
||||
#else
|
||||
#include "nvm_placeholder.c"
|
||||
u64 tot_heapUsed() {
|
||||
return mm_heapUsed();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -190,7 +190,7 @@ void gc_forceGC(bool toplevel) {
|
||||
u64 startTime=0, startSize=0;
|
||||
if (gc_log_enabled) {
|
||||
startTime = nsTime();
|
||||
startSize = mm_heapUsed();
|
||||
startSize = tot_heapUsed();
|
||||
#if GC_LOG_DETAILED
|
||||
gcs_visitBytes = 0; gcs_freedBytes = 0;
|
||||
gcs_visitCount = 0; gcs_freedCount = 0;
|
||||
@ -198,7 +198,7 @@ void gc_forceGC(bool toplevel) {
|
||||
#endif
|
||||
}
|
||||
gc_run(toplevel);
|
||||
u64 endSize = mm_heapUsed();
|
||||
u64 endSize = tot_heapUsed();
|
||||
if (gc_log_enabled) {
|
||||
fprintf(stderr, "GC: before: "N64d"B/"N64d"B", startSize, mm_heapAlloc);
|
||||
#if GC_LOG_DETAILED
|
||||
@ -217,7 +217,7 @@ void gc_forceGC(bool toplevel) {
|
||||
STATIC_GLOBAL bool gc_wantTopLevelGC;
|
||||
bool gc_maybeGC(bool toplevel) {
|
||||
if (gc_depth) return false;
|
||||
u64 used = mm_heapUsed();
|
||||
u64 used = tot_heapUsed();
|
||||
if (used > gc_lastAlloc*2 || (toplevel && gc_wantTopLevelGC)) {
|
||||
if (toplevel) gc_wantTopLevelGC = false;
|
||||
gc_forceGC(toplevel);
|
||||
|
||||
@ -16,6 +16,7 @@ GLOBAL u64 mm_ctrs[128];
|
||||
GLOBAL EmptyValue* mm_buckets[128];
|
||||
#define b1_buckets mm_buckets
|
||||
#define b1_allocL mm_allocL
|
||||
#define b1_ctrs mm_ctrs
|
||||
#define ALSZ 20
|
||||
#define BSZ(X) (1ull<<(X))
|
||||
#define MUL 1
|
||||
@ -27,6 +28,7 @@ GLOBAL EmptyValue* mm_buckets[128];
|
||||
|
||||
#define b3_buckets (mm_buckets+64)
|
||||
#define b3_allocL mm_allocL
|
||||
#define b3_ctrs (mm_ctrs+64)
|
||||
#define ALSZ 20
|
||||
#define BSZ(X) (3ull<<(X))
|
||||
#define MUL 3
|
||||
@ -59,8 +61,5 @@ void mm_dumpHeap(FILE* f) {
|
||||
}
|
||||
|
||||
u64 mm_heapUsed() {
|
||||
u64 r = 0;
|
||||
for (i32 i = 0; i < 64; i++) r+= mm_ctrs[i ] * (1ull<<i);
|
||||
for (i32 i = 0; i < 64; i++) r+= mm_ctrs[i+64] * (3ull<<i);
|
||||
return r;
|
||||
return b1_heapUsed() + b3_heapUsed();
|
||||
}
|
||||
|
||||
@ -17,11 +17,6 @@ GLOBAL EmptyValue* mm_buckets[64];
|
||||
#define BN(X) mm_##X
|
||||
#include "mm_buddyTemplate.c"
|
||||
|
||||
u64 mm_heapUsed() {
|
||||
u64 r = 0;
|
||||
for (i32 i = 0; i < 64; i++) r+= mm_ctrs[i]*BSZ(i);
|
||||
return r;
|
||||
}
|
||||
#undef BN
|
||||
#undef BSZ
|
||||
|
||||
|
||||
@ -186,6 +186,12 @@ static NOINLINE void BN(freeFreedAndMerge)() {
|
||||
}
|
||||
#endif
|
||||
|
||||
NOINLINE u64 BN(heapUsed)() {
|
||||
u64 r = 0;
|
||||
for (i32 i = 0; i < 64; i++) r+= BN(ctrs)[i]*BSZ(i);
|
||||
return r;
|
||||
}
|
||||
|
||||
void writeNum(FILE* f, u64 v, i32 len);
|
||||
void BN(dumpHeap)(FILE* f) {
|
||||
for (u64 i = 0; i < alSize; i++) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user