GNU bug report logs - #57196
28.1.90; An idea to allow background (low-priority) threads

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Ihor Radchenko <yantar92@HIDDEN>; dated Sun, 14 Aug 2022 04:12:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at>

Received: (at submit) by; 14 Aug 2022 04:11:31 +0000
From debbugs-submit-bounces <at> Sun Aug 14 00:11:31 2022
Received: from localhost ([]:35571
	by with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at>>)
	id 1oN4yI-0001wc-KC
	for submit <at>; Sun, 14 Aug 2022 00:11:31 -0400
Received: from ([]:57738)
 by with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1oN4yD-0001wS-TM
 for submit <at>; Sun, 14 Aug 2022 00:11:29 -0400
Received: from ([2001:470:142:3::10]:35044)
 by with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1oN4yD-0001xh-Ou
 for bug-gnu-emacs@HIDDEN; Sun, 14 Aug 2022 00:11:25 -0400
Received: from ([2607:f8b0:4864:20::102e]:41675)
 by with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1oN4y9-0001ZQ-My
 for bug-gnu-emacs@HIDDEN; Sun, 14 Aug 2022 00:11:25 -0400
Received: by with SMTP id
 for <bug-gnu-emacs@HIDDEN>; Sat, 13 Aug 2022 21:11:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20210112;
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20210112;
X-Gm-Message-State: ACgBeo0VxHj1pkTJ9JHMxLpSW7rnTxNwMmus3yr8xnnCTfO89Ad49kv1
X-Google-Smtp-Source: AA6agR67xI3oEVlq0cXy6sEcs55uRpfEeZcjPqUvWUqaHdLo1ehf9LwufhUN6ONG+z9ld0Yel1XcwQ==
X-Received: by 2002:a17:90a:9907:b0:1f5:2318:ea6d with SMTP id
 Sat, 13 Aug 2022 21:11:19 -0700 (PDT)
Received: from localhost ([2409:8a70:2bf:80b0:8ec6:81ff:fe70:339d])
 by with ESMTPSA id
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 13 Aug 2022 21:11:19 -0700 (PDT)
From: Ihor Radchenko <yantar92@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.1.90; An idea to allow background (low-priority) threads
Date: Sun, 14 Aug 2022 12:12:20 +0800
Message-ID: <878rnr1n17.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2607:f8b0:4864:20::102e;
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.0 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at>
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <>
List-Unsubscribe: <>, 
 <mailto:debbugs-submit-request <at>>
List-Archive: <>
List-Post: <mailto:debbugs-submit <at>>
List-Help: <mailto:debbugs-submit-request <at>>
List-Subscribe: <>, 
 <mailto:debbugs-submit-request <at>>
Errors-To: debbugs-submit-bounces <at>
Sender: "Debbugs-submit" <debbugs-submit-bounces <at>>
X-Spam-Score: -2.1 (--)


Emacs does have a limited concurrency support via Threads, which is,
unfortunately, mostly a toy feature I haven't seen being used a lot.

All my attempts to implement some real functionality using threads
failed because it is very hard to create real-life threads that do not
noticeably block Emacs. Most of the time, Emacs gets quite sluggish,
even if the thread yields frequently.

Such situation sounds similar to what one may get with 1CPU and
multiple processed fighting for the CPU time. This is something that
used to be solved with nice command.

Could something like nice be implemented for Elisp threads?

Or, alternatively, could thread execution be limited in some ways?
I have the approach taken by org-element cache processing in mind.
org-element limits cache processing using the following variables:

(defvar org-element-cache-sync-idle-time 0.6
  "Length, in seconds, of idle time before syncing cache.")

(defvar org-element-cache-sync-duration 0.04
  "Maximum duration, as a time value, for a cache synchronization.
If the synchronization is not over after this delay, the process
pauses and resumes after `org-element-cache-sync-break'

(defvar org-element-cache-sync-break 0.3
  "Duration, as a time value, of the pause between synchronizations.
See `org-element-cache-sync-duration' for more information.")

I imagine that something similar could be done for threads.
`make-thread' could allow some kind of priority setting that will limit
its execution time to comfortable levels, so that the user in main
thread can actually interact with Emacs without noticing anything.


Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at
Support Org development at,
or support my work at

Acknowledgement sent to Ihor Radchenko <yantar92@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#57196; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 14 Aug 2022 04:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.