From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Zhu Zihao Newsgroups: gmane.emacs.devel Subject: Re: Slot accessing issues in EIEIO Date: Fri, 08 May 2020 11:12:36 +0800 Message-ID: <87wo5nf7bv.wl-all_but_last@163.com> References: <87a72lhf3b.wl-all_but_last@163.com> <878si5gmt7.wl-all_but_last@163.com> <877dxoh1m6.wl-all_but_last@163.com> <874kssgzrf.wl-all_but_last@163.com> <87k11nzvc2.fsf@bernoul.li> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="4952"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/27.0 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: Jonas Bernoulli , Zhu Zihao , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 08 05:13:39 2020 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 1jWtSF-0001C4-9S for ged-emacs-devel@m.gmane-mx.org; Fri, 08 May 2020 05:13:39 +0200 Original-Received: from localhost ([::1]:50112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWtSE-0003s2-CQ for ged-emacs-devel@m.gmane-mx.org; Thu, 07 May 2020 23:13:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWtRk-0003Gh-Lp for emacs-devel@gnu.org; Thu, 07 May 2020 23:13:08 -0400 Original-Received: from m12-15.163.com ([220.181.12.15]:60888) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jWtRf-0006er-J3 for emacs-devel@gnu.org; Thu, 07 May 2020 23:13:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:Message-ID:From:Subject:MIME-Version; bh=xJ5A2 dym3AP8rbne+RdxTxWcDZlD2/EBDHUgpAUUAks=; b=pjxuVlLp7Ow9+HOqWV2/Q cL0YnzW0zi+qVSwPiWgnhRmH7GoQXDhESC8cBH009J9DZvbszJFDhgQtgN0mC0+s zaIHD2MJslyVqckD8LnQi9vFEnao0nYL6suy3JTatMJrlxprsrTb1vEsQ/SMm8N3 xaPtdvBqq2M66/DdzIiWeA= Original-Received: from archlinux.163.com (unknown [113.102.100.98]) by smtp11 (Coremail) with SMTP id D8CowADndfoszrRe0WSuBg--.204S2; Fri, 08 May 2020 11:12:50 +0800 (CST) In-Reply-To: X-Face: :]]%@R1{oDt0%iKgI@Kga#OZ; ogt+%OOne&J4#E*O,TIlI)yEFw--I\:3s~EV97GI$1.1!}8inmF9UgtUBB@#8>'8NWNC8qg/v*OLfQB; Z:@G3HeNf3u& ,&HpBGv%?p{bzsl'|5T";1&X X-CM-TRANSID: D8CowADndfoszrRe0WSuBg--.204S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxWrWUCFyUCw1DWrW5tFy3CFg_yoW5ZrW8pF Wa9F90krWDAw4fCwsrJw4vvFySyw4Iv345GFn0q3y5Z3yYvw1DtF4vkrW5AFW7Aws7Xw1Y vFZIqrWDArn8AaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziuWlPUUUUU= X-Originating-IP: [113.102.100.98] X-CM-SenderInfo: pdoosuxxwbztlvw6il2tof0z/1tbiKRgdr1Xlv70KBwADs- Received-SPF: pass client-ip=220.181.12.15; envelope-from=all_but_last@163.com; helo=m12-15.163.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/07 23:12:56 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] 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_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.devel:249238 Archived-At: On Thu, 07 May 2020 22:52:26 +0800, Stefan Monnier wrote: > > > That sounds too complicated for my use-cases at least, > > Maybe it would require a fair bit pf change, but I don't see why it > would be significantly more complicated than what you currently do if > you were to start from scratch with such a design (to clarify: I'm > mostly interested in making sure that we have a good solution for > someone who wants to do that and is starting from scratch; having a good > solution for the existing closql.el is a somewhat secondary concern > since the advice mechanism does the job). > > You can structure the two-objects solution in various different ways: > e.g. you could keep your objects as they are, but create > a "proxy/firewall/interposer" object which contains only a single field > (which points to the real object). Then when accessing fields of this > object you can use the `slot-missing` generic function to do what your > current advice does, simply operating on the underlying real object. > > It should be possible to create a "generic interposer" solution like > that which can be used instead of your advice and that is not specific > to closql. > > > and I don't see what we gain by doing that except not having to advice > > `eieio-oref' and `eieio-oset', which by the way I don't think is all > > that horrible. > > Advising `eieio-oref` means slowing down every access to every slot of > every EIEIO object. That's the main problem for me. For some EIEIO > uses it's not a problem, but some EIEIO uses do care about the > performance of accesses to their slots. > > > I would have liked to write > > > > (cl-defmethod eieio-oset ((obj closql-object) slot value) > > ...) > > We could go there, but there's again an issue of performance: > > A) We could keep the code as is and just turn the `defun` into a `cl-defgeneric`, > in which case performance will be unaffected *until* someone comes > with his own `(cl-defmethod eieio-oref ...)` at which point again all > accesses to all slots of all EIEIO get impacted (if there's only one > (default) method, cl-generic optimizes away the method dispatch). > > The advantage compared to your advice is that subsequent > `(cl-defmethod eieio-oref ...)` don't impose additional slowdown > (unless they dispatch on another argument). > > B) We could try and work harder in the implementation of `eieio-oref` so > that the added cost discussed in (A) is always present but is made > useful (by reducing the rest of the cost). This would likely require > changes in cl-generic.el as well. > Currently eieio-oref basically does a gethash to find the slot's offset > and then an `aref` to get the slot's content. The method dispatch > adds another gethash, so we'd want this dispatch-time gethash to > replace the one that fetches the slot offset. > This would be great, but it requires a good bit more work. > > > -- Stefan It looks like a diffcult job. Maybe we can fix the eieio pattern of pcase. In this piece of code: (defclass test-class () ((slot))) (pcase (make-instance 'test-class) ((eieio slot) slot)) ;; => unbound An unbound marker will be returned on the fly without running slot-unbound in pcase with eieio pattern. Is it reasonable?