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 21:35:49 +0800 Message-ID: <874jjprmq2.fsf@yahoo.com> References: <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> <87a5thta90.fsf@yahoo.com> <87led1865h.fsf@localhost> <875y45t7yo.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37593"; 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 15:36:57 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 1qixNx-0009Zf-HU for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Sep 2023 15:36:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qixNC-0001SP-FT; Wed, 20 Sep 2023 09:36:10 -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 1qixN8-0001S4-IP for emacs-devel@gnu.org; Wed, 20 Sep 2023 09:36:06 -0400 Original-Received: from sonic308-56.consmr.mail.ne1.yahoo.com ([66.163.187.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qixN6-0004uR-KM for emacs-devel@gnu.org; Wed, 20 Sep 2023 09:36:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695216961; bh=6o9a4S66evPKOu9uZ3pgUT1UqV9zrZen/mldoBETgsg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=rGUJSlgRU+QojSTvMLF4SQoQ7ona7hRi4Uxr73wnAqVphyQxDZdiQYNYaMNdZaFgw9/aZZruQO3y1IUdqIfTSvhRafSwD6An3UosUiqqhs8Yv4EyUboSt9UrrW7mNffD+grvoSSLPjDUH2uHZO0iK59Y7g5pUfOzEl+WdqgC+BQz2qxz9r+q5rb6BwWYNC6ZytRaQL10MrR2hIoGma5Ww77slZQbvsH8+fEArTJACSFk+QpMGVUgR/IuRmdY4YA66cpwITszVKLcY2IUIrHmDNNiMVaYoLcZaChGowNFDtzHVHkMc1AcLlNmx009T26kN+Ew/P1bfsLr+X+Bck8WRA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695216961; bh=/IFiwbexottA8LxGtxqO02QZZg+XC4PWvHPRV0eKWbm=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=J9hrYYs6URKtw+bgyMEbv65xK0WSlOkDPaPhpKZvFSRIU0yXWmUdYiKtxeJ8bBGMuCwbzRYkc/SfPHhQh3f51sD+ERLz+5/SDbAyl7oWjGDOA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X13 BuUwuUhPqB5iK.VVdKlKtPthy5htYe0KEogfe2GJxG X-Sonic-MF: X-Sonic-ID: d4e67bbd-e122-473f-a0bc-37eafaf866ac Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Wed, 20 Sep 2023 13:36:01 +0000 Original-Received: by hermes--production-sg3-55c667b499-xh9wt (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 87773a598a4221ecf6583f053df675c4; Wed, 20 Sep 2023 13:35:57 +0000 (UTC) In-Reply-To: <875y45t7yo.fsf@yahoo.com> (Po Lu's message of "Wed, 20 Sep 2023 19:11:43 +0800") 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.187.31; envelope-from=luangruo@yahoo.com; helo=sonic308-56.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:310836 Archived-At: Po Lu writes: > Ihor Radchenko writes: > >> Does it mean that each threads contains a copy of the whole `globals'? I >> think I proposed this in the linked thread and it was objected as >> something taking a lot of memory. > > It incorporates one pointer for each field within globals itself. AFAIU > that was the initial impetus for introducing struct emacs_globals in the > first place. > >> IMHO, copy-of-write would be better here - only store the thread-local >> values that are actually altered by the thread. > > Of course only specbound values will be saved within each thread's > state, but each thread must maintain a pointer to the field that is > actually holding the value of the forwarded variables. > >> Indeed, a simple #define will not be enough then, but we would not waste >> memory copying the values that will never be changed anyway. > > On my machine, struct emacs_globals is 7490 bytes, just short of 7 KiB. Correction: just over 7 KiB.