From f9b07e1c7a013ebba2a2517458fc099ad220c3b7 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Thu, 11 Jul 2024 17:45:00 +0200 Subject: [PATCH] erts: Optimize PSD cleanup --- erts/emulator/beam/erl_process.c | 50 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index e6f68f079770..1c64051de3be 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -13275,41 +13275,41 @@ delete_process(Process* p) /* free all pending messages */ erts_proc_sig_cleanup_queues(p); - scb = ERTS_PROC_SET_SAVED_CALLS_BUF(p, NULL); + /* Cleanup psd */ + + psd = (ErtsPSD *) erts_atomic_read_nob(&p->psd); + if (psd) { + scb = ERTS_PROC_SET_SAVED_CALLS_BUF(p, NULL); - if (scb) { + if (scb) { #ifndef BEAMASM - p->fcalls += CONTEXT_REDS; /* Reduction counting depends on this... */ + p->fcalls += CONTEXT_REDS; /* Reduction counting depends on this... */ #endif - erts_free(ERTS_ALC_T_CALLS_BUF, (void *) scb); - } - - pbt = ERTS_PROC_SET_CALL_TIME(p, NULL); - while (pbt) { - process_breakpoint_trace_t *next = pbt->next; - erts_free(ERTS_ALC_T_BPD, (void *) pbt); - pbt = next; - } - pbt = ERTS_PROC_SET_CALL_MEMORY(p, NULL); - while (pbt) { - process_breakpoint_trace_t *next = pbt->next; - erts_free(ERTS_ALC_T_BPD, (void *) pbt); - pbt = next; - } - - erts_destroy_nfunc(p); + erts_free(ERTS_ALC_T_CALLS_BUF, (void *) scb); + } - /* Cleanup psd */ + pbt = ERTS_PROC_SET_CALL_TIME(p, NULL); + while (pbt) { + process_breakpoint_trace_t *next = pbt->next; + erts_free(ERTS_ALC_T_BPD, (void *) pbt); + pbt = next; + } + pbt = ERTS_PROC_SET_CALL_MEMORY(p, NULL); + while (pbt) { + process_breakpoint_trace_t *next = pbt->next; + erts_free(ERTS_ALC_T_BPD, (void *) pbt); + pbt = next; + } - psd = (ErtsPSD *) erts_atomic_read_nob(&p->psd); + erts_destroy_nfunc(p); - if (psd) { if (psd->data[ERTS_PSD_SYSMON_MSGQ_LEN_LOW]) { erts_clear_all_msgq_low_sessions(p); } - erts_atomic_set_nob(&p->psd, (erts_aint_t) NULL); /* Reduction counting depends on this... */ - erts_free(ERTS_ALC_T_PSD, psd); + + erts_atomic_set_nob(&p->psd, (erts_aint_t) NULL); /* Reduction counting depends on this... */ + erts_free(ERTS_ALC_T_PSD, psd); } /* Clean binaries and funs */