* Stats record now contains gc-info fields.

This commit is contained in:
Abdulaziz Ghuloum 2007-08-30 12:54:21 -04:00
parent 46755415b4
commit f030e4e11d
6 changed files with 75 additions and 34 deletions

Binary file not shown.

View File

@ -258,6 +258,16 @@ gc_alloc_new_code(int size, int old_gen, gc_t* gc){
} }
} }
static void
add_to_collect_count(ikpcb* pcb, int bytes){
int minor = bytes + pcb->allocation_count_minor;
while(minor >= most_bytes_in_minor){
minor -= most_bytes_in_minor;
pcb->allocation_count_major++;
}
pcb->allocation_count_minor = minor;
}
@ -272,8 +282,10 @@ gc_tconc_push_extending(gc_t* gc, ikp tcbucket){
} }
ikp ap = ikp ap =
ik_mmap_typed(pagesize, ik_mmap_typed(pagesize,
meta_mt[meta_ptrs] | next_gen_tag[0], meta_mt[meta_ptrs] | next_gen_tag[gc->collect_gen],
//meta_mt[meta_ptrs] | next_gen_tag[0],
gc->pcb); gc->pcb);
add_to_collect_count(gc->pcb, pagesize);
gc->segment_vector = gc->pcb->segment_vector; gc->segment_vector = gc->pcb->segment_vector;
bzero(ap, pagesize); bzero(ap, pagesize);
ikp nap = ap + 2*wordsize; ikp nap = ap + 2*wordsize;
@ -351,6 +363,7 @@ static void fix_new_pages(gc_t* gc);
extern void verify_integrity(ikpcb* pcb, char*); extern void verify_integrity(ikpcb* pcb, char*);
ikpcb* ikpcb*
ik_collect(int mem_req, ikpcb* pcb){ ik_collect(int mem_req, ikpcb* pcb){
#ifndef NDEBUG #ifndef NDEBUG
@ -359,17 +372,13 @@ ik_collect(int mem_req, ikpcb* pcb){
{ /* ACCOUNTING */ { /* ACCOUNTING */
int bytes = ((int)pcb->allocation_pointer) - int bytes = ((int)pcb->allocation_pointer) -
((int)pcb->heap_base); ((int)pcb->heap_base);
int minor = bytes + pcb->allocation_count_minor; add_to_collect_count(pcb, bytes);
while(minor >= most_bytes_in_minor){
minor -= most_bytes_in_minor;
pcb->allocation_count_major++;
}
pcb->allocation_count_minor = minor;
} }
struct rusage t0, t1; struct rusage t0, t1;
struct timeval rt0, rt1;
gettimeofday(&rt0, 0);
getrusage(RUSAGE_SELF, &t0); getrusage(RUSAGE_SELF, &t0);
gc_t gc; gc_t gc;
@ -448,29 +457,10 @@ ik_collect(int mem_req, ikpcb* pcb){
#ifndef NDEBUG #ifndef NDEBUG
fprintf(stderr, "collect done\n"); fprintf(stderr, "collect done\n");
#endif #endif
getrusage(RUSAGE_SELF, &t1);
pcb->collect_utime.tv_usec += t1.ru_utime.tv_usec - t0.ru_utime.tv_usec;
pcb->collect_utime.tv_sec += t1.ru_utime.tv_sec - t0.ru_utime.tv_sec;
if (pcb->collect_utime.tv_usec >= 1000000){
pcb->collect_utime.tv_usec -= 1000000;
pcb->collect_utime.tv_sec += 1;
}
else if (pcb->collect_utime.tv_usec < 0){
pcb->collect_utime.tv_usec += 1000000;
pcb->collect_utime.tv_sec -= 1;
}
pcb->collect_stime.tv_usec += t1.ru_stime.tv_usec - t0.ru_stime.tv_usec;
pcb->collect_stime.tv_sec += t1.ru_stime.tv_sec - t0.ru_stime.tv_sec;
if (pcb->collect_stime.tv_usec >= 1000000){
pcb->collect_stime.tv_usec -= 1000000;
pcb->collect_stime.tv_sec += 1;
}
else if (pcb->collect_stime.tv_usec < 0){
pcb->collect_stime.tv_usec += 1000000;
pcb->collect_stime.tv_sec -= 1;
}
/* delete all old heap pages */ /* delete all old heap pages */
if(old_heap_pages){ if(old_heap_pages){
ikpages* p = old_heap_pages; ikpages* p = old_heap_pages;
@ -512,6 +502,44 @@ ik_collect(int mem_req, ikpcb* pcb){
#ifndef NDEBUG #ifndef NDEBUG
verify_integrity(pcb, "exit"); verify_integrity(pcb, "exit");
#endif #endif
getrusage(RUSAGE_SELF, &t1);
gettimeofday(&rt1, 0);
pcb->collect_utime.tv_usec += t1.ru_utime.tv_usec - t0.ru_utime.tv_usec;
pcb->collect_utime.tv_sec += t1.ru_utime.tv_sec - t0.ru_utime.tv_sec;
if (pcb->collect_utime.tv_usec >= 1000000){
pcb->collect_utime.tv_usec -= 1000000;
pcb->collect_utime.tv_sec += 1;
}
else if (pcb->collect_utime.tv_usec < 0){
pcb->collect_utime.tv_usec += 1000000;
pcb->collect_utime.tv_sec -= 1;
}
pcb->collect_stime.tv_usec += t1.ru_stime.tv_usec - t0.ru_stime.tv_usec;
pcb->collect_stime.tv_sec += t1.ru_stime.tv_sec - t0.ru_stime.tv_sec;
if (pcb->collect_stime.tv_usec >= 1000000){
pcb->collect_stime.tv_usec -= 1000000;
pcb->collect_stime.tv_sec += 1;
}
else if (pcb->collect_stime.tv_usec < 0){
pcb->collect_stime.tv_usec += 1000000;
pcb->collect_stime.tv_sec -= 1;
}
pcb->collect_rtime.tv_usec += rt1.tv_usec - rt0.tv_usec;
pcb->collect_rtime.tv_sec += rt1.tv_sec - rt0.tv_sec;
if (pcb->collect_rtime.tv_usec >= 1000000){
pcb->collect_rtime.tv_usec -= 1000000;
pcb->collect_rtime.tv_sec += 1;
}
else if (pcb->collect_rtime.tv_usec < 0){
pcb->collect_rtime.tv_usec += 1000000;
pcb->collect_rtime.tv_sec -= 1;
}
return pcb; return pcb;
} }

View File

@ -921,6 +921,12 @@ ikrt_stats_now(ikp t, ikpcb* pcb){
ref(t, off_record_data + 4 * wordsize) = fix(s.tv_sec); ref(t, off_record_data + 4 * wordsize) = fix(s.tv_sec);
ref(t, off_record_data + 5 * wordsize) = fix(s.tv_usec); ref(t, off_record_data + 5 * wordsize) = fix(s.tv_usec);
ref(t, off_record_data + 6 * wordsize) = fix(pcb->collection_id); ref(t, off_record_data + 6 * wordsize) = fix(pcb->collection_id);
ref(t, off_record_data + 7 * wordsize) = fix(pcb->collect_utime.tv_sec);
ref(t, off_record_data + 8 * wordsize) = fix(pcb->collect_utime.tv_usec);
ref(t, off_record_data + 9 * wordsize) = fix(pcb->collect_stime.tv_sec);
ref(t, off_record_data + 10 * wordsize) = fix(pcb->collect_stime.tv_usec);
ref(t, off_record_data + 11 * wordsize) = fix(pcb->collect_rtime.tv_sec);
ref(t, off_record_data + 12 * wordsize) = fix(pcb->collect_rtime.tv_usec);
return void_object; return void_object;
} }

View File

@ -144,7 +144,7 @@ typedef struct ikpcb{
int allocation_count_major; int allocation_count_major;
struct timeval collect_utime; struct timeval collect_utime;
struct timeval collect_stime; struct timeval collect_stime;
struct timeval collect_rtime;
} ikpcb; } ikpcb;

Binary file not shown.

View File

@ -4,10 +4,17 @@
(import (except (ikarus) time-it)) (import (except (ikarus) time-it))
(define-record stats (define-record stats
(user-secs user-usecs sys-secs sys-usecs real-secs real-usecs collection-id)) (user-secs user-usecs
sys-secs sys-usecs
real-secs real-usecs
collection-id
gc-user-secs gc-user-usecs
gc-sys-secs gc-sys-usecs
gc-real-secs gc-real-usecs
))
(define (mk-stats) (define (mk-stats)
(make-stats #f #f #f #f #f #f #f)) (make-stats #f #f #f #f #f #f #f #f #f #f #f #f #f))
(define (set-stats! t) (define (set-stats! t)
(foreign-call "ikrt_stats_now" t)) (foreign-call "ikrt_stats_now" t))