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.devel Subject: Re: Concurrency via isolated process/thread Date: Fri, 07 Jul 2023 14:29:48 +0000 Message-ID: <87o7knbxr7.fsf@localhost> References: <871qhnr4ty.fsf@localhost> <87jzve8r4m.fsf@localhost> <871qhmo5nv.fsf@yahoo.com> <87bkgq8p5t.fsf@localhost> <831qhmjwk0.fsf@gnu.org> <875y6y8nlr.fsf@localhost> <87h6qhnalc.fsf@yahoo.com> <87ilax71wo.fsf@localhost> <878rbtkz2c.fsf@yahoo.com> <87a5w96x2o.fsf@localhost> <87jzvdjjp4.fsf@yahoo.com> <877crd6w53.fsf@localhost> <877crdjiwn.fsf@yahoo.com> <874jmh6v4s.fsf@localhost> <83y1jtgmbw.fsf@gnu.org> <87zg49xfke.fsf@localhost> <83sfa1gjns.fsf@gnu.org> <87r0plxbep.fsf@localhost> <83ilawhpi6.fsf@gnu.org> <87zg48apwr.fsf@localhost> <83edljg8ub.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40005"; mail-complaints-to="usenet@ciao.gmane.io" Cc: luangruo@yahoo.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 07 16:30:46 2023 Return-path: Envelope-to: ged-emacs-devel@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 1qHmTu-000AGR-0p for ged-emacs-devel@m.gmane-mx.org; Fri, 07 Jul 2023 16:30:46 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHmTC-0004gJ-1Q; Fri, 07 Jul 2023 10:30:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHmTB-0004dp-4d for emacs-devel@gnu.org; Fri, 07 Jul 2023 10:30:01 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHmT8-0001wq-Qz for emacs-devel@gnu.org; Fri, 07 Jul 2023 10:30:00 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id E29A1240029 for ; Fri, 7 Jul 2023 16:29:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1688740196; bh=hC4oyN10Our0Kx0QAqWqvVKy8jUAJDMpluEmncXVezs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=LNoUJ27wrIC335M72BkWeqLcvlAXuojPjWjkbVbBlV949x6bny1sdi9hxMocdKUZ4 RdFuZXhLzNHbYxC7IK+4ZW2EiCtJfRCtVMTXUt2y/rZHHdbvXseTsSUmtdFzHxjtcc JLtV7vXpbHsgDkdeegM7rJ9zibA65xJk7I/bel+8hYVUNuNeB8ixZtW+j8kN5H3kGh kA8gPyGzEilzcOh3/VqYitrcV8PQ5ekpXIeyUaaRG23DfSYY22AD6WxAjMe+eyjXAk i/xEM4hz+p27e5zhprkLgQ8g3YlJiJrvEGSCNZVvsEla7amp43LU4f8bbmJEiUpKYr Hi0+7PXqPmKCQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QyG5020S1z6tsj; Fri, 7 Jul 2023 16:29:56 +0200 (CEST) In-Reply-To: <83edljg8ub.fsf@gnu.org> Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307578 Archived-At: Eli Zaretskii writes: >> What you are describing will only affect subr primitives that work >> directly with C structs and address space. > > But that's how _everything_ works in Emacs. No Lisp runs except by > calling primitives. Looks like we have some misunderstanding here, because I do not clearly see how this kind of catch-all argument can be obvious. >> So, we can distinguish two locks: (1) low-level, only available to C >> subroutines; (2) Elisp-level, where the lock merely prevents other Elisp >> code from modifying the data. GC is safe to run when type-2 lock is in >> place as it will never clear the data in use and never alter the data in >> any way visible on Elisp level. > > Emacs doesn't know whether some C code which runs was invoked from C > or from Lisp. (Basically, everything is invoked from Lisp, one way or > another, as soon as we call recursive-edit from 'main' for the first > time after startup.) Let me elaborate. What GC is doing may affect C pointers to internal representations of Elisp objects. But never the Lisp representations. So, GC running only matters during a subroutine execution. And not every subroutine - just for a subset where we directly work with internal object structs. The subroutines that are GC-sensitive will need to set and release the object lock before/after they are done working with that object. That object lock type will be set in C code directly and will not be available from Elisp. This approach will, in the worst case, delay the GC by N_threads * time_between_maybe_gc_calls_in_code. This is a rather small price to pay in my book. GC is much less frequent (orders less) than the time between calls to maybe_gc. >> I do not think that it is that bad if we consider type-1 locks. > > There are no type-1 and type-2 locks. They are indistinguishable. I suggest to create two distinguishable locks - one that prevents GC and one that does not. Type-1 will ever only be set from some subset of C subroutines and will generally not lock for too long. Type-2 can be set from the Elisp code, can hold for a long time, but will not prevent GC. > You are trying to solve what constitutes a very small, almost > negligible, part of the problem. The elephant in the room is > something else. Ok. Please, describe the elephant in details. Then, we will be able to focus on this real big problem. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at