From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Emacs design and architecture. How about copy-on-write? Date: Wed, 20 Sep 2023 18:53:27 +0300 Message-ID: <83a5tgc03s.fsf@gnu.org> 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> <874jjprmq2.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14050"; mail-complaints-to="usenet@ciao.gmane.io" Cc: yantar92@posteo.net, emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 20 17:54:22 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 1qizWw-0003Ra-KH for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Sep 2023 17:54:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qizW1-0006n1-W0; Wed, 20 Sep 2023 11:53:26 -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 1qizW0-0006ml-1m for emacs-devel@gnu.org; Wed, 20 Sep 2023 11:53:24 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qizVy-0000Ek-Qd; Wed, 20 Sep 2023 11:53:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=skFle4g+5NmDq1GCDEfVPR3uryAVGSgInsbtmdvB4ns=; b=BX4ZXZ3Nz5oU 1sI18zyZWUn8qSjKt8hf9AGBoI/JG0Hy5etb+q3q9U1c+eeVvHFW6ISi0Htmfu3MgzrRgMDAkb/Sf 2j4Q4ILqnQ82BAQkKe4NgRu9N8GHKDl6dKdVTV5bUhIYaZxF5poxPFwWCh6wehYXakYiXbfTNDhtM eJY+X/8bnyqdBEe8AX2Yi9GlgRuzgXh39rBO+OuflTZUGKCuxTJtNo15OoamVVPZTX8VdLFqECEOf UrXWIdzMeqyQvwQoLBbM7EeNllHzqpZxgRz++vrgTCzJBqsM5zI0cTbjkZalMmUDP1Nt37JpgDW4f ceSvYtiPh2nWqmmxC1DhzA==; In-Reply-To: <874jjprmq2.fsf@yahoo.com> (message from Po Lu on Wed, 20 Sep 2023 21:35:49 +0800) 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:310842 Archived-At: > From: Po Lu > Cc: Emanuel Berg , emacs-devel@gnu.org > Date: Wed, 20 Sep 2023 21:35:49 +0800 > > 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. And don't forget that the globals defined in globals.h are just those we define in C. There are many globals defined in Lisp.