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

To reply to this bug, email your comments to 57197 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#57197; Package emacs. (Sun, 14 Aug 2022 04:19:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 14 Aug 2022 04:19:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57197; Package emacs. (Mon, 15 Aug 2022 05:59:01 GMT) Full text and rfc822 format available.

Message #8 received at 57197 <at> debbugs.gnu.org (full text, mbox):

From: Akib Azmain Turja <akib <at> disroot.org>
To: yantar92 <at> gmail.com, 57197 <at> debbugs.gnu.org
Subject: bug#57197: 28.1.90; Can pure side-effect-free functions use
 multiple CPUs in Elisp?
Date: Mon, 15 Aug 2022 11:57:31 +0600
[Message part 1 (text/plain, inline)]
> 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
>

I think the problem is the interpreter itself, which is not thread-safe.
This looks like a feature request, I think emacs-devel is good for that.

-- 
Akib Azmain Turja

Find me on Mastodon at @akib <at> hostux.social.

This message is signed by me with my GnuPG key.  Its fingerprint is:

    7001 8CE5 819F 17A3 BBA6  66AF E74F 0EFA 922A E7F5
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57197; Package emacs. (Mon, 15 Aug 2022 07:14:01 GMT) Full text and rfc822 format available.

Message #11 received at 57197 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Akib Azmain Turja <akib <at> disroot.org>
Cc: yantar92 <at> gmail.com, 57197 <at> debbugs.gnu.org
Subject: Re: bug#57197: 28.1.90; Can pure side-effect-free functions use
 multiple CPUs in Elisp?
Date: Mon, 15 Aug 2022 09:13:41 +0200
Akib Azmain Turja <akib <at> disroot.org> writes:

> I think the problem is the interpreter itself, which is not thread-safe.

Yes, the interpreter (byte-code or not) itself is not thread-safe, so I
don't think it's feasible to do anything here without a serious rewrite
of that.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57197; Package emacs. (Mon, 15 Aug 2022 08:05:02 GMT) Full text and rfc822 format available.

Message #14 received at 57197 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: Akib Azmain Turja <akib <at> disroot.org>
Cc: 57197 <at> debbugs.gnu.org
Subject: Re: bug#57197: 28.1.90; Can pure side-effect-free functions use
 multiple CPUs in Elisp?
Date: Mon, 15 Aug 2022 16:05:43 +0800
Akib Azmain Turja <akib <at> disroot.org> writes:

> I think the problem is the interpreter itself, which is not
> thread-safe.

Thanks for the clarification! This is unfortunate.

> This looks like a feature request, I think emacs-devel is good for that.

I have heard on emacs-devel that M-x report-emacs-bug should also be
used for feature requests. Moreover, CONTRIBUTE says:

    Bug reports and fixes, feature requests and patches/implementations
    should be sent to bug-gnu-emacs <at> gnu.org, the bug/feature list.  This
    is coupled to the https://debbugs.gnu.org tracker.  It is best to use
    the command 'M-x report-emacs-bug RET' to report issues to the tracker
    (described below).  Be prepared to receive comments and requests for
    changes in your patches, following your submission.

Let me know if I miss something.

-- 
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57197; Package emacs. (Mon, 15 Aug 2022 09:52:02 GMT) Full text and rfc822 format available.

Message #17 received at 57197 <at> debbugs.gnu.org (full text, mbox):

From: Akib Azmain Turja <akib <at> disroot.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 57197 <at> debbugs.gnu.org
Subject: Re: bug#57197: 28.1.90; Can pure side-effect-free functions use
 multiple CPUs in Elisp?
Date: Mon, 15 Aug 2022 15:43:04 +0600
[Message part 1 (text/plain, inline)]
Ihor Radchenko <yantar92 <at> gmail.com> writes:

>> This looks like a feature request, I think emacs-devel is good for that.
>
> I have heard on emacs-devel that M-x report-emacs-bug should also be
> used for feature requests. Moreover, CONTRIBUTE says:
>
>     Bug reports and fixes, feature requests and patches/implementations
>     should be sent to bug-gnu-emacs <at> gnu.org, the bug/feature list.  This
>     is coupled to the https://debbugs.gnu.org tracker.  It is best to use
>     the command 'M-x report-emacs-bug RET' to report issues to the tracker
>     (described below).  Be prepared to receive comments and requests for
>     changes in your patches, following your submission.
>
> Let me know if I miss something.

Maybe I'm wrong.  But looks like discussion takes place mainly on
emacs-devel.  Please correct me if I'm wrong.

-- 
Akib Azmain Turja

Find me on Mastodon at @akib <at> hostux.social.

This message is signed by me with my GnuPG key.  Its fingerprint is:

    7001 8CE5 819F 17A3 BBA6  66AF E74F 0EFA 922A E7F5
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57197; Package emacs. (Mon, 15 Aug 2022 11:47:02 GMT) Full text and rfc822 format available.

Message #20 received at 57197 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Akib Azmain Turja <akib <at> disroot.org>
Cc: yantar92 <at> gmail.com, 57197 <at> debbugs.gnu.org
Subject: Re: bug#57197: 28.1.90;
 Can pure side-effect-free functions use multiple CPUs in Elisp?
Date: Mon, 15 Aug 2022 14:46:38 +0300
> Cc: 57197 <at> debbugs.gnu.org
> Date: Mon, 15 Aug 2022 15:43:04 +0600
> From:  Akib Azmain Turja via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> >> This looks like a feature request, I think emacs-devel is good for that.
> >
> > I have heard on emacs-devel that M-x report-emacs-bug should also be
> > used for feature requests. Moreover, CONTRIBUTE says:
> >
> >     Bug reports and fixes, feature requests and patches/implementations
> >     should be sent to bug-gnu-emacs <at> gnu.org, the bug/feature list.  This
> >     is coupled to the https://debbugs.gnu.org tracker.  It is best to use
> >     the command 'M-x report-emacs-bug RET' to report issues to the tracker
> >     (described below).  Be prepared to receive comments and requests for
> >     changes in your patches, following your submission.
> >
> > Let me know if I miss something.
> 
> Maybe I'm wrong.  But looks like discussion takes place mainly on
> emacs-devel.  Please correct me if I'm wrong.

You are both right.

Feature requests should in general be sent as bug reports.  However,
if a feature request is likely to mean a major redesign of a large
part of Emacs, it is best first to discuss it on emacs-devel, so that
we could assess its feasibility with more hands on deck.




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.