File 2125-Group-the-fields-of-ErtsRunQueue-that-are-often-acce.patch of Package erlang

From 1b3c8c183a6067ce0079c0b9cfd3d05dbdd49803 Mon Sep 17 00:00:00 2001
From: Robin Morisset <rmorisset@meta.com>
Date: Wed, 26 Mar 2025 11:10:22 -0700
Subject: [PATCH 15/15] Group the fields of ErtsRunQueue that are often
 accessed by other cores

This is a tiny change that should improve cache locality a bit during
task stealing.
---
 erts/emulator/beam/erl_process.h | 33 ++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/erts/emulator/beam/erl_process.h b/erts/emulator/beam/erl_process.h
index 883a6acf68..dca01e4087 100644
--- a/erts/emulator/beam/erl_process.h
+++ b/erts/emulator/beam/erl_process.h
@@ -469,36 +469,37 @@ struct ErtsMigrationPaths_ {
 
 
 struct ErtsRunQueue_ {
-    int ix;
-
     erts_mtx_t mtx;
+    erts_atomic32_t flags;
+
+    struct {
+	ErtsRunQueueInfo prio_info[ERTS_NO_PROC_PRIO_LEVELS];
+	/* We use the same prio queue for low and
+	   normal prio processes */
+	ErtsRunPrioQueue prio[ERTS_NO_PROC_PRIO_LEVELS-1];
+      Uint context_switches;
+      Uint reductions;
+    } procs;
+
+    erts_aint32_t max_len;
+    erts_atomic32_t len;
+
+    /* The fields above are the ones that are commonly accessed by other cores during task stealing
+       They are grouped together to improve cache locality. */
 
+    int ix;
     ErtsSchedulerSleepList sleepers;
 
     ErtsSchedulerData *scheduler;
     int waiting;
     int woken;
-    erts_atomic32_t flags;
     int check_balance_reds;
     int full_reds_history_sum;
     int full_reds_history[ERTS_FULL_REDS_HISTORY_SIZE];
     int out_of_work_count;
-    erts_aint32_t max_len;
-    erts_atomic32_t len;
     int wakeup_other;
     int wakeup_other_reds;
 
-    struct {
-	Uint context_switches;
-	Uint reductions;
-
-	ErtsRunQueueInfo prio_info[ERTS_NO_PROC_PRIO_LEVELS];
-
-	/* We use the same prio queue for low and
-	   normal prio processes */
-	ErtsRunPrioQueue prio[ERTS_NO_PROC_PRIO_LEVELS-1];
-    } procs;
-
     struct {
 	ErtsMiscOpList *start;
 	ErtsMiscOpList *end;
-- 
2.43.0

openSUSE Build Service is sponsored by