From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#22114: 24.5; [PATCH] Allow profiler.el to display reports after stopping Date: Sun, 13 Dec 2015 23:18:25 +0100 Message-ID: <20151213221825.GC1296@odonien.fritz.box> References: <83bna0di5k.fsf@gnu.org> <20151208163208.GA1080@odonien.bevuta.com> <837fkodf3e.fsf@gnu.org> <83zixkbyoj.fsf@gnu.org> <20151213203323.GB1296@odonien.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="h31gzZEtNLTqOjlF" X-Trace: ger.gmane.org 1450045163 32412 80.91.229.3 (13 Dec 2015 22:19:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Dec 2015 22:19:23 +0000 (UTC) Cc: John Wiegley , Paul Eggert , Stefan Monnier , 22114@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 13 23:19:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a8Ez0-0006vy-DI for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Dec 2015 23:19:10 +0100 Original-Received: from localhost ([::1]:56778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8Eyz-0002A5-JW for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Dec 2015 17:19:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8Eyv-00029r-D5 for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 17:19:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8Eys-00063y-4e for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 17:19:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8Eys-00063h-1e for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 17:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1a8Eyr-00010L-M7 for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2015 17:19:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Dec 2015 22:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 22114-submit@debbugs.gnu.org id=B22114.14500451143824 (code B ref 22114); Sun, 13 Dec 2015 22:19:01 +0000 Original-Received: (at 22114) by debbugs.gnu.org; 13 Dec 2015 22:18:34 +0000 Original-Received: from localhost ([127.0.0.1]:50683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a8EyQ-0000zc-A1 for submit@debbugs.gnu.org; Sun, 13 Dec 2015 17:18:34 -0500 Original-Received: from mail-wm0-f41.google.com ([74.125.82.41]:38063) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1a8EyP-0000zM-0r for 22114@debbugs.gnu.org; Sun, 13 Dec 2015 17:18:33 -0500 Original-Received: by wmpp66 with SMTP id p66so38294909wmp.1 for <22114@debbugs.gnu.org>; Sun, 13 Dec 2015 14:18:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=3KJ7NMoVKD8FXY4+ruHIlSTlosSnzzJOQeXgUiNaoxA=; b=nrKwQscH6i/Sbz4wHyZJL1xO+LP+Q8022ebKCB+eGZ367X615SvndKLpMNBEUrlsY/ bMtoRb+tJ7aR7Y7HPP8XxwaACZQgTSx5eczZryZwy686uYV7g5bzVWreYA9lCcYXvxaD GX0pFkVW2lRHqfb4aVFHupZ8fnAUGdGa6xD9C0gfExPTE7v70Uzd43syFGSIv5ehB+TM nc3nwNSD8a1kyoZtAqoNZQtfNm4Helrx+eUfTDK/9UzLgqNdwrzSI8n1d817Mtjl4PUP xsYUNQvaIiYqlwAdgeQq8me7ROKgH4dg7/y+wR5nx5ATd8O2twRoFMVLxunathjbqL1d e9pA== X-Received: by 10.194.77.51 with SMTP id p19mr33229936wjw.159.1450045107150; Sun, 13 Dec 2015 14:18:27 -0800 (PST) Original-Received: from localhost (dslb-088-078-205-095.088.078.pools.vodafone-ip.de. [88.78.205.95]) by smtp.gmail.com with ESMTPSA id l128sm13315908wmf.10.2015.12.13.14.18.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Dec 2015 14:18:26 -0800 (PST) Content-Disposition: inline In-Reply-To: <20151213203323.GB1296@odonien.fritz.box> User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109960 Archived-At: --h31gzZEtNLTqOjlF Content-Type: text/plain; charset=utf-8 Content-Disposition: inline On 12/13/15 at 09:33pm, Vasilij Schneidermann wrote: > What if one would just create a deep copy of the log that can be > safely used externally? Apparently not even that is necessary. I wrote another variant of the patch that disables the check for a running profiler before generating a report, avoids erroring out if generating a report for a non-running profiler and doesn't reset the log after stopping. Either my testing has been too superficial and something unexpected will come bite me or the comments are simply outdated. I've taken the liberty to include Paul Eggert and Stefan Monnier into the CC as they've contributed several patches to profiler.c and should be able to illuminate this matter. --h31gzZEtNLTqOjlF Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Disable-profiler-log-reset-on-stop.patch" >From 7153c42d55d14ad6d367f4e7f8a5482cb814e810 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Sun, 13 Dec 2015 23:09:12 +0100 Subject: [PATCH] Disable profiler log reset on stop --- lisp/profiler.el | 31 +++++++++++++++---------------- src/profiler.c | 16 +--------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/lisp/profiler.el b/lisp/profiler.el index f28bbfe..90a4241 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -216,19 +216,17 @@ Optional argument MODE means only check for the specified mode (cpu or mem)." (defun profiler-cpu-profile () "Return CPU profile." - (when (profiler-running-p 'cpu) - (profiler-make-profile - :type 'cpu - :timestamp (current-time) - :log (profiler-cpu-log)))) + (profiler-make-profile + :type 'cpu + :timestamp (current-time) + :log (profiler-cpu-log))) (defun profiler-memory-profile () "Return memory profile." - (when (profiler-memory-running-p) - (profiler-make-profile - :type 'memory - :timestamp (current-time) - :log (profiler-memory-log)))) + (profiler-make-profile + :type 'memory + :timestamp (current-time) + :log (profiler-memory-log))) ;;; Calltrees @@ -845,20 +843,21 @@ Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started." t) (defun profiler-report-cpu () + (when (profiler-cpu-log)) (let ((profile (profiler-cpu-profile))) - (when profile - (profiler-report-profile-other-window profile)))) + (profiler-report-profile-other-window profile))) (defun profiler-report-memory () (let ((profile (profiler-memory-profile))) - (when profile - (profiler-report-profile-other-window profile)))) + (profiler-report-profile-other-window profile))) (defun profiler-report () "Report profiling results." (interactive) - (profiler-report-cpu) - (profiler-report-memory)) + (when (and (fboundp 'profiler-cpu-log) (profiler-cpu-log)) + (profiler-report-cpu)) + (when (profiler-memory-log) + (profiler-report-memory))) ;;;###autoload (defun profiler-find-profile (filename) diff --git a/src/profiler.c b/src/profiler.c index efdb1d9..4cd6bb0 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -41,9 +41,7 @@ static Lisp_Object make_log (EMACS_INT heap_size, EMACS_INT max_stack_depth) { /* We use a standard Elisp hash-table object, but we use it in - a special way. This is OK as long as the object is not exposed - to Elisp, i.e. until it is returned by *-profiler-log, after which - it can't be used any more. */ + a special way. */ Lisp_Object log = make_hash_table (hashtest_profiler, make_number (heap_size), make_float (DEFAULT_REHASH_SIZE), @@ -412,12 +410,6 @@ Before returning, a new log is allocated for future samples. */) (void) { Lisp_Object result = cpu_log; - /* Here we're making the log visible to Elisp, so it's not safe any - more for our use afterwards since we can't rely on its special - pre-allocated keys anymore. So we have to allocate a new one. */ - cpu_log = (profiler_cpu_running - ? make_log (profiler_log_size, profiler_max_stack_depth) - : Qnil); Fputhash (Fmake_vector (make_number (1), Qautomatic_gc), make_number (cpu_gc_count), result); @@ -487,12 +479,6 @@ Before returning, a new log is allocated for future samples. */) (void) { Lisp_Object result = memory_log; - /* Here we're making the log visible to Elisp , so it's not safe any - more for our use afterwards since we can't rely on its special - pre-allocated keys anymore. So we have to allocate a new one. */ - memory_log = (profiler_memory_running - ? make_log (profiler_log_size, profiler_max_stack_depth) - : Qnil); return result; } -- 2.6.2 --h31gzZEtNLTqOjlF--