[m-rev.] for review: --mem-usage-report
Zoltan Somogyi
zs at csse.unimelb.edu.au
Tue Dec 4 15:43:04 AEDT 2007
For review by anyone.
Zoltan.
runtime/mercury_wrapper.c:
Make the --mem-usage-report option work, but tweak it slightly
- to report more information, and
- to allow (and require) the user to provide the prefix for the output
file.
doc/user_guide.texi:
Document the user-visible changes in the option.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.553
diff -u -b -r1.553 user_guide.texi
--- doc/user_guide.texi 23 Nov 2007 07:35:53 -0000 1.553
+++ doc/user_guide.texi 4 Dec 2007 04:20:35 -0000
@@ -9665,13 +9665,14 @@
Prints statistics about tabling when the program terminates.
@sp 1
- at item --mem-usage-report
- at findex --mem-usage-report
+ at item --mem-usage-report @var{prefix}
+ at findex --mem-usage-report @var{prefix}
Print a report about the memory usage of the program
when the program terminates.
The report is printed to a new file named @file{.mem_usage_report at var{N}}
for the lowest value of @var{N} (up to 99)
which doesn't overwrite an existing file.
+Note that this capability is not supported on all operating systems.
@sp 1
@item --trace-count
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.185
diff -u -b -r1.185 mercury_wrapper.c
--- runtime/mercury_wrapper.c 30 Oct 2007 00:46:23 -0000 1.185
+++ runtime/mercury_wrapper.c 4 Dec 2007 04:21:19 -0000
@@ -38,9 +38,11 @@
#include <stdio.h>
#include <string.h>
+#ifdef MR_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
#if 0 /* XXX the following code breaks on Win32 */
#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <sys/resource.h>
#endif /* breaks on Win32 */
@@ -273,9 +275,9 @@
static int repeats = 1;
#define MAX_MEM_USAGE_REPORT_ATTEMPTS 100
-#define MAX_MEM_USAGE_REPORT_FILENAME_SIZE 1024
+#define MAX_MEM_USAGE_REPORT_CMD_SIZE 1024
-static MR_bool mem_usage_report = MR_FALSE;
+static char *MR_mem_usage_report_prefix = NULL;
static int MR_num_output_args = 0;
@@ -1204,7 +1206,7 @@
{ "trace-count-summary-cmd", 1, 0, MR_TRACE_COUNT_SUMMARY_CMD_OPT },
{ "tc-summary-max", 1, 0, MR_TRACE_COUNT_SUMMARY_MAX_OPT },
{ "trace-count-summary-max", 1, 0, MR_TRACE_COUNT_SUMMARY_MAX_OPT },
- { "mem-usage-report", 0, 0, MR_MEM_USAGE_REPORT },
+ { "mem-usage-report", 1, 0, MR_MEM_USAGE_REPORT },
/* This needs to be kept at the end. */
{ NULL, 0, 0, 0 }
@@ -1726,7 +1728,7 @@
break;
case MR_MEM_USAGE_REPORT:
- mem_usage_report = MR_TRUE;
+ MR_mem_usage_report_prefix = MR_copy_string(MR_optarg);
break;
case 'a':
@@ -2652,16 +2654,38 @@
MR_primordial_thread = (MercuryThread) 0;
#endif
-#if 0 /* XXX the following code breaks on Win32 */
- if (mem_usage_report) {
- char buf[MAX_MEM_USAGE_REPORT_FILENAME_SIZE];
+#ifdef MR_HAVE_SYS_STAT_H
+ if (MR_mem_usage_report_prefix != NULL) {
+ struct stat statbuf;
+ char filename_buf[MAX_MEM_USAGE_REPORT_CMD_SIZE];
+ char cmd_buf[MAX_MEM_USAGE_REPORT_CMD_SIZE];
+ int i;
+
+ for (i = 1; i < MAX_MEM_USAGE_REPORT_ATTEMPTS; i++) {
+ snprintf(filename_buf, MAX_MEM_USAGE_REPORT_CMD_SIZE,
+ "%s%02d", MR_mem_usage_report_prefix, i);
+
+ if (stat(filename_buf, &statbuf) == 0) {
+ /* Filename_buf exists; try next name. */
+ continue;
+ }
+
+ snprintf(cmd_buf, MAX_MEM_USAGE_REPORT_CMD_SIZE,
+ "cp /proc/%d/status %s", getpid(), filename_buf);
+ system(cmd_buf);
+ break;
+ }
+
+#if 0
+ /* XXX This alternative implementation breaks on Win32 and Linux. */
+ char buf[MAX_MEM_USAGE_REPORT_CMD_SIZE];
int i;
int fd;
FILE *fp;
fp = NULL;
for (i = 1; i < MAX_MEM_USAGE_REPORT_ATTEMPTS; i++) {
- sprintf(buf, ".mem_usage_report%02d", i);
+ sprintf(buf, "%s%02d", MR_mem_usage_report_prefix, i);
do {
fd = open(buf, O_WRONLY | O_CREAT | O_EXCL, 0600);
@@ -2688,8 +2712,9 @@
(void) fclose(fp);
}
- }
#endif /* breaks on Win32 */
+ }
+#endif /* MR_HAVE_SYS_STAT_H */
MR_terminate_engine();
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list