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 19:11:43 +0800 Message-ID: <875y45t7yo.fsf@yahoo.com> References: <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> <87a5thta90.fsf@yahoo.com> <87led1865h.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="30942"; 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 13:13:23 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 1qiv91-0007u5-5L for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Sep 2023 13:13:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiv7q-0000Rm-Op; Wed, 20 Sep 2023 07:12: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 1qiv7l-0000RK-GT for emacs-devel@gnu.org; Wed, 20 Sep 2023 07:12:06 -0400 Original-Received: from sonic312-23.consmr.mail.ne1.yahoo.com ([66.163.191.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiv7i-0008Tk-8x for emacs-devel@gnu.org; Wed, 20 Sep 2023 07:12:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695208318; bh=xazmX+Kl3vFCKMeB3zXS0nqaqFKnhW8h7FAbBxCidQU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=Wv4kB3lr1x+pZK8s1fKDMlVmovGccxKmQbvIig1ET9ejOIuDm+n9eL3m8Z3GvQkahC7UzTfZ0WYtqaBdDDAHC9BqFX90G4OKmmGij1RjE/FR3URSg95oL4jS3QkRFmVaFaCdQVU0VnCkfuAZaPD4S/SovfH56I9n7wsiawKe/W53OnpG3Aa85enRQc76VYL9rD1sxANr1ZIL640m5EK0X8dS9eOWYau1DpBV0lrHohCN5xbLQQHbrCCHU7ITxkNK6YdEC3za+wV0uiIkS2KTHijc1rQjhwQQoHoVN8hZ/TJurRUksiOQM4LkCHJDFhKAQk0uSeoXPb8F4PBGMW3yUQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695208318; bh=h7CcHe3sLQvBEuJYnYa92t8PZh1ZAof6PWqF0RtY8UK=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=MPWIJyENVl1IsKrMjSrqBZ/s0QehyMNTS2xY9HzMwxpKjahR7zLVl77UdwsGYSjquyg49mxRuKxqSTeUScqUMwWVzy+bd7zpn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ikpFO 4xzr3WNL1dHwqFDsl3EfI.upyLTq5PCkAT1c5JuVCA X-Sonic-MF: X-Sonic-ID: 7276a6e5-a11b-4bd3-a65f-1ead9b05fb4a Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Wed, 20 Sep 2023 11:11:58 +0000 Original-Received: by hermes--production-sg3-55c667b499-tw4nx (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 3f1fbfd6c2b7923b87d22058df1e1283; Wed, 20 Sep 2023 11:11:51 +0000 (UTC) In-Reply-To: <87led1865h.fsf@localhost> (Ihor Radchenko's message of "Wed, 20 Sep 2023 10:56:26 +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.191.204; envelope-from=luangruo@yahoo.com; helo=sonic312-23.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:310815 Archived-At: 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. struct thread_state amounts to 12704 bytes, which does not come across as excessive in this day and age. Thread-local storage is then dynamically allocated as bindings materialize. > We discussed asynchronous access to buffers earlier and concluded that > modifying a buffer (and its buffer-local values) asynchronously is a > hard problem. In particular, handling gap asynchronously is simply not > possible. It might be more practical to allow simultaneous read-only > access to the same buffer, but interlock writes to buffer object > (including moving gap, changing buffer text, and changing buffer-local > values). The gap and point are not buffer local values. I'm referring to variables saved within local_var_alist, which must be modified to incorporate bindings for each thread. The problem lies in how to perform this efficiently.