[m-rev.] diff: runtime options for benchmarking I/O tabling
Zoltan Somogyi
zs at cs.mu.OZ.AU
Tue Dec 14 18:04:45 AEDT 2004
Add two runtime options useful in benchmarking I/O tabling.
runtime/mercury_wrapper.[ch]:
Recognize the two new runtime options, and implement the first:
When --mem-usage-report is included in MERCURY_OPTIONS, write a report
on the memory usage of the program when the program exits.
trace/mercury_trace_internal.c:
Implement the other option, --mdb-benchmark-silent. When this option
is given, the debugger will generate no output to stdout (and neither
will the program). This is to avoid mixing prompts (e.g. "mdb>" with
the timing data output by tools/speedtest, allowing the output of
tools/speedtest to be processed automatically.
doc/user_guide.texi:
Document the new options, with the documentation of
--mdb-benchmark-silent being for developers only.
Fix a documentation bug on an existing option.
Zoltan.
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/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
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.401
diff -u -b -r1.401 user_guide.texi
--- doc/user_guide.texi 13 Dec 2004 01:59:21 -0000 1.401
+++ doc/user_guide.texi 14 Dec 2004 07:02:43 -0000
@@ -7509,6 +7509,15 @@
@c --mdb-in-window is for use only by the mdb script, so it's
@c not documented here.
+ at c The documentation of --mdb-benchmark-silent is commented out because
+ at c this option is intended only for implementors.
+
+ at c @sp 1
+ at c @item --mdb-benchmark-silent
+ at c @findex --mdb-benchmark-silent (runtime option)
+ at c Redirect all output, including error messages, to /dev/null.
+ at c This is useful for benchmarking.
+
@sp 1
@item --debug-threads
@findex --debug-threads (runtime option)
@@ -7520,9 +7529,18 @@
symbol @samp{MR_DEBUG_THREADS} defined.
@sp 1
- at item --tabling-statistics @var{size}
+ at item --tabling-statistics
@findex --tabling-statistics
Prints statistics about tabling when the program terminates.
+
+ at sp 1
+ at item --mem-usage-report
+ at findex --mem-usage-report
+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.
@end table
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
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/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
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/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
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/odbc
cvs diff: Diffing extras/posix
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/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
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 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.138
diff -u -b -r1.138 mercury_wrapper.c
--- runtime/mercury_wrapper.c 14 Dec 2004 01:07:26 -0000 1.138
+++ runtime/mercury_wrapper.c 14 Dec 2004 03:49:28 -0000
@@ -35,6 +35,10 @@
#include <stdio.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/resource.h>
#ifdef MR_MSVC_STRUCTURED_EXCEPTIONS
#include <excpt.h>
@@ -159,6 +163,8 @@
const char *MR_mdb_err_filename = NULL;
MR_bool MR_mdb_in_window = MR_FALSE;
+MR_bool MR_mdb_benchmark_silent = MR_FALSE;
+
/* use readline() in the debugger even if the input stream is not a tty */
MR_bool MR_force_readline = MR_FALSE;
@@ -234,6 +240,11 @@
static MR_bool use_own_timer = MR_FALSE;
static int repeats = 1;
+#define MAX_MEM_USAGE_REPORT_ATTEMPTS 100
+#define MAX_MEM_USAGE_REPORT_FILENAME_SIZE 1024
+
+static MR_bool mem_usage_report = MR_FALSE;
+
static int MR_num_output_args = 0;
unsigned MR_num_threads = 1;
@@ -952,13 +963,15 @@
MR_MDB_IN,
MR_MDB_OUT,
MR_MDB_ERR,
+ MR_MDB_BENCHMARK_SILENT,
MR_MDB_IN_WINDOW,
MR_FORCE_READLINE,
MR_NUM_OUTPUT_ARGS,
MR_DEBUG_THREADS_OPT,
MR_DEEP_PROF_DEBUG_FILE_OPT,
MR_TABLING_STATISTICS_OPT,
- MR_TRACE_COUNT_OPT
+ MR_TRACE_COUNT_OPT,
+ MR_MEM_USAGE_REPORT
};
struct MR_option MR_long_opts[] = {
@@ -983,12 +996,14 @@
{ "mdb-out", 1, 0, MR_MDB_OUT },
{ "mdb-err", 1, 0, MR_MDB_ERR },
{ "mdb-in-window", 0, 0, MR_MDB_IN_WINDOW },
+ { "mdb-benchmark-silent", 0, 0, MR_MDB_BENCHMARK_SILENT },
{ "force-readline", 0, 0, MR_FORCE_READLINE },
{ "num-output-args", 1, 0, MR_NUM_OUTPUT_ARGS },
{ "debug-threads", 0, 0, MR_DEBUG_THREADS_OPT },
{ "deep-debug-file", 0, 0, MR_DEEP_PROF_DEBUG_FILE_OPT },
{ "tabling-statistics", 0, 0, MR_TABLING_STATISTICS_OPT },
- { "trace-count", 0, 0, MR_TRACE_COUNT_OPT }
+ { "trace-count", 0, 0, MR_TRACE_COUNT_OPT },
+ { "mem-usage-report", 0, 0, MR_MEM_USAGE_REPORT }
};
static void
@@ -1152,6 +1167,10 @@
MR_mdb_in_window = MR_TRUE;
break;
+ case MR_MDB_BENCHMARK_SILENT:
+ MR_mdb_benchmark_silent = MR_TRUE;
+ break;
+
case MR_FORCE_READLINE:
MR_force_readline = MR_TRUE;
#ifdef MR_NO_USE_READLINE
@@ -1182,6 +1201,10 @@
MR_trace_count_enabled = MR_TRUE;
break;
+ case MR_MEM_USAGE_REPORT:
+ mem_usage_report = MR_TRUE;
+ break;
+
case 'a':
benchmark_all_solns = MR_TRUE;
break;
@@ -1976,6 +1999,49 @@
pthread_cond_broadcast(&MR_runqueue_cond);
#endif
#endif
+
+ if (mem_usage_report) {
+ char buf[MAX_MEM_USAGE_REPORT_FILENAME_SIZE];
+ int i;
+ int fd;
+ FILE *fp;
+
+ fp = NULL;
+ for (i = 1; i < MAX_MEM_USAGE_REPORT_ATTEMPTS; i++) {
+ sprintf(buf, ".mem_usage_report%2d", i);
+
+ fd = open(buf, O_WRONLY | O_CREAT | O_EXCL, 0600);
+ if (fd >= 0) {
+ fp = fdopen(fd, "w");
+ break;
+ }
+ }
+
+ if (fp != NULL) {
+ struct rusage rusage;
+
+ fprintf(fp, "io actions %10d\n",
+ MR_io_tabling_counter_hwm);
+ if (getrusage(RUSAGE_SELF, &rusage) == 0) {
+ fprintf(fp, "max resident %10ld\n",
+ rusage.ru_maxrss);
+ fprintf(fp, "integral shared %10ld\n",
+ rusage.ru_ixrss);
+ fprintf(fp, "integral unshared %10ld\n",
+ rusage.ru_idrss);
+ fprintf(fp, "integral stack %10ld\n",
+ rusage.ru_isrss);
+ fprintf(fp, "page reclaims %10ld\n",
+ rusage.ru_minflt);
+ fprintf(fp, "page faults %10ld\n",
+ rusage.ru_majflt);
+ fprintf(fp, "swaps %10ld\n",
+ rusage.ru_nswap);
+ }
+
+ (void) fclose(fp);
+ }
+ }
MR_terminate_engine();
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.64
diff -u -b -r1.64 mercury_wrapper.h
--- runtime/mercury_wrapper.h 14 Dec 2004 01:07:26 -0000 1.64
+++ runtime/mercury_wrapper.h 14 Dec 2004 01:08:20 -0000
@@ -230,6 +230,9 @@
/* should mdb be started in a window */
extern MR_bool MR_mdb_in_window;
+/* should mdb be silent for benchmarking purposes */
+extern MR_bool MR_mdb_benchmark_silent;
+
/* use readline() in the debugger even if the input stream is not a tty */
extern MR_bool MR_force_readline;
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/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
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 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/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.182
diff -u -b -r1.182 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 11 Dec 2004 01:59:52 -0000 1.182
+++ trace/mercury_trace_internal.c 14 Dec 2004 06:59:35 -0000
@@ -687,6 +687,7 @@
char *line;
MR_Next res;
MR_Event_Details event_details;
+ const char *prompt;
if (! interactive) {
return MR_trace_event_internal_report(cmd, event_info);
@@ -791,6 +792,20 @@
char *env;
int n;
+ if (MR_mdb_benchmark_silent) {
+ (void) close(1);
+ if (open("/dev/null", O_WRONLY) != 1) {
+ fprintf(stderr, "cannot silence stdout");
+ exit(1);
+ }
+
+ (void) close(2);
+ if (open("/dev/null", O_WRONLY) != 2) {
+ /* there is nowhere to report the error */
+ exit(1);
+ }
+ }
+
if (MR_mdb_in_window) {
/*
** If opening the window fails, fall back on
@@ -3996,9 +4011,9 @@
** The "table_io allow" command allows the programmer to give
** the command "table_io start" even in grades in which there
** is no guarantee that all I/O primitives are tabled. It is
- ** for developers only, because its use on programs in which
- ** some but not all I/O primitives are tabled, the results of
- ** turning on I/O tabling can be weird.
+ ** for developers only, because if it is used on programs in
+ ** which some but not all I/O primitives are tabled, the
+ ** results of turning on I/O tabling can be weird.
*/
MR_io_tabling_allowed = MR_TRUE;
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: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list