From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: hw Newsgroups: gmane.emacs.devel Subject: Re: User interaction from multiple threads Date: Sun, 02 Sep 2018 18:37:15 +0200 Organization: my virtual residence Message-ID: <87a7ozg8jo.fsf@himinbjorg.adminart.net> References: <838t59j821.fsf@gnu.org> <834lflb2fj.fsf@gnu.org> <83h8jk9l41.fsf@gnu.org> <8336v2994c.fsf@gnu.org> <83bm9q6x7v.fsf@gnu.org> <874lfi863s.fsf@himinbjorg.adminart.net> <83va7x5guc.fsf@gnu.org> <871sakl97g.fsf@himinbjorg.adminart.net> <8336uz6e8e.fsf@gnu.org> <877ekbego9.fsf@himinbjorg.adminart.net> <83mut73vau.fsf@gnu.org> <87lg8qqh9n.fsf@himinbjorg.adminart.net> <83mut52o8g.fsf@gnu.org> <877ek9oscr.fsf@himinbjorg.adminart.net> <83o9dk0xu0.fsf@gnu.org> <87in3rmpis.fsf@himinbjorg.adminart.net> <83ftyt120d.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1535906946 28041 195.159.176.226 (2 Sep 2018 16:49:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 2 Sep 2018 16:49:06 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: psainty@orcon.net.nz, gazally@runbox.com, rms@gnu.org, emacs-devel-bounces+psainty=orcon.net.nz@gnu.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 02 18:49:02 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fwVYb-00077R-BO for ged-emacs-devel@m.gmane.org; Sun, 02 Sep 2018 18:49:01 +0200 Original-Received: from localhost ([::1]:41735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwVah-0000kj-Ia for ged-emacs-devel@m.gmane.org; Sun, 02 Sep 2018 12:51:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwVaU-0000eC-3x for emacs-devel@gnu.org; Sun, 02 Sep 2018 12:50:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwVTW-0004LL-RH for emacs-devel@gnu.org; Sun, 02 Sep 2018 12:43:47 -0400 Original-Received: from mo6-p01-ob.smtp.rzone.de ([2a01:238:20a:202:5301::12]:29580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fwVTT-0004IR-U5; Sun, 02 Sep 2018 12:43:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1535906622; s=strato-dkim-0002; d=adminart.net; h=Sender:References:Message-ID:Date:In-Reply-To:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=CBRfDnGHeeUOXRleADnl8xgDQuP24T+bQK1650qQTNc=; b=kjoXHc7SfDbb6PBvgGGT1yx26hcu+IPLEqmj/U8FsCq0lMxC0bDy4e6w9Pa0kT8GF4 ONn4/GEbcIsl8yPShXgvZc6CYM9icILbFHx/bsxAchKeaJSOUers5KCmTJnKNbSIF7Lx xu2a1dyahX67YHvVldgrZSU4bPzGsC8+Q6yVZQRzT+SFRGnL6cF5BRD50VXGjoj6dH97 7b0ynhKrcTJ6Mnpv1bjEtB2aK7oF2C/tolEO3cr18p1deF7LWsMjufE7EYUWNDdp9CoK GWVMVNHSQo4cE/6RMrpA/zbxBuCGMdoR+Y2507UayRv2lAVFXgkVPdFOrMGZQaudndcj Gp4Q== X-RZG-AUTH: ":O2kGeEG7b/pS1FS4THaxjVF9w0vVgfQ9xGcjwO5WMRo5c+h5ceMqQWZ3yrBp+AVdIIwXjneEe9k=" X-RZG-CLASS-ID: mo00 Original-Received: from himinbjorg.adminart.net by smtp.strato.de (RZmta 43.21 DYNA|AUTH) with ESMTPSA id j020b1u82GhWFGG (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Sun, 2 Sep 2018 18:43:32 +0200 (CEST) Original-Received: from lee by himinbjorg.adminart.net with local (Exim 4.90_1) (envelope-from ) id 1fwVTH-0000ZR-Sq; Sun, 02 Sep 2018 18:43:31 +0200 In-Reply-To: <83ftyt120d.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 01 Sep 2018 21:55:14 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5301::12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:229181 Archived-At: Eli Zaretskii writes: >> From: hw >> Cc: psainty@orcon.net.nz, gazally@runbox.com, rms@gnu.org, emacs-devel-bounces+psainty=orcon.net.nz@gnu.org, emacs-devel@gnu.org >> Date: Sat, 01 Sep 2018 19:32:07 +0200 >> >> > There's very little overhead, but if you are interested in the >> > details, I suggest to read thread.c. It's not a lot of code, and the >> > ideas are quite simple. >> >> I wish I had at least 50 lifetimes so I could do more of what I would >> like to do. > > Same here. > >> Would you say that when a user is writing a function that does some >> string replacements within texts that are usually between 16 and >> 64kB in size should use multiple threads to replace different >> strings or not? > > Could be, if the code is written to yield from time to time. Does that mean functions like (replace-string) should now be rewritten to yield time? Or are they already written like that? Will or did that slow them down? Or does it mean someone writing a function should always write it so that it yields time, accepting that it might be slowed down? >> I would expect it to be slower because of the overhead unless multiple >> threads could run at the same time. Since they can't, what would be an >> advantage of using multiple threads? > > It is advantageous if some of the threads call yielding APIs, since > then other threads could run while they are waiting. Shouldn't threads that are just waiting yield time to others automatically? When I use Term::ReadKey in perl to read a key, my program can be waiting for a key to be pressed without using CPU time. It does that automatically.