all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Helmut Eller <eller.helmut@gmail.com>
To: "Gerd Möllmann" <gerd.moellmann@gmail.com>
Cc: Ihor Radchenko <yantar92@posteo.net>,
	 Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: MPS: profiler
Date: Fri, 21 Jun 2024 10:21:10 +0200	[thread overview]
Message-ID: <87frt63dvt.fsf@gmail.com> (raw)
In-Reply-To: <m2r0cq4tt3.fsf@pro2.fritz.box> ("Gerd Möllmann"'s message of "Fri, 21 Jun 2024 09:51:52 +0200")

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

On Fri, Jun 21 2024, Gerd Möllmann wrote:

>> There is a function mps_arena_busy, that might be useful.  The doc says
>> that it should only be used for debugging.  But the implementation
>> actually checks if the arena holds a lock.
>
> Yes, the SIBPROF handler could at least return early then.

Perhaps something like this?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Be-careful-while-profiling.patch --]
[-- Type: text/x-diff, Size: 2166 bytes --]

From d86baa8b2af2059b00c9cbec5f404008c73705a8 Mon Sep 17 00:00:00 2001
From: Helmut Eller <eller.helmut@gmail.com>
Date: Fri, 21 Jun 2024 10:12:28 +0200
Subject: [PATCH] Be careful while profiling

SIGPROF can be delived while the SIGSEGV handler is running.  In this
situation we shouldn't access MPS-managed memory.  E.g. the profiler
should not look inside closures when recording backtraces.

* src/igc.h (igc_busy_p): New.
* src/profiler.c (add_sample): When igc_busy_p, do the same as the old
GC does when it is called during GC, i.e. only increace a counter and
don't record a backtrace.
* src/igc.c (igc_busy_p): Implement it.
---
 src/igc.c      | 6 ++++++
 src/igc.h      | 1 +
 src/profiler.c | 4 ++++
 3 files changed, 11 insertions(+)

diff --git a/src/igc.c b/src/igc.c
index ce4058fb25c..7ccde80e329 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -4021,6 +4021,12 @@ igc_alloc_dump (size_t nbytes)
   return base_to_client (block);
 }
 
+bool
+igc_busy_p (void)
+{
+  return mps_arena_busy (global_igc->arena);
+}
+
 /***********************************************************************
 				  Init
  ***********************************************************************/
diff --git a/src/igc.h b/src/igc.h
index 485f23090c2..fc80a92d1a8 100644
--- a/src/igc.h
+++ b/src/igc.h
@@ -154,6 +154,7 @@ #define EMACS_IGC_H
 char *igc_dump_finish_obj (void *client, enum igc_obj_type type,
 			   char *base, char *end);
 void *igc_alloc_dump (size_t nbytes);
+bool igc_busy_p (void);
 
 # define eassert_not_mps() eassert (false)
 #else
