[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] pdumper 9f90742 2/2: Stop spamming stderr with pdumper loa
From: |
Daniel Colascione |
Subject: |
[Emacs-diffs] pdumper 9f90742 2/2: Stop spamming stderr with pdumper load info; move to pdumper-stats |
Date: |
Mon, 26 Feb 2018 01:16:02 -0500 (EST) |
branch: pdumper
commit 9f90742d3deeb301cfd93cb0e94aa828d5dfe874
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>
Stop spamming stderr with pdumper load info; move to pdumper-stats
---
src/emacs.c | 25 ++-----------------------
src/pdumper.c | 47 ++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 44 insertions(+), 28 deletions(-)
diff --git a/src/emacs.c b/src/emacs.c
index 8f4ecd1..4159810 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -724,7 +724,7 @@ dump_error_to_string (enum pdumper_load_result result)
#define PDUMP_FILE_ARG "--dump-file"
static enum pdumper_load_result
-load_pdump (int argc, char **argv, const char** out_dump_file)
+load_pdump (int argc, char **argv)
{
const char *const suffix = ".pdmp";
const char *const argv0_base = "emacs";
@@ -797,7 +797,6 @@ load_pdump (int argc, char **argv, const char**
out_dump_file)
dump_file = NULL;
out:
- *out_dump_file = dump_file ? strdup (dump_file) : NULL;
return result;
}
#endif /* HAVE_PDUMPER */
@@ -827,7 +826,6 @@ main (int argc, char **argv)
stack_bottom = (char *) &stack_bottom_variable;
const char *dump_mode = NULL;
- const char *loaded_dump = NULL;
const char *temacs = find_argument ("--temacs", argc, argv);
#ifdef HAVE_PDUMPER
bool attempt_load_pdump = false;
@@ -904,21 +902,7 @@ main (int argc, char **argv)
#ifdef HAVE_PDUMPER
if (attempt_load_pdump)
- {
- struct timeval start;
- gettimeofday (&start, NULL);
- enum pdumper_load_result result = load_pdump (argc, argv, &loaded_dump);
- struct timeval end;
- gettimeofday (&end, NULL);
- double tdif =
- 1000.0 * (end.tv_sec - start.tv_sec)
- + (end.tv_usec - start.tv_usec) / 1.0e3;
- fprintf (stderr, "load_dump %s %g milliseconds%s%s\n",
- loaded_dump ? "completed in" : "failed after",
- tdif,
- loaded_dump ? "" : ": ",
- dump_error_to_string (result));
- }
+ load_pdump (argc, argv);
#endif
/* True if address randomization interferes with memory allocation. */
@@ -1916,8 +1900,6 @@ Using an Emacs configured with --with-x-toolkit=lucid
does not have this problem
if (dump_mode)
Vdump_mode = build_string (dump_mode);
- if (loaded_dump)
- Vdump_file_name = build_string (loaded_dump); // XXX: decode
/* Enter editor command loop. This never returns. */
Frecursive_edit ();
@@ -2788,9 +2770,6 @@ Don't rely on it for testing whether a feature you want
to use is available. */
DEFVAR_BOOL ("noninteractive", noninteractive1,
doc: /* Non-nil means Emacs is running without interactive
terminal. */);
- DEFVAR_LISP ("dump-file-name", Vdump_file_name,
- doc: /* Name of the dump file used to start this Emacs process.
*/);
-
DEFVAR_LISP ("kill-emacs-hook", Vkill_emacs_hook,
doc: /* Hook run when `kill-emacs' is called.
Since `kill-emacs' may be invoked when the terminal is disconnected (or
diff --git a/src/pdumper.c b/src/pdumper.c
index 83141db..80ed9a8 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -25,6 +25,7 @@
#include "lisp.h"
#include "pdumper.h"
#include "window.h"
+#include "systime.h"
#include "dmpstruct.h"
@@ -4722,6 +4723,10 @@ struct pdumper_loaded_dump_private
struct dump_header header;
/* Mark bits for objects in the dump; used during GC. */
struct dump_bitset mark_bits;
+ /* Time taken to load the dump. */
+ double load_time;
+ /* Dump file name. */
+ char *dump_filename;
};
struct pdumper_loaded_dump dump_public;
@@ -5071,6 +5076,15 @@ enum dump_section
NUMBER_DUMP_SECTIONS,
};
+/* Subtract two timespecs, yielding a difference in milliseconds. */
+static double
+subtract_timespec (struct timespec minuend, struct timespec subtrahend)
+{
+ return
+ 1000.0 * (double)(minuend.tv_sec - subtrahend.tv_sec)
+ + (double)(minuend.tv_nsec - subtrahend.tv_nsec) / 1.0e6;
+}
+
/* Load a dump from DUMP_FILENAME. Return an error code.
N.B. We run very early in initialization, so we can't use lisp,
@@ -5095,6 +5109,9 @@ pdumper_load (const char *dump_filename)
struct dump_header *header = &header_buf;
struct dump_memory_map sections[NUMBER_DUMP_SECTIONS];
+ const struct timespec start_time = current_timespec ();
+ char *dump_filename_copy = NULL;
+
memset (&header_buf, 0, sizeof (header_buf));
memset (§ions, 0, sizeof (sections));
@@ -5142,6 +5159,11 @@ pdumper_load (const char *dump_filename)
}
err = PDUMPER_LOAD_OOM;
+ dump_filename_copy = strdup (dump_filename);
+ if (!dump_filename_copy)
+ goto out;
+
+ err = PDUMPER_LOAD_OOM;
adj_discardable_start = header->discardable_start;
dump_page_size = dump_get_page_size ();
@@ -5209,6 +5231,11 @@ pdumper_load (const char *dump_filename)
dump_hooks[i] ();
initialized = true;
+ dump_private.load_time = subtract_timespec (
+ current_timespec (), start_time);
+ dump_private.dump_filename = dump_filename_copy;
+ dump_filename_copy = NULL;
+
out:
for (int i = 0; i < ARRAYELTS (sections); ++i)
dump_mmap_release (§ions[i]);
@@ -5216,19 +5243,27 @@ pdumper_load (const char *dump_filename)
dump_bitset_destroy (&mark_bits);
if (dump_fd >= 0)
emacs_close (dump_fd);
+ free (dump_filename_copy);
return err;
}
DEFUN ("pdumper-stats",
Fpdumper_stats, Spdumper_stats,
0, 0, 0,
- doc: /* Return statistics about the portable dumper. */)
+ doc: /* Return an alist of statistics about dump file that
+ started this Emacs, if any. Nil if this Emacs was not
+ started using a portable dumper dump file.*/)
(void)
{
- Lisp_Object stats = Qnil;
- if (dumped_with_pdumper_p ())
- dump_push (&stats, Fcons (Qdumped_with_pdumper, Qt));
- return Fnreverse (stats);
+ if (!dumped_with_pdumper_p ())
+ return Qnil;
+
+ return CALLN (
+ Flist,
+ Fcons (Qdumped_with_pdumper, Qt),
+ Fcons (Qload_time, make_float (dump_private.load_time)),
+ Fcons (Qdump_file_name,
+ build_unibyte_string (dump_private.dump_filename)));
}
#endif /* HAVE_PDUMPER */
@@ -5247,6 +5282,8 @@ syms_of_pdumper (void)
DEFSYM (Qdump_emacs_portable__sort_predicate_copied,
"dump-emacs-portable--sort-predicate-copied");
DEFSYM (Qdumped_with_pdumper, "dumped-with-pdumper");
+ DEFSYM (Qload_time, "load-time");
+ DEFSYM (Qdump_file_name, "dump-file-name");
defsubr (&Spdumper_stats);
#endif /* HAVE_PDUMPER */
}