From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.tangents Subject: Re: Shrinking the C core Date: Thu, 14 Sep 2023 15:03:00 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34219"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-tangents@gnu.org To: Arthur Miller Original-X-From: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Thu Sep 14 15:11:42 2023 Return-path: Envelope-to: get-emacs-tangents@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 1qgm8D-0008lF-Rw for get-emacs-tangents@m.gmane-mx.org; Thu, 14 Sep 2023 15:11:41 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgm7u-0005Yh-5D; Thu, 14 Sep 2023 09:11:22 -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 1qglzw-0000xE-Py for emacs-tangents@gnu.org; Thu, 14 Sep 2023 09:03:09 -0400 Original-Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qglzu-0005fF-7l for emacs-tangents@gnu.org; Thu, 14 Sep 2023 09:03:08 -0400 Original-Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2bcde83ce9fso14383521fa.1 for ; Thu, 14 Sep 2023 06:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694696582; x=1695301382; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pyeb3y1Jlb7r96SuN9MIuTTIqzjjXCHMl/7h+iPxnxA=; b=MCJEaZx9WN9Y33AryFf4asvjW55Odk7dRcvtB0LNCgz608tVWr8Jwlu/hi3Br6Q7Qu D3VJzeNl9wLbfCF5Pt1QwXRLV+RyDtRKOiG3AU3f19OnG+mJZ69usPzk/okkR+nsrEww s3kTeHMop5LnACw4bCOgREO46PVMIAjVd4bkmrAohLCP8ip2lO8HEdJLmjY6Bqn1WXFC bBaJ0jwDHToH5+IGcLfu6AIphBXPAGHgcmwlQBlkldruKkgf3O4UtK/KElyCfbox2Tvp aJOmAwKA+faTC0yvH0FIgmVcxH4tJjQTzYHbPnXtMS/cqzC9B+u1Jt3MyKaYiMBO7c0/ G7MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694696582; x=1695301382; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pyeb3y1Jlb7r96SuN9MIuTTIqzjjXCHMl/7h+iPxnxA=; b=gD7+iM2hd+aQslBjMSk7n9wAkyYyAZw/eFCKVsqfDVBchBXelPAgfn756MP1vnsrqK hLZC0w6rbKFyZNFS7aoPsxkDAjloeX+rmgTv2R4AreFFXKlkM9az2Azz/dtAuhu12MEk adyyiyWCSUA7G9WQiBDkD/MO0bb/Yn201B5WxsbVDs93q4B3FHwc5ZiQMhmSqfaQuQa6 45lQ9JbBva+0yxQcaizqm/KNH4TTmIodWeZabVSPAw/UbAVuclZAImsh4E93Exnpb9If EG8m5UjyZLLXtKBANOmC9izq7EQes8KslZ2Zm1k8xqVrQ1OB/H18m1O8XSM/R1zcJ1OA EMsQ== X-Gm-Message-State: AOJu0YwaMxwDrYdxke0PxsrdpBcry6KGGKD7CkqY3gxCOlGjV6MtcZoC IaRS7QxfVJ2b5K783PqhAseqdY3ruYFucfuM X-Google-Smtp-Source: AGHT+IEi6lSVLxCv9LiAgy518GfVOHz49/PzEwUlO+AfYkQRYervKwWlDTklcZEk/lAJlRAbd2iVLw== X-Received: by 2002:a2e:95d2:0:b0:2bb:8bc1:db55 with SMTP id y18-20020a2e95d2000000b002bb8bc1db55mr4656224ljh.52.1694696581861; Thu, 14 Sep 2023 06:03:01 -0700 (PDT) Original-Received: from Pro.fritz.box (pd9e36797.dip0.t-ipconnect.de. [217.227.103.151]) by smtp.gmail.com with ESMTPSA id n25-20020a170906b31900b0099bcdfff7cbsm983984ejz.160.2023.09.14.06.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:03:01 -0700 (PDT) In-Reply-To: (Arthur Miller's message of "Thu, 14 Sep 2023 13:35:06 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=gerd.moellmann@gmail.com; helo=mail-lj1-x22b.google.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 14 Sep 2023 09:11:21 -0400 X-BeenThere: emacs-tangents@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Original-Sender: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.tangents:1085 Archived-At: Arthur Miller writes: > Gerd M=C3=B6llmann writes: >> I'm pretty sure that CL packages could be added to Emacs as it is, if >> some people would work on it. > > With "CL packages" you mean namespaces? There seem to be already a > branch that implements them, but I don't know how well it works, I > haven't tried it. Yup, that's mine, as a pastime :-). I have no plans with that. >> I'm also pretty sure that an incremental + generational GC could be >> added, at least as an option, because I would have almost done it some >> 20+ years ago. It was torpedoed by a patent issue concerning >> mostly-copying GC. The patent has since expired. A lot of work, of >> course. I think some people do or have done something in this area, but >> I don't know details. > > I am not very familiar wth GC:s implementation more then just some > bired-eye overview. SBCL recently started to move towards non-moving > GC to help with the speed, notably when calling native code which does > not like it's pointers moved underneath, but I am not expert on details > there, these what I have got from the paper: > > https://applied-langua.ge/~hayley/swcl-gc.pdf Interesting, thanks for the pointer! >> I'm not at all sure that non-cooperative multi-threading could be added >> to Emacs. But I'm also not sure how a CL core would help here. > > They are exposing posix threads and have done some work to make at least > parts of the Lisp system work well with threads, and it seems it is > working well for many applicaitons. > > http://www.lichteblau.com/sbcl/doc/manual/sbcl/Implementation-_0028Linux-= x86_0029.html#Implementation-_0028Linux-x86_0029 Yes, I remember to some degree. I think Daniel Barlow started adding thread support to SBCL at the time I constributed to CMUCL. ISTR some communiaction with him about the implemenattion of dynamic bindings in the presence of threads. > I think there is also a missconception in Emacs community that Emacs > loop itself has to be parallelized; I am not sure it is needed; Don't know what the "loop" refers to. I think the biggest problem with uncooperative multi-threading in Emacs is that Emacs has so much global state. As a consequence, it's unsafe to let two threads use anything in the C code in parallel. Maybe one could think of using some Python-like GIL, but that's kind of pointless, isn't it? > I think > for many people it would be enough to expose threading in form of "js > workers" or something like that. It can be done with processes of > course, but people seem to constantly scream about it in disucssions. Parallel worker threads have the same problem as above. And cooperative threads are there already, I think. > CL has things like lparallel and green threads built on top of > hardware threads, so even there is a bit of job already done. I am > sure all that can be done in Emacs too, but I think, both communities > would be more helped if we perhaps used sbcl and interested > individuals helped make sbcl runtime better intead of reduplication > the entire effort. Is this realistic? I mean how many people would be interested to do that? >> On the other hand, I'm pretty convinced that an Emacs core written in CL >> would have to be close to 100% compatible with the existing C core to be >> accepted by users. That includes a CL rewrite of the C Elisp, including >> byte code interpreter. > > Yes, my conclusion too. > >> accepted by users. That includes a CL rewrite of the C Elisp, including >> byte code interpreter. > > I am not sure how much of byte-interpretter is needed; I was thinking > how byte interpretter and native compiler fitt there. Oviously since > sbcl is a compiler, with don't need all that stuff, but I am not sure > how much of byte code intepretter is needed. I am sure we need to > understand all of the syntax, since byte code is a valid elisp, > according to the manual; so the reader have to be able to read the > syntax I guess, as printed representation, and has to print same stuff > back to feed into elisp functions. Not sure what you are saying. Something has to execute the bytecode, or not? >> That's a massive endeavor. My hair stands up when I remember the >> compatibility problems I faced with the new redisplay ages ago. >> Multiply that by some factor > 1. But maybe that's a burnt child >> dreading the fire :-). > > Yes, I know. I am fully aware that it is an impossibility for someone > alone, even for a very few. I don't think it is a burnt child, since > yes, the character renderer of Emacs has to be implemented if Emacs > applications will run unchanged. (I think you misunderstoof the phrase. I'm the burnt child...). > Hopefully it will be possible to implement Emacs stuff as a special kind > of terminal/character renderer over some sort of tree/graph structure. I > think CLOS and CL have much better tools to refactor that stuff than C, > but what do I know, I haven't tried that and I am not sure if I will > tbh. I am bolling with the ideas. I have seen what they do in other > similar CL software (Hemlock, McClIM, Lem), perhaps there is something > that can be reused there, but I don't know how much and what yet. And, > yes text properties are a special chapter on its own :). So, your plan would be to re-implement redisplay in CL. Good look with that. And a ton of other stuff, like the stuff Eli mentioned. And the result of the whole massive effort is then 100% compatible with current Emacs. That's what I call quatsch, sorry, but honestly. Work on Lem if you like CL that much :-)