GNU bug report logs - #57197
28.1.90; Can pure side-effect-free functions use multiple CPUs in Elisp?

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> gmail.com>

Date: Sun, 14 Aug 2022 04:19:01 UTC

Severity: normal

Found in version 28.1.90

Full log


View this message in rfc822 format

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: 57197 <at> debbugs.gnu.org
Subject: bug#57197: 28.1.90; Can pure side-effect-free functions use multiple CPUs in Elisp?
Date: Sun, 14 Aug 2022 12:18:52 +0800
Hi,

The known blocker of Elisp support of multi-threading is shared Elisp
machine state. Handling competing access to global Elisp variables is
tricky. However, it is not the case for pure side-effect-free functions.

Consider the following code:

(let (long-list-of-cons)
  (dotimes (i 100000)
    (push (cons i (1+ i)) long-list-of-cons))
  (mapcar #'car long-list-of-cons))

The last mapcar looks like a good candidate to run on multiple CPUs.
I imagine that instead of applying #'car sequentially, Elisp can split
the list in chunks and run them independently on multiple CPUs. This
operation is still blocking and thus will not create issues with shared
access. At the same time such mapcar call will finish much faster.

Would something like this be feasible to implement in Elisp?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




This bug report was last modified 2 years and 309 days ago.

Previous Next


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