From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Emacs design and architecture. How about copy-on-write? Date: Wed, 20 Sep 2023 18:22:19 +0800 Message-ID: <87a5thta90.fsf@yahoo.com> References: <0518f65b-1dd1-6923-8497-da4d3aeac631@gutov.dev> <87sf7fc7kd.fsf@dataswamp.org> <834jjuk68t.fsf@gnu.org> <87cyyhc7uu.fsf@dataswamp.org> <83ttrsg9nx.fsf@gnu.org> <83h6nrg4eg.fsf@gnu.org> <83v8c7elan.fsf@gnu.org> <877conk5ny.fsf@localhost> <83ttrreeu0.fsf@gnu.org> <87bkdzeas1.fsf@localhost> <83cyyfe5l8.fsf@gnu.org> <8734zbyu6o.fsf@dataswamp.org> <835y46e8o9.fsf@gnu.org> <87zg1ixvnc.fsf@dataswamp.org> <87il86nxts.fsf@localhost> <87o7hyx8h2.fsf@dataswamp.org> <87o7hx88ry.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="17601"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Emanuel Berg , emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 20 12:23:26 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 1qiuMf-0004Oe-Lc for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Sep 2023 12:23:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiuLw-0005Xm-Ky; Wed, 20 Sep 2023 06:22:40 -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 1qiuLv-0005XQ-0U for emacs-devel@gnu.org; Wed, 20 Sep 2023 06:22:39 -0400 Original-Received: from sonic303-21.consmr.mail.ne1.yahoo.com ([66.163.188.147]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiuLt-0007Vo-1b for emacs-devel@gnu.org; Wed, 20 Sep 2023 06:22:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695205353; bh=TrrICT8CDEFua1Ts/3DLRkqrDZcZfGNRnWx7/hH1/gQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=E+DvD+8vrzpfXis0tNl9lqwSplU9uoH3YrHRH+o94mj8HoD3qPicPN2GyevtJmF7mSlkPQnOl6VekhnoZ26i9h5q2Nq48YNf3Lst0tgmg9heregO+mFp21IBPdVijHCms+5vcgLLnRCNJZrspUUv3FstkeVErGn79N4uZFoBDGDP50Ia7ryHa/mj2z0DCAYk100bZpWnE+3d/Uxjf9/V7owOCOleELfChn2YWkZL+spHXwJqxAK9Sf9IjOHrKuuKdboFQJ7AjLYuLgUg5GFrI+8YuePVH4QC8fbsuhgp3QoTCM1qLmyhFHBXD5yUbx1vvI3Y4UImiDITtKp0+vkpXA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695205353; bh=9G/LCV3GIWyV4BV7KqtfMcgPTUXOpUFPVhWDEvWKj31=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=iBnjvD/H6V9Q/T1S5bnAX09iVvz46gj6NalIaJstWq+A+3GqTv9lJn8M+Yblnn8vcMovqte/nFWAwkVzontvvLvFm5s4yVJxnskq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mVJzTY8a7h 0Ixv4FZ1EF2Yjdr3yM.ptF1Y_N_jmU3MhtIgRmdsix X-Sonic-MF: X-Sonic-ID: 7af43dd3-3443-43f3-8cd4-c6d80d0c4051 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ne1.yahoo.com with HTTP; Wed, 20 Sep 2023 10:22:33 +0000 Original-Received: by hermes--production-sg3-55c667b499-7t45b (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID f47da05783e81d75ef53bd3676c42993; Wed, 20 Sep 2023 10:22:27 +0000 (UTC) In-Reply-To: <87o7hx88ry.fsf@localhost> (Ihor Radchenko's message of "Wed, 20 Sep 2023 09:59:45 +0000") X-Mailer: WebService/1.1.21797 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.188.147; envelope-from=luangruo@yahoo.com; helo=sonic303-21.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:310813 Archived-At: Ihor Radchenko writes: > Emanuel Berg writes: > >> Ihor Radchenko wrote: >> >>> Because implementation details are tricky - a lot of Elisp >>> internal machinery is relying upon modifying global symbol >>> objects [...] >> >> Yeah, but that should be fine, as long as they are locked and >> unlocked safely, right? > > No. > > If we have something like (let ((case-fold-search t)) ...), we will lock > `case-fold-search' symbol for the whole duration of `let' call and block > any other threads trying to alter `case-fold-search' locally. Emacs does not store the default value of each symbol in the variables which they forward to. All DEFVARs are thread local in this sense, for each thread must be capable of simultaneously binding different values to the same variable. In my implementation, struct thread_state incorporates pointers to all forwarded variables, each of which either points within thread_state itself when its symbol is bound locally, or to `globals' otherwise. Vcharset_map_path thus becomes: #define Vcharset_map_path (*current_thread->f_Vcharset_map_path) That being said, case-fold-search is a bad example. I have not yet established how buffer local variables will be efficiently represented when multiple threads selecting the same buffer bind the same variables simultaneously. Once that hurdle is surmounted and the regex engine itself is rendered thread-safe, threads will be capable of calling regexp matching functions concurrently, with only their local bindings of case_fold_search taking effect. No symbol-based locking necessary.