From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Elias_M=C3=A5rtenson?= Newsgroups: gmane.emacs.devel Subject: Re: Threading IO-bound functions Date: Mon, 19 Dec 2016 11:03:32 +0800 Message-ID: References: <8360mj99oe.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11443a8a3693d80543fa2a3a X-Trace: blaine.gmane.org 1482116629 2108 195.159.176.226 (19 Dec 2016 03:03:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Dec 2016 03:03:49 +0000 (UTC) Cc: emacs-devel To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 19 04:03:43 2016 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 1cIoEo-0007nY-Eh for ged-emacs-devel@m.gmane.org; Mon, 19 Dec 2016 04:03:42 +0100 Original-Received: from localhost ([::1]:43013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cIoEr-0007Sf-00 for ged-emacs-devel@m.gmane.org; Sun, 18 Dec 2016 22:03:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cIoEk-0007Sa-CE for emacs-devel@gnu.org; Sun, 18 Dec 2016 22:03:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cIoEj-0006zQ-Ab for emacs-devel@gnu.org; Sun, 18 Dec 2016 22:03:38 -0500 Original-Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:36871) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cIoEh-0006vd-Ls; Sun, 18 Dec 2016 22:03:35 -0500 Original-Received: by mail-wm0-x232.google.com with SMTP id t79so89012685wmt.0; Sun, 18 Dec 2016 19:03:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7wynzGZOysapPdBY7xeJv9TlgVGYsdUWWEQmsl6izs8=; b=vLUhsRRR4E6PgdNsLlWfceGtxaUBfqo+qhowfSs52qRxKisBmE0yY23yGzkfuMOney aRABuG0exgtUxAofB3atMjVhV8TzKbRNr5tiAdeMZ5FApWHD0uPtQmgqYMxz8BMXR4ff R6qQ8QH7FK0/RaCaeDOquxfdLXIaNt5Plk8YB4nhU/FUhKa1LcWKkmVf61mHJFLMfmN9 mGuFhoaH8DL3ZiSUQoo8ePdhb1iB1XI2q0xt0bh2TPvszKC7wP//fI6ihK9cQOsQYIAq SQmDrZ5N4ThVOzxWxMGnW2Ix3JnKyDCpebFFL0diLvK5A6gjWOfETV3BWjepikEjTNDL UDhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7wynzGZOysapPdBY7xeJv9TlgVGYsdUWWEQmsl6izs8=; b=hCRNexDCckCUjCOzp0or3aaNrCfBVf9ZExPqpjEz4Veub/cRRZCcxLouXqqOjULfTL sLwYP3OiFEX8Jqc4Cy/cMFCw8Ck/Q5pbhOX2VOpGAP6qwEy1LFWifa10aZ0k7rW6ximz DvZwwxIfWy27xxhHD/aHpXQPM/MYQGTFcoCRSCrjAMrjj8X4ajVn2JkNO+RviVa4vKpD 00zEOb6meZWJwFmkCuYVVnc+J1D42ZV1anNHJZyp9LRvdOf3uMdJANNfZ4eMrQpixLjc wwUc9wuvJe3Gv8X+TRkrB0Kblbb0HLMEib6SInsyIUWMHATK47g+4zzLyJgVuWrpUuzW 0a7A== X-Gm-Message-State: AIkVDXIOzfODw+NYdJdnvgQbBiLw7JLp8RFhRt/+zDmb82F2Mf+qAGnd0GvAF2YifugHtSgv2DOoi/e/F5O0Tg== X-Received: by 10.28.136.198 with SMTP id k189mr11040534wmd.24.1482116612655; Sun, 18 Dec 2016 19:03:32 -0800 (PST) Original-Received: by 10.80.135.165 with HTTP; Sun, 18 Dec 2016 19:03:32 -0800 (PST) In-Reply-To: <8360mj99oe.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::232 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:210616 Archived-At: --001a11443a8a3693d80543fa2a3a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 16 December 2016 at 23:26, Eli Zaretskii wrote: > > From: Elias M=C3=A5rtenson > > Date: Thu, 15 Dec 2016 12:01:51 +0800 > > > > The number one function that I call that sometimes hang for a > significant amount of time is =E2=80=98gnus=E2=80=99. I decided to > > try running it in a thread, and it worked surprisingly well. Initial > loading of the messages can now be done in the > > background. > > Beginner's luck ;-) > Oh for sure. I was also careful not to do anything that may upset it (like running other gnus-functions at the same time). The fact that my macro implements one lock per function only makes it usable for single-operation functions. Gnus should probably a global lock that ensures that only one Gnus function at a time is called. This issue can't be limited to just Gnus, so perhaps Emacs should provide some higher-level facility to implement this stuff. > Did you try this in "emacs -nw"? And without your Gnus > customizations, which allow some shortcuts? Half way through its > initialization, Gnus asks a question, and then you get bug#25214. > I was using the GTK Emacs, and yes, if it asks a question, the entire Emacs crashes is the most bizarre way. My workaround is simply making sure that it doesn't interact with the user. > > I'd like to have people's opinions on this strategy, and if it might be > reasonable to default =E2=80=98gnus=E2=80=99 to do this when > > run on Emacs versions with concurrency support. > > I think we need first to solve the above problem in some way. Or > change Gnus to not ask any questions from a background thread. > I think most questions are asked using =E2=80=98read-string=E2=80=99 or som= e variant like =E2=80=98completing-read=E2=80=99, right? At the very least, I think that c= oncurrent Emacs needs to make sure that the behaviour of these functions are well-defined in the context of threading. --001a11443a8a3693d80543fa2a3a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 1= 6 December 2016 at 23:26, Eli Zaretskii <eliz@gnu.org> wrote:
=
> From: Elias M=C3=A5r= tenson <lokedhs@gmail.com> > Date: Thu, 15 Dec 2016 12:01:51 +0800
>
> The number one function that I call that sometimes hang for a signific= ant amount of time is =E2=80=98gnus=E2=80=99. I decided to
> try running it in a thread, and it worked surprisingly well. Initial l= oading of the messages can now be done in the
> background.

Beginner's luck ;-)

Oh for s= ure. I was also careful not to do anything that may upset it (like running = other gnus-functions at the same time).

The fact t= hat my macro implements one lock per function only makes it usable for sing= le-operation functions. Gnus should probably a global lock that ensures tha= t only one Gnus function at a time is called. This issue can't be limit= ed to just Gnus, so perhaps Emacs should provide some higher-level facility= to implement this stuff.
=C2=A0
Did you try this in "emacs -nw"?=C2=A0 And= without your Gnus
customizations, which allow some shortcuts?=C2=A0 Half way through its
initialization, Gnus asks a question, and then you get bug#25214.

I was using the GTK Emacs, and yes, if it asks a= question, the entire Emacs crashes is the most bizarre way.

=
My workaround is simply making sure that it doesn't interact= with the user.
=C2=A0
> I'd like to have people's = opinions on this strategy, and if it might be reasonable to default =E2=80= =98gnus=E2=80=99 to do this when
> run on Emacs versions with concurrency support.

I think we need first to solve the above problem in some way.=C2=A0 = Or
change Gnus to not ask any questions from a background thread.

I think most questi= ons are asked using =E2=80=98read-string=E2=80=99 or some variant like =E2= =80=98completing-read=E2=80=99, right? At the very least, I think that conc= urrent Emacs needs to make sure that the behaviour of these functions are w= ell-defined in the context of threading.
--001a11443a8a3693d80543fa2a3a--