From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs 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 Message-ID: <875yiv1mqb.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24565"; mail-complaints-to="usenet@ciao.gmane.io" To: 57197@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 14 06:19:31 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oN563-0006Cn-83 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Aug 2022 06:19:31 +0200 Original-Received: from localhost ([::1]:43324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oN560-00034w-Fo for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Aug 2022 00:19:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oN55a-00034Z-FP for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 00:19:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oN55a-0002LA-4H for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 00:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oN55Z-0004HK-V1 for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 00:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Aug 2022 04:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57197 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166045068516384 (code B ref -1); Sun, 14 Aug 2022 04:19:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Aug 2022 04:18:05 +0000 Original-Received: from localhost ([127.0.0.1]:35581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oN54f-0004GB-DE for submit@debbugs.gnu.org; Sun, 14 Aug 2022 00:18:05 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oN54d-0004G3-0X for submit@debbugs.gnu.org; Sun, 14 Aug 2022 00:18:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oN54c-00032G-2F for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 00:18:02 -0400 Original-Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:37541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oN54T-0002Ip-JK for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 00:18:01 -0400 Original-Received: by mail-pl1-x635.google.com with SMTP id m2so3880617pls.4 for ; Sat, 13 Aug 2022 21:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:subject:to:from:from:to:cc; bh=RpdT/2qyRGTy3BgJjjIzRavyiRZCnoNgqHl7sxvPo6Y=; b=hvo8qY9JZX/JhxekxTXuJFBiF4A6ZFlYL/BBLFZM8TMgLNgTPENB2Qq4TSdevTKgiw dy6AJhfYofsu8nJyQqSTt9bhBMXQBFBIzk7yaNVaoxc/3qYkXvuPuBsBJXOAA7BgBDjr QRkVLYUfDJTaNJ1WI2/3IplSQItbmxhiIHEV0OOj+EL6903oRwa3MQssF0+5bzR0QD1z 0d/Aa2mjWpfIH65isDeW+yPLMnlEHTg4t/3yTUcci87RUMDU5VrtL0sPyfbNP/PVKlFD CM58cIRzn1sUWZY7YCDFMFIPt/hvFHaEoOdMTmuRJH/glSomO1GaJIDjm0y4bNtCNeEt WwSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc; bh=RpdT/2qyRGTy3BgJjjIzRavyiRZCnoNgqHl7sxvPo6Y=; b=D4bJ6XNirsGoaWmcWLYEsWDLsgonutAjMIx1NTxhR7KvJOya5z6hF3FES/dMXO4bi7 OOXA6mOaFuI0BKcrLX3/68/iGVosaf0mdz3KQuOiYrmYzQLp2zUbweeeqRhUOuCxdnZX XLjSVTlx+7goAxSFYU2VQ5LZ94j9nrQqOczBzifUL8PZGXOBTq3SJk8mI7zZzgbTHZDZ 69dSyfr9UqdIGrmkUhxLCmZHNyBjs8AZNkQveof25nRg4Vhr4oUJUS4DTBFxPj64zc6/ w1yV5IMIwAhY1Nrn/UZT64PUOgoJ1LBLfeEOFeeSP0EMubqrJEiWgHICnDYjwjjs0uuj 5x9g== X-Gm-Message-State: ACgBeo2QrY290QofHWCZshvMR4J4w5HFqltDahg+waFFjNHUbHsUFfvQ QnOESLswcBBk0Zm5coCXcJJ6LGOROB5zCQ== X-Google-Smtp-Source: AA6agR7DMZZwetzn6e6STq63Y95uYipnwswznjP0TBs9y3FBerdf2ohaa2L6xy0DkiSmWnrNAKsWlw== X-Received: by 2002:a17:902:7883:b0:170:d646:7f00 with SMTP id q3-20020a170902788300b00170d6467f00mr11151062pll.164.1660450671466; Sat, 13 Aug 2022 21:17:51 -0700 (PDT) Original-Received: from localhost ([2409:8a70:2bf:80b0:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id r15-20020aa7988f000000b0052d51acf115sm4366341pfl.157.2022.08.13.21.17.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 21:17:50 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=yantar92@gmail.com; helo=mail-pl1-x635.google.com 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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:239610 Archived-At: 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