diff options
| author | Helmut Eller | 2025-01-03 17:27:10 +0100 |
|---|---|---|
| committer | Gerd Möllmann | 2025-01-08 04:19:19 +0100 |
| commit | f3ef8385dc5ebe4fa67967d02eade6f8c74872da (patch) | |
| tree | cda4ac0e572586851b71667a19933f18f52b63a5 /src | |
| parent | cabe8da3b628f31aa1e0f7993cde941927ba0669 (diff) | |
| download | emacs-f3ef8385dc5ebe4fa67967d02eade6f8c74872da.tar.gz emacs-f3ef8385dc5ebe4fa67967d02eade6f8c74872da.zip | |
Delay processing of SIGPROF to the next safepoint
* src/lisp.h (process_pending_profiler_signals): New function.
* src/profiler.c (pending_profiler_signals): New variable.
(handle_profiler_signal): Instead of calling add_sample,
set pending_signals and increment pending_profiler_signals.
(process_pending_profiler_signals): New function.
* src/keyboard.c (process_pending_signals): Call
process_pending_profiler_signals.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 1 | ||||
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/profiler.c | 17 |
3 files changed, 18 insertions, 1 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 94337d2ba8c..67a7f129a51 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -8190,6 +8190,7 @@ process_pending_signals (void) | |||
| 8190 | handle_async_input (); | 8190 | handle_async_input (); |
| 8191 | do_pending_atimers (); | 8191 | do_pending_atimers (); |
| 8192 | do_async_work (); | 8192 | do_async_work (); |
| 8193 | process_pending_profiler_signals (); | ||
| 8193 | } | 8194 | } |
| 8194 | 8195 | ||
| 8195 | /* Undo any number of BLOCK_INPUT calls down to level LEVEL, | 8196 | /* Undo any number of BLOCK_INPUT calls down to level LEVEL, |
diff --git a/src/lisp.h b/src/lisp.h index f8bf92d665c..0d9ed9b7495 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -5974,6 +5974,7 @@ extern bool profiler_memory_running; | |||
| 5974 | extern void malloc_probe (size_t); | 5974 | extern void malloc_probe (size_t); |
| 5975 | extern void syms_of_profiler (void); | 5975 | extern void syms_of_profiler (void); |
| 5976 | extern void mark_profiler (void); | 5976 | extern void mark_profiler (void); |
| 5977 | extern void process_pending_profiler_signals (void); | ||
| 5977 | 5978 | ||
| 5978 | 5979 | ||
| 5979 | #ifdef DOS_NT | 5980 | #ifdef DOS_NT |
diff --git a/src/profiler.c b/src/profiler.c index 66a0e37f92e..f22a0352e73 100644 --- a/src/profiler.c +++ b/src/profiler.c | |||
| @@ -387,6 +387,9 @@ static enum profiler_cpu_running | |||
| 387 | /* Hash-table log of CPU profiler. */ | 387 | /* Hash-table log of CPU profiler. */ |
| 388 | static struct profiler_log cpu; | 388 | static struct profiler_log cpu; |
| 389 | 389 | ||
| 390 | /* Number of unprocessed profiler signals. */ | ||
| 391 | static uintptr_t pending_profiler_signals; | ||
| 392 | |||
| 390 | /* The current sampling interval in nanoseconds. */ | 393 | /* The current sampling interval in nanoseconds. */ |
| 391 | static EMACS_INT current_sampling_interval; | 394 | static EMACS_INT current_sampling_interval; |
| 392 | 395 | ||
| @@ -402,7 +405,19 @@ handle_profiler_signal (int signal) | |||
| 402 | count += overruns; | 405 | count += overruns; |
| 403 | } | 406 | } |
| 404 | #endif | 407 | #endif |
| 405 | add_sample (&cpu, count); | 408 | pending_signals = true; |
| 409 | pending_profiler_signals += count; | ||
| 410 | } | ||
| 411 | |||
| 412 | void | ||
| 413 | process_pending_profiler_signals (void) | ||
| 414 | { | ||
| 415 | uintptr_t count = pending_profiler_signals; | ||
| 416 | if (count) | ||
| 417 | { | ||
| 418 | pending_profiler_signals = 0; | ||
| 419 | add_sample (&cpu, count); | ||
| 420 | } | ||
| 406 | } | 421 | } |
| 407 | 422 | ||
| 408 | static void | 423 | static void |