PATCH 21.5
I decided to use double instead of EMACS_INT to fix the wrap around in
the gc_state statistics that Adrian reported.
If nobody objects, I'll commit in a few days.
lisp/ChangeLog addition:
2006-03-26 Marcus Crestani <crestani(a)xemacs.org>
* diagnose.el (show-gc-stats): Adjust format string, remove
explicitly freed statistics.
src/ChangeLog addition:
2006-03-26 Marcus Crestani <crestani(a)xemacs.org>
* gc.c: Remove functions for explicitly-freed statistics.
* gc.c (struct gc_state): EMACS_INT -> double, remove
explicitly-freed statistics.
* gc.c (Fgc_stats): Remove explicitly-freed statistics.
* gc.c (PL): Use make_float.
* gc.h: Remove prototypes and macros for explicitly-freed
statistics.
xemacs-21.5 source patch:
Diff command: cvs -q diff -u
Files affected: src/gc.h src/gc.c lisp/diagnose.el
Index: lisp/diagnose.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/diagnose.el,v
retrieving revision 1.8
diff -u -r1.8 diagnose.el
--- lisp/diagnose.el 12 Mar 2006 09:10:39 -0000 1.8
+++ lisp/diagnose.el 26 Mar 2006 16:01:38 -0000
@@ -398,10 +398,12 @@
(interactive)
(let ((buffer "*garbage collection statistics*")
(plist (gc-stats))
- (fmt "%-9s %10s %10s %10s %10s %10s\n"))
+ (fmt "%-9s %16s %12s %12s %12s %12s\n"))
(flet ((plist-get-stat (category field)
- (or (plist-get plist (intern (concat category field)))
- "-"))
+ (let ((stat (plist-get plist (intern (concat category field)))))
+ (if stat
+ (format "%.0f" stat)
+ "-")))
(show-stats (category)
(princ (format fmt category
(plist-get-stat category "-total")
@@ -412,12 +414,12 @@
(with-output-to-temp-buffer buffer
(save-excursion
(set-buffer buffer)
- (princ (format "%s %s\n" "Current phase" (plist-get plist
'phase)))
- (princ (make-string 64 ?-))
+ (princ (format "%s %g\n" "Current phase" (plist-get plist
'phase)))
+ (princ (make-string 78 ?-))
(princ "\n")
(princ (format fmt "stat" "total" "last-gc"
"this-gc"
"last-cycle" "this-cylce"))
- (princ (make-string 64 ?-))
+ (princ (make-string 78 ?-))
(princ "\n")
(show-stats "n-gc")
(show-stats "n-cycles")
@@ -428,13 +430,4 @@
(show-stats "dequeued2")
(show-stats "finalized")
(show-stats "freed")
- (princ (make-string 64 ?-))
- (princ "\n")
- (princ (format fmt "explicitly"
- "freed:"
- (plist-get-stat "explicitly" "-freed")
- "tried:"
- (plist-get-stat "explicitly" "-tried-freed")
- "")))
-
- (plist-get plist 'n-gc-total)))))
+ (plist-get plist 'n-gc-total))))))
Index: src/gc.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/gc.c,v
retrieving revision 1.3
diff -u -r1.3 gc.c
--- src/gc.c 2 Mar 2006 17:11:47 -0000 1.3
+++ src/gc.c 26 Mar 2006 16:02:14 -0000
@@ -125,17 +125,15 @@
struct
{
enum gc_phase phase;
- EMACS_INT n_gc[GC_STAT_COUNT];
- EMACS_INT n_cycles[GC_STAT_COUNT];
- EMACS_INT enqueued[GC_STAT_COUNT];
- EMACS_INT dequeued[GC_STAT_COUNT];
- EMACS_INT repushed[GC_STAT_COUNT];
- EMACS_INT enqueued2[GC_STAT_COUNT];
- EMACS_INT dequeued2[GC_STAT_COUNT];
- EMACS_INT finalized[GC_STAT_COUNT];
- EMACS_INT freed[GC_STAT_COUNT];
- EMACS_INT explicitly_freed;
- EMACS_INT explicitly_tried_freed;
+ double n_gc[GC_STAT_COUNT];
+ double n_cycles[GC_STAT_COUNT];
+ double enqueued[GC_STAT_COUNT];
+ double dequeued[GC_STAT_COUNT];
+ double repushed[GC_STAT_COUNT];
+ double enqueued2[GC_STAT_COUNT];
+ double dequeued2[GC_STAT_COUNT];
+ double finalized[GC_STAT_COUNT];
+ double freed[GC_STAT_COUNT];
} gc_state;
#endif /* ERROR_CHECK_GC */
@@ -226,54 +224,6 @@
GC_STAT_TICK (freed);
}
-void
-gc_stat_explicitly_freed (void)
-{
- gc_state.explicitly_freed++;
-}
-
-void
-gc_stat_explicitly_tried_freed (void)
-{
- gc_state.explicitly_tried_freed++;
-}
-
-#define GC_STAT_PRINT_ONE(stat) \
- printf (" | %9s %10d %10d %10d %10d %10d\n", \
- #stat, \
- (int) gc_state.stat[GC_STAT_TOTAL], \
- (int) gc_state.stat[GC_STAT_IN_LAST_GC], \
- (int) gc_state.stat[GC_STAT_IN_THIS_GC], \
- (int) gc_state.stat[GC_STAT_IN_LAST_CYCLE], \
- (int) gc_state.stat[GC_STAT_IN_THIS_CYCLE])
-
-void
-gc_stat_print_stats (void)
-{
- printf (" | PHASE %d TOTAL_GC %d\n",
- (int) GC_PHASE,
- (int) gc_state.n_gc[GC_STAT_TOTAL]);
- printf (" | %9s %10s %10s %10s %10s %10s\n",
- "stat", "total", "last_gc", "this_gc",
- "last_cycle", "this_cycle");
- printf (" | %9s %10d %10d %10d \n",
- "cycle", (int) gc_state.n_cycles[GC_STAT_TOTAL],
- (int) gc_state.n_cycles[GC_STAT_IN_LAST_GC],
- (int) gc_state.n_cycles[GC_STAT_IN_THIS_GC]);
-
- GC_STAT_PRINT_ONE (enqueued);
- GC_STAT_PRINT_ONE (dequeued);
- GC_STAT_PRINT_ONE (repushed);
- GC_STAT_PRINT_ONE (enqueued2);
- GC_STAT_PRINT_ONE (dequeued2);
- GC_STAT_PRINT_ONE (finalized);
- GC_STAT_PRINT_ONE (freed);
-
- printf (" | explicitly freed %d tried %d\n",
- (int) gc_state.explicitly_freed,
- (int) gc_state.explicitly_tried_freed);
-}
-
DEFUN("gc-stats", Fgc_stats, 0, 0 ,"", /*
Return statistics about garbage collection cycles in a property list.
*/
@@ -281,10 +231,8 @@
{
Lisp_Object pl = Qnil;
#define PL(name,value) \
- pl = cons3 (intern (name), make_int ((int) gc_state.value), pl)
+ pl = cons3 (intern (name), make_float (gc_state.value), pl)
- PL ("explicitly-tried-freed", explicitly_tried_freed);
- PL ("explicitly-freed", explicitly_freed);
PL ("freed-in-this-cycle", freed[GC_STAT_IN_THIS_CYCLE]);
PL ("freed-in-this-gc", freed[GC_STAT_IN_THIS_GC]);
PL ("freed-in-last-cycle", freed[GC_STAT_IN_LAST_CYCLE]);
Index: src/gc.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/gc.h,v
retrieving revision 1.2
diff -u -r1.2 gc.h
--- src/gc.h 27 Feb 2006 16:29:26 -0000 1.2
+++ src/gc.h 26 Mar 2006 16:02:14 -0000
@@ -34,17 +34,11 @@
void gc_stat_print_stats (void);
void gc_stat_finalized (void);
void gc_stat_freed (void);
-void gc_stat_explicitly_freed (void);
-void gc_stat_explicitly_tried_freed (void);
# define GC_STAT_FINALIZED gc_stat_finalized ()
# define GC_STAT_FREED gc_stat_freed ()
-# define GC_STAT_EXPLICITLY_FREED gc_stat_explicitly_freed ()
-# define GC_STAT_EXPLICITLY_TRIED_FREED gc_stat_explicitly_tried_freed ()
#else /* not ERROR_CHECK_GC */
# define GC_STAT_FINALIZED
# define GC_STAT_FREED
-# define GC_STAT_EXPLICITLY_FREED
-# define GC_STAT_EXPLICITLY_TRIED_FREED
#endif /* not ERROR_CHECK_GC */
#endif /* not NEW_GC */
--
Marcus