diff options
author | neal <neal> | 2008-07-08 16:36:44 +0000 |
---|---|---|
committer | neal <neal> | 2008-07-08 16:36:44 +0000 |
commit | 7fac904370272d59b4631874ab8700686ccc20ac (patch) | |
tree | 8868de76b9fc0db08958dc6126eac53483b5dd0f | |
parent | 6df49ca1a377b5d0e70682ba7118076af2cc801a (diff) |
viengoos/
2008-07-08 Neal H. Walfield <neal@gnu.org>
* profile.h: Move to ../libc-parts.
* profile.c: Likewise.
* ager.c: Don't include "profile.h" but <profile.h>.
(update_stats): Replace use of profile_start and profile_end with
profile_region and profile_region_end.
libc-parts/
2008-07-08 Neal H. Walfield <neal@gnu.org>
* profile.h: Moved here from ../viengoos/profile.h.
(profile_region): New macro.
(profile_region_end): Likewise.
(profile_start) [NPROFILE]: Do nothing in this case.
(profile_end) [NPROFILE]: Likewise.
(profile_stats_dump) [NPROFILE]: Likewise.
* profile.c: Moved here from ../viengoos/profile.c.
(profile_start) [! RM_INTERN]: Use a static buffer.
* Makefile.am (common_sources): Add fields profile.c and
profile.h.
benchmarks/boehm-gc/
2008-07-08 Neal H. Walfield <neal@gnu.org>
* patches/04-gc-alloc-c.patch: Remove file.
* patches/05-viengoos-scheduler.patch: Merge changes into this
one. Remove cruft. Update profile code. Tweak scheduler.
* Makefile.am (patch_files): Remove 04-gc-alloc-c.patch.
-rw-r--r-- | benchmarks/boehm-gc/ChangeLog | 7 | ||||
-rw-r--r-- | benchmarks/boehm-gc/Makefile.am | 1 | ||||
-rw-r--r-- | benchmarks/boehm-gc/patches/04-gc-alloc-c.patch | 208 | ||||
-rw-r--r-- | benchmarks/boehm-gc/patches/05-viengoos-scheduler.patch | 376 | ||||
-rw-r--r-- | libc-parts/ChangeLog | 13 | ||||
-rw-r--r-- | libc-parts/profile.c (renamed from viengoos/profile.c) | 69 | ||||
-rw-r--r-- | libc-parts/profile.h (renamed from viengoos/profile.h) | 27 | ||||
-rw-r--r-- | viengoos/ChangeLog | 8 | ||||
-rw-r--r-- | viengoos/ager.c | 6 |
9 files changed, 251 insertions, 464 deletions
diff --git a/benchmarks/boehm-gc/ChangeLog b/benchmarks/boehm-gc/ChangeLog index 029ba2d..53d8685 100644 --- a/benchmarks/boehm-gc/ChangeLog +++ b/benchmarks/boehm-gc/ChangeLog @@ -1,3 +1,10 @@ +2008-07-08 Neal H. Walfield <neal@gnu.org> + + * patches/04-gc-alloc-c.patch: Remove file. + * patches/05-viengoos-scheduler.patch: Merge changes into this + one. Remove cruft. Update profile code. Tweak scheduler. + * Makefile.am (patch_files): Remove 04-gc-alloc-c.patch. + 2008-07-04 Neal H. Walfield <neal@gnu.org> * patches/05-viengoos-scheduler.patch: Fix profile.h chunk. diff --git a/benchmarks/boehm-gc/Makefile.am b/benchmarks/boehm-gc/Makefile.am index 394e503..80c98fa 100644 --- a/benchmarks/boehm-gc/Makefile.am +++ b/benchmarks/boehm-gc/Makefile.am @@ -24,7 +24,6 @@ include $(top_srcdir)/Makefoo.am patch_files = 01-gc-include-private-gcconfig-h.patch \ 02-gc-mach_dep-c.patch \ 03-gc-configure-ac.patch \ - 04-gc-alloc-c.patch \ 05-viengoos-scheduler.patch # Files to link into newlib's source tree (relative to $(srcdir)/addon) diff --git a/benchmarks/boehm-gc/patches/04-gc-alloc-c.patch b/benchmarks/boehm-gc/patches/04-gc-alloc-c.patch deleted file mode 100644 index b2da1d2..0000000 --- a/benchmarks/boehm-gc/patches/04-gc-alloc-c.patch +++ /dev/null @@ -1,208 +0,0 @@ -#! /bin/sh -patch -p1 -f $* < $0 -exit $? - -Instrument gc code. - ---- gc/alloc.c~ 2007-06-22 04:40:30.000000000 +0200 -+++ gc/alloc.c 2008-06-18 16:51:20.000000000 +0200 -@@ -24,6 +24,69 @@ - # include <sys/types.h> - # endif - -+uint64_t gc_time; -+ -+static inline uint64_t -+now (void) -+{ -+ struct timeval t; -+ struct timezone tz; -+ -+ if (gettimeofday( &t, &tz ) == -1) -+ return 0; -+ return (t.tv_sec * 1000000 + t.tv_usec); -+ -+} -+ -+static int timing; -+ -+static uint64_t -+start_timing (const char *func, int lineno) -+{ -+ static const char *timing_func; -+ static int timing_lineno; -+ -+ if (timing) -+ { -+ printf ("Timing for %s:%d but start_timing called from %s:%d\n", -+ timing_func, timing_lineno, func, lineno); -+ assert (! timing); -+ } -+ -+ timing_func = func; -+ timing_lineno = lineno; -+ -+ timing = 1; -+ -+ return now (); -+} -+ -+static void -+end_timing (const char *func, int lineno, uint64_t start) -+{ -+ uint64_t end = now (); -+ -+ if (! timing) -+ { -+ printf ("Timing not started by end_timing called from %s:%d!\n", -+ func, lineno); -+ assert (! timing); -+ } -+ timing = 0; -+ -+ assert (start <= end); -+ gc_time += end - start; -+} -+ -+#define start_timing() \ -+ do { \ -+ uint64_t start = start_timing (__FUNCTION__, __LINE__) -+ -+#define end_timing() \ -+ end_timing (__FUNCTION__, __LINE__, start); \ -+ } while (0) -+ -+ - /* - * Separate free lists are maintained for different sized objects - * up to MAXOBJBYTES. -@@ -256,6 +319,8 @@ - n_partial_gcs = 0; - return; - } else { -+ start_timing (); -+ - # ifdef PARALLEL_MARK - GC_wait_for_reclaim(); - # endif -@@ -266,6 +331,7 @@ - (unsigned long)GC_gc_no+1, - (long)GC_bytes_allocd); - } -+ - GC_promote_black_lists(); - (void)GC_reclaim_all((GC_stop_func)0, TRUE); - GC_clear_marks(); -@@ -275,7 +341,11 @@ - } else { - n_partial_gcs++; - } -+ -+ end_timing (); - } -+ -+ start_timing (); - /* We try to mark with the world stopped. */ - /* If we run out of time, this turns into */ - /* incremental marking. */ -@@ -294,6 +364,8 @@ - GC_n_attempts++; - } - } -+ -+ end_timing (); - } - } - -@@ -325,6 +397,10 @@ - "Initiating full world-stop collection %lu after %ld allocd bytes\n", - (unsigned long)GC_gc_no+1, (long)GC_bytes_allocd); - } -+ -+ GC_bool ret = true; -+ start_timing (); -+ - GC_promote_black_lists(); - /* Make sure all blocks have been reclaimed, so sweep routines */ - /* don't see cleared mark bits. */ -@@ -337,7 +413,8 @@ - if ((GC_find_leak || stop_func != GC_never_stop_func) - && !GC_reclaim_all(stop_func, FALSE)) { - /* Aborted. So far everything is still consistent. */ -- return(FALSE); -+ ret = FALSE; -+ break; - } - GC_invalidate_mark_state(); /* Flush mark stack. */ - GC_clear_marks(); -@@ -354,7 +431,8 @@ - GC_unpromote_black_lists(); - } /* else we claim the world is already still consistent. We'll */ - /* finish incrementally. */ -- return(FALSE); -+ ret = FALSE; -+ break; - } - GC_finish_collection(); - if (GC_print_stats) { -@@ -362,7 +440,9 @@ - GC_log_printf("Complete collection took %lu msecs\n", - MS_TIME_DIFF(current_time,start_time)); - } -- return(TRUE); -+ -+ end_timing (); -+ return ret; - } - - -@@ -390,6 +470,8 @@ - - if (GC_dont_gc) return; - if (GC_incremental && GC_collection_in_progress()) { -+ start_timing (); -+ - for (i = GC_deficit; i < GC_RATE*n; i++) { - if (GC_mark_some((ptr_t)0)) { - /* Need to finish a collection */ -@@ -415,6 +497,8 @@ - } - if (GC_deficit > 0) GC_deficit -= GC_RATE*n; - if (GC_deficit < 0) GC_deficit = 0; -+ -+ end_timing (); - } else { - GC_maybe_gc(); - } -@@ -1021,3 +1105,30 @@ - - return(*flh); - } -+ -+ -+void -+GC_dump_stats (void) -+{ -+ printf ("GC: " -+#ifdef THREADS -+ "multi-threaded" -+#else -+ "single threaded" -+#endif -+ ", %s, " -+#ifndef PARALLEL_MARK -+ "non-" -+#endif -+ "parallel mark, dirty bits %smaintained\n", -+ TRUE_INCREMENTAL ? "true incremental" : -+ GC_incremental ? "generational" : "stop the world", -+ GC_dirty_maintained ? "" : "not "); -+ printf("%d collections\n", (int) GC_gc_no); -+ printf ("%lld.%03lld seconds spent collecting\n", -+ gc_time / 1000000, (gc_time % 1000000) / 1000); -+ printf("Heap size: %d (%d kb)\n", -+ GC_get_heap_size(), GC_get_heap_size() / 1024); -+ printf("Total bytes allocated: %d (%d kb)\n", -+ GC_get_total_bytes (), GC_get_total_bytes () / 1024); -+} - diff --git a/benchmarks/boehm-gc/patches/05-viengoos-scheduler.patch b/benchmarks/boehm-gc/patches/05-viengoos-scheduler.patch index 63544fd..10b5cc2 100644 --- a/benchmarks/boehm-gc/patches/05-viengoos-scheduler.patch +++ b/benchmarks/boehm-gc/patches/05-viengoos-scheduler.patch @@ -6,10 +6,9 @@ Patch to support the Viengoos specific scheduler. To disable it, set GC_viengoos_scheduler to 0. -Only in gc: 05-viengoos-scheduler.patch.applied -diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m4 gc-old/allchblk.c gc/allchblk.c ---- gc-old/allchblk.c 2007-06-07 02:40:07.000000000 +0200 -+++ gc/allchblk.c 2008-06-27 17:01:49.000000000 +0200 +diff -uprN -x '*.applied' -x config.guess -x '*~' -x autom4te.cache -x config.sub -x configure gc.orig/allchblk.c gc/allchblk.c +--- gc.orig/allchblk.c 2007-06-07 02:40:07.000000000 +0200 ++++ gc/allchblk.c 2008-07-05 16:08:59.000000000 +0200 @@ -117,7 +117,9 @@ void GC_print_hblkfreelist() while (h != 0) { hhdr = HDR(h); @@ -55,8 +54,8 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m + if (0) + printf ("%x: After unmapping %d used (%d available)\n", + l4_myself (), -+ (GC_get_heap_size() - GC_unmapped_bytes) / PAGESIZE, -+ GC_available_bytes / PAGESIZE); ++ (GC_get_heap_size() - GC_unmapped_bytes) / 4096, ++ GC_available_bytes / 4096); + return; + } + @@ -230,10 +229,9 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m if (0 == hbp) return 0; /* Add it to map of valid blocks */ -Only in gc: allchblk.c~ -diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m4 gc-old/alloc.c gc/alloc.c ---- gc-old/alloc.c 2008-06-27 17:02:33.000000000 +0200 -+++ gc/alloc.c 2008-06-27 17:01:08.000000000 +0200 +diff -uprN -x '*.applied' -x config.guess -x '*~' -x autom4te.cache -x config.sub -x configure gc.orig/alloc.c gc/alloc.c +--- gc.orig/alloc.c 2007-06-22 04:40:30.000000000 +0200 ++++ gc/alloc.c 2008-07-08 16:52:55.000000000 +0200 @@ -15,6 +15,13 @@ * */ @@ -248,77 +246,16 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m # include "private/gc_priv.h" -@@ -24,68 +31,7 @@ +@@ -24,6 +31,8 @@ # include <sys/types.h> # endif --uint64_t gc_time; -- --static inline uint64_t --now (void) --{ -- struct timeval t; -- struct timezone tz; -- -- if (gettimeofday( &t, &tz ) == -1) -- return 0; -- return (t.tv_sec * 1000000 + t.tv_usec); -- --} -- --static int timing; -- --static uint64_t --start_timing (const char *func, int lineno) --{ -- static const char *timing_func; -- static int timing_lineno; -- -- if (timing) -- { -- printf ("Timing for %s:%d but start_timing called from %s:%d\n", -- timing_func, timing_lineno, func, lineno); -- assert (! timing); -- } -- -- timing_func = func; -- timing_lineno = lineno; -- -- timing = 1; -- -- return now (); --} -- --static void --end_timing (const char *func, int lineno, uint64_t start) --{ -- uint64_t end = now (); -- -- if (! timing) -- { -- printf ("Timing not started by end_timing called from %s:%d!\n", -- func, lineno); -- assert (! timing); -- } -- timing = 0; -- -- assert (start <= end); -- gc_time += end - start; --} -- --#define start_timing() \ -- do { \ -- uint64_t start = start_timing (__FUNCTION__, __LINE__) -- --#define end_timing() \ -- end_timing (__FUNCTION__, __LINE__, start); \ -- } while (0) -- +#include "profile.h" - ++ /* * Separate free lists are maintained for different sized objects -@@ -286,9 +232,134 @@ void GC_clear_a_few_frames() + * up to MAXOBJBYTES. +@@ -223,9 +232,134 @@ void GC_clear_a_few_frames() /* limits used by blacklisting. */ static word GC_collect_at_heapsize = (word)(-1); @@ -392,11 +329,6 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m + if (GC_viengoos_scheduler) + { + int alloced = GC_adj_bytes_allocd(); -+ if (alloced < min_bytes_allocd()) -+ /* If we have not allocated anything since the last -+ collection, don't do a collection. */ -+ return FALSE; -+ +#ifdef __gnu_hurd_viengoos__ + static int init; + if (! init) @@ -426,6 +358,11 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m + } + + if (r) { ++ if (alloced < GC_available_bytes / 100) ++ /* If we have not allocated anything since the last ++ collection, don't do a collection. */ ++ return FALSE; ++ + static int warning; + /* Only print this once per-gc. GC_allochblk_nth calls this + function repeatedly without immediately following up with @@ -453,127 +390,149 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m return(GC_adj_bytes_allocd() >= min_bytes_allocd() || GC_heapsize >= GC_collect_at_heapsize); } -@@ -319,7 +390,7 @@ void GC_maybe_gc(void) +@@ -256,6 +390,8 @@ void GC_maybe_gc(void) n_partial_gcs = 0; return; } else { -- start_timing (); -+ profile_start (GC_TIMER); - ++ profile_region (GC_TIMER); ++ # ifdef PARALLEL_MARK GC_wait_for_reclaim(); -@@ -342,10 +413,10 @@ void GC_maybe_gc(void) + # endif +@@ -266,6 +402,7 @@ void GC_maybe_gc(void) + (unsigned long)GC_gc_no+1, + (long)GC_bytes_allocd); + } ++ + GC_promote_black_lists(); + (void)GC_reclaim_all((GC_stop_func)0, TRUE); + GC_clear_marks(); +@@ -275,7 +412,11 @@ void GC_maybe_gc(void) + } else { n_partial_gcs++; } - -- end_timing (); -+ profile_end (GC_TIMER); ++ ++ profile_region_end (); } - -- start_timing (); -+ profile_start (GC_TIMER); ++ ++ profile_region (GC_TIMER); /* We try to mark with the world stopped. */ /* If we run out of time, this turns into */ /* incremental marking. */ -@@ -365,7 +436,7 @@ void GC_maybe_gc(void) +@@ -294,6 +435,8 @@ void GC_maybe_gc(void) + GC_n_attempts++; } } - -- end_timing (); -+ profile_end (GC_TIMER); ++ ++ profile_region_end (); } } -@@ -396,10 +467,18 @@ GC_bool GC_try_to_collect_inner(GC_stop_ - GC_log_printf( +@@ -325,6 +468,10 @@ GC_bool GC_try_to_collect_inner(GC_stop_ "Initiating full world-stop collection %lu after %ld allocd bytes\n", (unsigned long)GC_gc_no+1, (long)GC_bytes_allocd); -+ -+ extern int backtrace (void **array, int size); -+ void *a[10]; -+ int c = backtrace (a, 10); -+ int i; -+ for (i = 0; i < c; i ++) -+ GC_log_printf("%p ", a[i]); -+ GC_log_printf("\n"); } - -- GC_bool ret = true; -- start_timing (); ++ + GC_bool ret = TRUE; -+ profile_start (GC_TIMER); - ++ profile_region (GC_TIMER); ++ GC_promote_black_lists(); /* Make sure all blocks have been reclaimed, so sweep routines */ -@@ -414,7 +493,7 @@ GC_bool GC_try_to_collect_inner(GC_stop_ + /* don't see cleared mark bits. */ +@@ -337,7 +484,8 @@ GC_bool GC_try_to_collect_inner(GC_stop_ + if ((GC_find_leak || stop_func != GC_never_stop_func) && !GC_reclaim_all(stop_func, FALSE)) { /* Aborted. So far everything is still consistent. */ - ret = FALSE; -- break; +- return(FALSE); ++ ret = FALSE; + goto out; } GC_invalidate_mark_state(); /* Flush mark stack. */ GC_clear_marks(); -@@ -432,7 +511,7 @@ GC_bool GC_try_to_collect_inner(GC_stop_ +@@ -354,7 +502,8 @@ GC_bool GC_try_to_collect_inner(GC_stop_ + GC_unpromote_black_lists(); } /* else we claim the world is already still consistent. We'll */ /* finish incrementally. */ - ret = FALSE; -- break; +- return(FALSE); ++ ret = FALSE; + goto out; } GC_finish_collection(); if (GC_print_stats) { -@@ -441,7 +520,8 @@ GC_bool GC_try_to_collect_inner(GC_stop_ +@@ -362,7 +511,10 @@ GC_bool GC_try_to_collect_inner(GC_stop_ + GC_log_printf("Complete collection took %lu msecs\n", MS_TIME_DIFF(current_time,start_time)); } - -- end_timing (); +- return(TRUE); ++ + out: -+ profile_end (GC_TIMER); - return ret; ++ profile_region_end (); ++ return ret; } -@@ -470,7 +550,7 @@ void GC_collect_a_little_inner(int n) + +@@ -390,6 +542,8 @@ void GC_collect_a_little_inner(int n) if (GC_dont_gc) return; if (GC_incremental && GC_collection_in_progress()) { -- start_timing (); -+ profile_start (GC_TIMER); - ++ profile_region (GC_TIMER); ++ for (i = GC_deficit; i < GC_RATE*n; i++) { if (GC_mark_some((ptr_t)0)) { -@@ -498,7 +578,7 @@ void GC_collect_a_little_inner(int n) + /* Need to finish a collection */ +@@ -415,6 +569,8 @@ void GC_collect_a_little_inner(int n) + } if (GC_deficit > 0) GC_deficit -= GC_RATE*n; if (GC_deficit < 0) GC_deficit = 0; - -- end_timing (); -+ profile_end (GC_TIMER); ++ ++ profile_region_end (); } else { GC_maybe_gc(); } -@@ -1110,6 +1190,8 @@ ptr_t GC_allocobj(size_t gran, int kind) - void - GC_dump_stats (void) - { +@@ -904,6 +1060,8 @@ GC_bool GC_expand_hp_inner(word n) + /* Force GC before we are likely to allocate past expansion_slop */ + GC_collect_at_heapsize = + GC_heapsize + expansion_slop - 2*MAXHINCR*HBLKSIZE; ++ GC_collect_at_heapsize = ++ GC_heapsize + expansion_slop - 2*MAXHINCR*HBLKSIZE; + # if defined(LARGE_CONFIG) + if (GC_collect_at_heapsize < GC_heapsize /* wrapped */) + GC_collect_at_heapsize = (word)(-1); +@@ -1021,3 +1179,146 @@ ptr_t GC_allocobj(size_t gran, int kind) + + return(*flh); + } ++ ++ ++void ++GC_dump_stats (void) ++{ + extern uint64_t gc_map_time; + - printf ("GC: " - #ifdef THREADS - "multi-threaded" -@@ -1125,10 +1207,123 @@ GC_dump_stats (void) - GC_incremental ? "generational" : "stop the world", - GC_dirty_maintained ? "" : "not "); - printf("%d collections\n", (int) GC_gc_no); -- printf ("%lld.%03lld seconds spent collecting\n", -- gc_time / 1000000, (gc_time % 1000000) / 1000); - printf("Heap size: %d (%d kb)\n", - GC_get_heap_size(), GC_get_heap_size() / 1024); - printf("Total bytes allocated: %d (%d kb)\n", - GC_get_total_bytes (), GC_get_total_bytes () / 1024); ++ printf ("GC: " ++#ifdef THREADS ++ "multi-threaded" ++#else ++ "single threaded" ++#endif ++ ", %s, " ++#ifndef PARALLEL_MARK ++ "non-" ++#endif ++ "parallel mark, dirty bits %smaintained\n", ++ TRUE_INCREMENTAL ? "true incremental" : ++ GC_incremental ? "generational" : "stop the world", ++ GC_dirty_maintained ? "" : "not "); ++ printf("%d collections\n", (int) GC_gc_no); ++ printf("Heap size: %d (%d kb)\n", ++ GC_get_heap_size(), GC_get_heap_size() / 1024); ++ printf("Total bytes allocated: %d (%d kb)\n", ++ GC_get_total_bytes (), GC_get_total_bytes () / 1024); + + profile_stats_dump (); +} + ++#ifndef __gnu_hurd_viengoos__ +/* profile.c - Profiling support implementation. + Copyright (C) 2008 Free Software Foundation, Inc. + Written by Neal H. Walfield <neal@gnu.org>. @@ -661,10 +620,10 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m + site->pending ++; + if (site->pending == 1) + site->start = now (); - } ++} + +void -+profile_end (uintptr_t id, const char *name) ++profile_end (uintptr_t id) +{ + struct site *site = &sites[id]; + assert (site->pending); @@ -685,14 +644,10 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m + calls ++; + } +} -+ -Only in gc: alloc.c~ -Only in gc: atomic_ops.c -Only in gc: atomic_ops_sysdeps.S -Only in gc: autom4te.cache -diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m4 gc-old/include/private/gcconfig.h gc/include/private/gcconfig.h ---- gc-old/include/private/gcconfig.h 2008-06-27 17:02:33.000000000 +0200 -+++ gc/include/private/gcconfig.h 2008-06-26 10:41:11.000000000 +0200 ++#endif +diff -uprN -x '*.applied' -x config.guess -x '*~' -x autom4te.cache -x config.sub -x configure gc.orig/include/private/gcconfig.h gc/include/private/gcconfig.h +--- gc.orig/include/private/gcconfig.h 2008-07-08 16:47:51.000000000 +0200 ++++ gc/include/private/gcconfig.h 2008-07-02 16:17:26.000000000 +0200 @@ -1087,6 +1087,8 @@ # ifdef LINUX # define OS_TYPE "LINUX" @@ -715,44 +670,9 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m # endif # ifdef DARWIN # define OS_TYPE "DARWIN" -Only in gc: libatomic_ops -Only in gc/libatomic_ops-1.2: .cvsignore -Only in gc/libatomic_ops-1.2/doc: .cvsignore -Only in gc/libatomic_ops-1.2/src/atomic_ops: .cvsignore -Only in gc/libatomic_ops-1.2/src/atomic_ops/sysdeps: .cvsignore -Only in gc/libatomic_ops-1.2/src: .cvsignore -Only in gc/libatomic_ops-1.2/tests: .cvsignore -diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m4 gc-old/malloc.c gc/malloc.c ---- gc-old/malloc.c 2007-06-06 22:48:35.000000000 +0200 -+++ gc/malloc.c 2008-06-26 10:41:13.000000000 +0200 -@@ -269,7 +269,9 @@ void * GC_generic_malloc(size_t lb, int - LOCK(); - if( EXPECT((op = *opp) == 0, 0) ) { - UNLOCK(); -- return(GENERAL_MALLOC((word)lb, NORMAL)); -+ void *p = GENERAL_MALLOC((word)lb, NORMAL); -+ GC_ASSERT (p); -+ return(p); - } - /* See above comment on signals. */ - GC_ASSERT(0 == obj_link(op) -@@ -281,9 +283,12 @@ void * GC_generic_malloc(size_t lb, int - obj_link(op) = 0; - GC_bytes_allocd += GRANULES_TO_BYTES(lg); - UNLOCK(); -+ GC_ASSERT (op); - return op; - } else { -- return(GENERAL_MALLOC(lb, NORMAL)); -+ void *p = GENERAL_MALLOC(lb, NORMAL); -+ GC_ASSERT (p); -+ return(p); - } - } - -diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m4 gc-old/os_dep.c gc/os_dep.c ---- gc-old/os_dep.c 2007-06-29 21:17:44.000000000 +0200 -+++ gc/os_dep.c 2008-06-26 10:41:13.000000000 +0200 +diff -uprN -x '*.applied' -x config.guess -x '*~' -x autom4te.cache -x config.sub -x configure gc.orig/os_dep.c gc/os_dep.c +--- gc.orig/os_dep.c 2007-06-29 21:17:44.000000000 +0200 ++++ gc/os_dep.c 2008-07-08 16:39:31.000000000 +0200 @@ -2064,6 +2064,18 @@ ptr_t GC_unmap_end(ptr_t start, size_t b return end_addr; } @@ -776,7 +696,7 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m /* round the endpoints in both places. */ void GC_unmap(ptr_t start, size_t bytes) { -+ profile_start (MAP_TIMER); ++ profile_region (MAP_TIMER); + ptr_t start_addr = GC_unmap_start(start, bytes); ptr_t end_addr = GC_unmap_end(start, bytes); @@ -802,13 +722,13 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m # endif + + out: -+ profile_end (MAP_TIMER); ++ profile_region_end (); } void GC_remap(ptr_t start, size_t bytes) { -+ profile_start (MAP_TIMER); ++ profile_region (MAP_TIMER); + ptr_t start_addr = GC_unmap_start(start, bytes); ptr_t end_addr = GC_unmap_end(start, bytes); @@ -845,7 +765,7 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m # endif + + out: -+ profile_end (MAP_TIMER); ++ profile_region_end (); } /* Two adjacent blocks have already been unmapped and are about to */ @@ -853,7 +773,7 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m /* unmapped due to alignment constraints. */ void GC_unmap_gap(ptr_t start1, size_t bytes1, ptr_t start2, size_t bytes2) { -+ profile_start (MAP_TIMER); ++ profile_region (MAP_TIMER); + ptr_t start1_addr = GC_unmap_start(start1, bytes1); ptr_t end1_addr = GC_unmap_end(start1, bytes1); @@ -873,38 +793,14 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m # endif + + out: -+ profile_end (MAP_TIMER); ++ profile_region_end (); } #endif /* USE_MUNMAP */ -Only in gc: os_dep.c~ -Only in gc: patch.stamp -Only in gc: profile.h -diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m4 gc-old/tests/test.c gc/tests/test.c ---- gc-old/tests/test.c 2007-06-19 00:18:01.000000000 +0200 -+++ gc/tests/test.c 2008-06-26 10:41:14.000000000 +0200 -@@ -1334,6 +1334,18 @@ void SetMinimumStack(long minSize) - # endif - # endif - # endif -+extern int GC_viengoos_scheduler; -+ GC_viengoos_scheduler = 1; -+#ifdef USE_MMAP -+ printf ("USE_MMAP "); -+#endif -+#ifdef USE_MUNMAP -+ printf ("USE_UNMMAP "); -+#endif -+#ifdef STACK_GROWS_DOWN -+ printf ("STACK_GROWS_DOWN "); -+#endif -+ printf ("\n"); - run_one_test(); - check_heap_stats(); - # ifndef MSWINCE ---- gc-old/profile.h 2008-06-30 10:00:59.312047969 +0200 -+++ gc/profile.h 2008-07-02 16:16:09.000000000 +0200 -@@ -0,0 +1,35 @@ +diff -uprN -x '*.applied' -x config.guess -x '*~' -x autom4te.cache -x config.sub -x configure gc.orig/profile.h gc/profile.h +--- gc.orig/profile.h 1970-01-01 01:00:00.000000000 +0100 ++++ gc/profile.h 2008-07-08 16:29:27.000000000 +0200 +@@ -0,0 +1,53 @@ +/* profile.h - Profiling support interface. + Copyright (C) 2008 Free Software Foundation, Inc. + Written by Neal H. Walfield <neal@gnu.org>. @@ -927,8 +823,10 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m + +#include <stdint.h> + -+#define GC_TIMER 0, "gc" -+#define MAP_TIMER 1, "map" ++#define GC_TIMER "gc" ++#define MAP_TIMER "map" ++ ++#ifndef NPROFILE + +/* Start a timer for the profile site ID (this must be unique per + site, can be the function's address). NAME is the symbolic @@ -936,7 +834,23 @@ diff -upr -x Makefile.in -x configure -x config.guess -x config.sub -x aclocal.m +extern void profile_start (uintptr_t id, const char *name); + +/* End the timer for the profile site ID. */ -+extern void profile_end (uintptr_t id, const char *name); ++extern void profile_end (uintptr_t id); + +extern void profile_stats_dump (void); + ++#else ++ ++#define profile_start(id, name) do { } while (0) ++#define profile_end(id) do { } while (0) ++#define profile_stats_dump() do { } while (0) ++ ++#endif ++ ++#define profile_region(__pr_id) \ ++ { \ ++ const char *__pr_id_ = (__pr_id); \ ++ profile_start((uintptr_t) __pr_id_, __pr_id_) ++ ++#define profile_region_end() \ ++ profile_end ((uintptr_t) __pr_id_); \ ++ } diff --git a/libc-parts/ChangeLog b/libc-parts/ChangeLog index ccd4e04..88374ed 100644 --- a/libc-parts/ChangeLog +++ b/libc-parts/ChangeLog @@ -1,5 +1,18 @@ 2008-07-08 Neal H. Walfield <neal@gnu.org> + * profile.h: Moved here from ../viengoos/profile.h. + (profile_region): New macro. + (profile_region_end): Likewise. + (profile_start) [NPROFILE]: Do nothing in this case. + (profile_end) [NPROFILE]: Likewise. + (profile_stats_dump) [NPROFILE]: Likewise. + * profile.c: Moved here from ../viengoos/profile.c. + (profile_start) [! RM_INTERN]: Use a static buffer. + * Makefile.am (common_sources): Add fields profile.c and + profile.h. + +2008-07-08 Neal H. Walfield <neal@gnu.org> + * process-spawn.c (process_spawn): Don't add an extra trailing NUL to the argment vector or the environment vector. diff --git a/viengoos/profile.c b/libc-parts/profile.c index 441a02e..2d2b225 100644 --- a/viengoos/profile.c +++ b/libc-parts/profile.c @@ -18,16 +18,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifdef RM_INTERN +# include "../viengoos/zalloc.h" +#else +# include <stdlib.h> +#endif + #include "profile.h" -#include "zalloc.h" -#include "output.h" #include <hurd/ihash.h> #include <stddef.h> #include <string.h> #include <l4.h> +#include <hurd/rm.h> static struct hurd_ihash sites_hash; -static bool init; +static char sites_hash_buffer[PAGESIZE]; +static int init; /* XXX: This implementation assumes that we are single threaded! In the case of Viengoos, this is essentially true: all relevant @@ -47,13 +53,15 @@ static int used; static uint64_t epoch; static uint64_t calls; -static uint64_t total_time; +/* It's nothing but it prevents a divide by zero. */ +static uint64_t total_time = 1; /* Number of extant profiling calls. We only update total_time if EXTANT is 0. The result is that the time spent profiling is correct, and the percent of the time profile that a function has been is more meaningful. */ static int extant; +#undef profile_stats_dump void profile_stats_dump (void) { @@ -62,31 +70,41 @@ profile_stats_dump (void) int i; for (i = 0; i < used; i ++) if (sites[i].calls) - printf ("%s:\t%d calls,\t%lld ms,\t%lld.%d us per call,\t" - "%d%% total time,\t%d%% profiled time\n", - sites[i].name, - sites[i].calls, - sites[i].time / 1000, - sites[i].time / sites[i].calls, - (int) ((10 * sites[i].time) / sites[i].calls) % 10, - (int) ((100 * sites[i].time) / (now - epoch)), - (int) ((100 * sites[i].time) / total_time)); - - printf ("profiled time: %lld ms, calls: %lld\n", - total_time / 1000, calls); - printf ("uptime: %lld ms\n", (now - epoch) / 1000); + s_printf ("%s:\t%d calls,\t%lld ms,\t%lld.%d us per call,\t" + "%d%% total time,\t%d%% profiled time\n", + sites[i].name, + sites[i].calls, + sites[i].time / 1000, + sites[i].time / sites[i].calls, + (int) ((10 * sites[i].time) / sites[i].calls) % 10, + (int) ((100 * sites[i].time) / (now - epoch)), + (int) ((100 * sites[i].time) / total_time)); + + s_printf ("profiled time: %lld ms, calls: %lld\n", + total_time / 1000, calls); + s_printf ("uptime: %lld ms\n", (now - epoch) / 1000); } +#undef profile_start void profile_start (uintptr_t id, const char *name) { if (! init) { - size_t size = hurd_ihash_buffer_size (SIZE, false, 0); + init = 1; + + size_t size; + void *buffer; +#ifdef RM_INTERN + size = hurd_ihash_buffer_size (SIZE, false, 0); /* Round up to a multiple of the page size. */ size = (size + PAGESIZE - 1) & ~(PAGESIZE - 1); - void *buffer = (void *) zalloc (size); + buffer = (void *) zalloc (size); +#else + size = sizeof (sites_hash_buffer); + buffer = sites_hash_buffer; +#endif if (! buffer) panic ("Failed to allocate memory for object hash!\n"); @@ -98,8 +116,10 @@ profile_start (uintptr_t id, const char *name) epoch = l4_system_clock (); - init = true; + init = 2; } + else if (init == 1) + return; struct site *site = hurd_ihash_find (&sites_hash, id); if (! site) @@ -112,7 +132,10 @@ profile_start (uintptr_t id, const char *name) if (err) panic ("Failed to add to hash: %d.", err); - site->name = name; + if (name) + site->name = name; + else + site->name = rm_method_id_string (id); } extant ++; @@ -122,9 +145,13 @@ profile_start (uintptr_t id, const char *name) site->start = l4_system_clock (); } +#undef profile_end void profile_end (uintptr_t id) { + if (init == 1) + return; + struct site *site = hurd_ihash_find (&sites_hash, id); if (! site) panic ("profile_end called without corresponding profile_begin (%p)!", diff --git a/viengoos/profile.h b/libc-parts/profile.h index d49dffb..d6ad55d 100644 --- a/viengoos/profile.h +++ b/libc-parts/profile.h @@ -20,6 +20,16 @@ #include <stdint.h> +/* XXX: Note that the implementation is currently not multi-thread + safe. */ + +/* Currently, only enable by default for Viengoos. */ +#ifndef RM_INTERN +#define NPROFILE +#endif + +#ifndef NPROFILE + /* Start a timer for the profile site ID (this must be unique per site, can be the function's address). NAME is the symbolic name. */ @@ -29,3 +39,20 @@ extern void profile_start (uintptr_t id, const char *name); extern void profile_end (uintptr_t id); extern void profile_stats_dump (void); + +#else + +#define profile_start(id, name) do { } while (0) +#define profile_end(id) do { } while (0) +#define profile_stats_dump() do { } while (0) + +#endif + +#define profile_region(__pr_id) \ + { \ + const char *__pr_id_ = (__pr_id); \ + profile_start((uintptr_t) __pr_id_, __pr_id_) + +#define profile_region_end() \ + profile_end ((uintptr_t) __pr_id_); \ + } diff --git a/viengoos/ChangeLog b/viengoos/ChangeLog index 6e00ccd..e827041 100644 --- a/viengoos/ChangeLog +++ b/viengoos/ChangeLog @@ -1,3 +1,11 @@ +2008-07-08 Neal H. Walfield <neal@gnu.org> + + * profile.h: Move to ../libc-parts. + * profile.c: Likewise. + * ager.c: Don't include "profile.h" but <profile.h>. + (update_stats): Replace use of profile_start and profile_end with + profile_region and profile_region_end. + 2008-07-04 Neal H. Walfield <neal@gnu.org> * Makefile.am (viengoos.striped): Rename from this... diff --git a/viengoos/ager.c b/viengoos/ager.c index a8a3fd7..f413388 100644 --- a/viengoos/ager.c +++ b/viengoos/ager.c @@ -23,6 +23,7 @@ #include "mutex.h" #include <assert.h> +#include <profile.h> #include "ager.h" #include "viengoos.h" @@ -31,7 +32,6 @@ #include "zalloc.h" #include "thread.h" #include "pager.h" -#include "profile.h" #define MIN(x,y) ((x) < (y) ? (x) : (y)) #define MAX(x,y) ((x) > (y) ? (x) : (y)) @@ -65,7 +65,7 @@ static void update_stats (void) { ss_mutex_lock (&kernel_lock); - profile_start ((uintptr_t) &update_stats, "update_stats"); + profile_region ("update_stats"); /* XXX: Update the statistics. We need to average some of the fields including the number of active, inactive, clean and dirty @@ -445,7 +445,7 @@ update_stats (void) stats (root_activity, memory_total - PAGER_LOW_WATER_MARK - 200); - profile_end ((uintptr_t) &update_stats); + profile_region_end (); ss_mutex_unlock (&kernel_lock); } |