LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0123-Fix-tracing-of-dirty-NIFs-on-debug-builds.patch of Package erlang (Project home:Ledest:erlang:20)

From d577018a76db8382421bcc6e7ed2dd2717867302 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Wed, 6 Dec 2017 16:18:31 +0100
Subject: [PATCH] "Fix" tracing of dirty NIFs on debug builds

When a dirty NIF is executed a "schedule in" trace event is
generated, which may in turn result in a generic system task being
created, causing the process to be scheduled out as it can't run
dirty with pending tasks.

This is usually fine since said system task is seldom created, but
ERTS_FORCE_ENIF_SEND_DELAY was de-facto always on for debug builds,
causing the process to bounce between dirty and normal schedulers

This commit is not a complete fix and it can go off the rails even
on normal builds; if there's a lot of dirty jobs lined up and the
receiver's msgq lock happens to be busy at the wrong time, the
additional trace messages generated through this will hammer the
lock and keep everything bouncing.
 erts/emulator/beam/erl_nif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index abb490cf9c..0a5fe026db 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -562,7 +562,7 @@ void enif_clear_env(ErlNifEnv* env)
 #ifdef DEBUG
 static int enif_send_delay = 0;
-#define ERTS_FORCE_ENIF_SEND_DELAY() (enif_send_delay++ % 2 == 0)
+#define ERTS_FORCE_ENIF_SEND_DELAY() (enif_send_delay++ % 32 == 0)