diff --git a/src/profiler.c b/src/profiler.c
index 98d83bcf264..c24a92de6d7 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -341,7 +341,11 @@ record_backtrace (struct profiler_log *plog, EMACS_INT count)
 static void
 add_sample (struct profiler_log *plog, EMACS_INT count)
 {
+#ifdef HAVE_MPS
+  if (igc_busy_p ())
+#else
   if (EQ (backtrace_top_function (), QAutomatic_GC)) /* bug#60237 */
+#endif
     /* Special case the time-count inside GC because the hash-table
        code is not prepared to be used while the GC is running.
        More specifically it uses ASIZE at many places where it does
-- 
2.39.2


  reply	other threads:[~2024-06-21  8:21 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 19:25 MPS: profiler Ihor Radchenko
2024-06-20 19:40 ` Eli Zaretskii
2024-06-20 19:48   ` Ihor Radchenko
2024-06-20 19:58     ` Gerd Möllmann
2024-06-20 20:29       ` Ihor Radchenko
2024-06-21  5:57         ` Gerd Möllmann
2024-06-21  6:17         ` Eli Zaretskii
2024-06-21  6:54           ` Gerd Möllmann
2024-06-21  7:16             ` Eli Zaretskii
2024-06-21  7:32               ` Gerd Möllmann
2024-06-21  7:19             ` Helmut Eller
2024-06-21  7:36               ` Ihor Radchenko
2024-06-21  7:44                 ` Helmut Eller
2024-06-21  7:51                   ` Gerd Möllmann
2024-06-21  8:21                     ` Helmut Eller [this message]
2024-06-21  8:31                       ` Gerd Möllmann
2024-06-21 10:45                         ` Eli Zaretskii
2024-06-21 11:47                           ` Gerd Möllmann
2024-06-21 12:01                             ` Helmut Eller
2024-06-21 12:09                               ` Ihor Radchenko
2024-06-21 12:42                                 ` Helmut Eller
2024-06-21 12:51                                   ` Ihor Radchenko
2024-06-21 14:49                                     ` MPS make-thread (was: MPS: profiler) Helmut Eller
2024-06-21 15:20                                       ` MPS make-thread Gerd Möllmann
2024-06-21 15:33                                         ` Gerd Möllmann
2024-06-21 15:42                                           ` Helmut Eller
2024-06-21 16:46                                             ` Gerd Möllmann
2024-06-21 18:31                                               ` Gerd Möllmann
2024-06-21 19:58                                                 ` Ihor Radchenko
2024-06-21 20:10                                                   ` Gerd Möllmann
2024-06-22 18:52                                                     ` Ihor Radchenko
2024-06-22 19:17                                                       ` Eli Zaretskii
2024-06-23  3:18                                                         ` Gerd Möllmann
2024-06-23  4:54                                                           ` Gerd Möllmann
2024-06-23  6:19                                                             ` Eli Zaretskii
2024-06-23  5:53                                                           ` Eli Zaretskii
2024-06-23  6:45                                                             ` Gerd Möllmann
2024-06-23  8:53                                                               ` Eli Zaretskii
2024-06-23  9:36                                                                 ` Gerd Möllmann
2024-06-23 10:21                                                                   ` Gerd Möllmann
2024-06-23 10:27                                                                     ` Gerd Möllmann
2024-06-23 13:19                                                                       ` Eli Zaretskii
2024-06-23 14:16                                                                         ` Gerd Möllmann
2024-06-26 11:20                                                                         ` Ihor Radchenko
2024-06-26 11:25                                                                           ` Gerd Möllmann
2024-06-22 19:26                                                       ` Gerd Möllmann
2024-06-22  6:29                                                   ` Eli Zaretskii
2024-06-22 18:53                                                     ` Ihor Radchenko
2024-06-22 19:04                                                       ` Eli Zaretskii
2024-06-22 19:17                                                         ` Ihor Radchenko
2024-06-22 18:13                                                 ` Helmut Eller
2024-06-22 18:31                                                   ` Gerd Möllmann
2024-06-25 18:42                                                   ` MPS native subrs (was: MPS make-thread) Helmut Eller via Emacs development discussions.
2024-06-25 20:10                                                     ` MPS native subrs Gerd Möllmann
2024-06-25 20:48                                                       ` Gerd Möllmann
2024-06-26  6:31                                                         ` Helmut Eller
2024-06-26  7:00                                                           ` Gerd Möllmann
2024-06-26 13:45                                                             ` Eli Zaretskii
2024-06-26 14:18                                                               ` Gerd Möllmann
2024-06-26 15:15                                                             ` Helmut Eller
2024-06-26 17:12                                                               ` Gerd Möllmann
2024-06-26 13:30                                                         ` Eli Zaretskii
2024-06-26 13:34                                                         ` Eli Zaretskii
2024-06-26  4:55                                                       ` Gerd Möllmann
2024-06-26 13:36                                                       ` Eli Zaretskii
2024-06-26 13:26                                                     ` MPS native subrs (was: MPS make-thread) Eli Zaretskii
2024-06-26 14:41                                                     ` MPS native subrs Andrea Corallo
2024-06-21 12:43                                 ` MPS: profiler Gerd Möllmann
2024-06-21 16:11                                   ` Ihor Radchenko
2024-06-21 12:41                               ` Gerd Möllmann
2024-06-21 14:10                             ` Eli Zaretskii
2024-06-21 16:09                               ` Ihor Radchenko
2024-06-21 16:22                                 ` Gerd Möllmann
2024-06-21 18:51                                 ` Ihor Radchenko
2024-06-21 18:58                                   ` Gerd Möllmann
2024-06-21 19:23                                     ` Ihor Radchenko
2024-06-21 19:50                                       ` Gerd Möllmann
2024-06-21 20:02                                         ` Ihor Radchenko
2024-06-22  6:37                                           ` Eli Zaretskii
2024-06-21  7:43               ` Gerd Möllmann
2024-06-21  7:50                 ` Ihor Radchenko
2024-06-21  7:53                   ` Gerd Möllmann
2024-06-21 10:39                   ` Eli Zaretskii
2024-06-21 10:57                     ` Ihor Radchenko
2024-06-21 10:58                       ` Eli Zaretskii
2024-06-21 11:20                         ` Ihor Radchenko
2024-06-21 11:29                           ` Eli Zaretskii
2024-06-21 11:33                         ` Gerd Möllmann
2024-06-21 19:55                           ` Dmitry Gutov
2024-06-21 16:12           ` Ihor Radchenko
2024-06-21 18:48             ` Eli Zaretskii
2024-06-21 10:49         ` Pip Cet
2024-06-21 10:56           ` Eli Zaretskii
2024-06-21  5:56     ` Eli Zaretskii
2024-06-21  6:14       ` Ihor Radchenko
2024-06-20 19:50 ` Gerd Möllmann
2024-06-20 20:02   ` Ihor Radchenko
2024-06-21  5:58     ` Eli Zaretskii
2024-06-21  6:16       ` Ihor Radchenko
2024-06-21  8:23 ` Pip Cet
2024-06-21  8:43   ` Ihor Radchenko
2024-06-21  8:50   ` Gerd Möllmann
2024-06-21 10:43   ` Eli Zaretskii
2024-06-21 11:00     ` Pip Cet
2024-06-21 11:09       ` Eli Zaretskii
2024-06-21 11:39         ` Gerd Möllmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87frt63dvt.fsf@gmail.com \
    --to=eller.helmut@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=gerd.moellmann@gmail.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.