From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73431: Add `setf` support for `stream.el` in ELPA Date: Thu, 03 Oct 2024 00:19:28 +0000 Message-ID: <932d7782-5685-4a43-b34c-fc0bb3a958e4@protonmail.com> References: <827cc7fc-10be-4b93-bd67-f275193e5d84@protonmail.com> <87tte0q2qc.fsf@posteo.net> <068ecfc3-b452-49a8-89bb-f42012aea5d4@protonmail.com> <6caa1395-a3b2-4e70-b905-1cbfee0f92bd@protonmail.com> <87y138hjij.fsf@web.de> <875xqa8fby.fsf@posteo.net> Reply-To: Okamsn 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="33546"; mail-complaints-to="usenet@ciao.gmane.io" Cc: michael_heerdegen@web.de, 73431@debbugs.gnu.org, nicolas@petton.fr, monnier@iro.umontreal.ca To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 03 02:20:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sw9Zs-0008Vk-6p for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Oct 2024 02:20:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sw9Ze-0005Ag-0J; Wed, 02 Oct 2024 20:20:06 -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 1sw9Za-00059r-6Q for bug-gnu-emacs@gnu.org; Wed, 02 Oct 2024 20:20:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sw9ZZ-0000fc-Sq for bug-gnu-emacs@gnu.org; Wed, 02 Oct 2024 20:20:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:From:Date:To:Subject; bh=pDiL0mXBJTrcEoZlnJpeADt5++qOsPliyV1X229e9oU=; b=Lo9oqu9bxDK5vZa8NrtBNdTbOHD7NDLXoGHw1Dn1Uwk0E8jpDh54UBy0bVZdgof7gyMl+DhiTbpjbuj2HQoN+hROKpndAipTLL7jR8RoudqcIqq9ZrHXiWzUaWFE+mvmJxXWJcR7WNZ2pYUEvHmzpsXOIntKR54rG49CEUWhEgc3xX3q6msALGq3WWnBfI7eMqHv6+pMGE5MHqm4W+RNx8SdGuOvnCPVPuPE0Imf2vdyrn7nBglJYg81zqHPMcAj0ix2d5ZoExEc013NYcFwomXfQMkmjNW5sJ7T8rf2dX/cYIsWI+VqrdLG7bZkgTl6Jm4ZyROf9yIAcHBTqk+59A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sw9Za-00032W-LY for bug-gnu-emacs@gnu.org; Wed, 02 Oct 2024 20:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Okamsn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Oct 2024 00:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73431 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: Michael Heerdegen , "Okamsn via \"Bug reports for GNU Emacs, the Swiss army knife of text editors\"" , Nicolas Petton , Stefan Monnier , 73431@debbugs.gnu.org Original-Received: via spool by 73431-submit@debbugs.gnu.org id=B73431.172791478411642 (code B ref 73431); Thu, 03 Oct 2024 00:20:02 +0000 Original-Received: (at 73431) by debbugs.gnu.org; 3 Oct 2024 00:19:44 +0000 Original-Received: from localhost ([127.0.0.1]:59517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sw9ZH-00031i-JX for submit@debbugs.gnu.org; Wed, 02 Oct 2024 20:19:44 -0400 Original-Received: from mail-40133.protonmail.ch ([185.70.40.133]:46155) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sw9ZC-000318-Vw for 73431@debbugs.gnu.org; Wed, 02 Oct 2024 20:19:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1727914771; x=1728173971; bh=pDiL0mXBJTrcEoZlnJpeADt5++qOsPliyV1X229e9oU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=s9COR2s6By4sLG6BneRMZhRFNv1FmvZOPm37ortBppicoy12rV4inYFiwn9Sy1yZK WtnUdXQ204/ATdhqrLsuymD5D70dV4MDjxNIWlkhHsvzwtJCEZi4r4I6ORDWEePhhS vLbVI5GlSgqsZesfa8PkZCUZsxd98j4vn62ck5KE1uo2T33Lck8wXxyMTPvBKdY6XP HP6KiaJ67D015gkEYiiBRwkRvGt3KHfEAWWxqgA5uI/kkcwCQUA7/mO9u+30pT7uMe EoH8vPaR/PQNi/+YlK8nTJ9c7x4rrToJlOKMPMw+o4vgRO6CZwdslGIliYGnpxt6HQ PYGpmgr7KnUPw== In-Reply-To: <875xqa8fby.fsf@posteo.net> Feedback-ID: 25935600:user:proton X-Pm-Message-ID: 854050c669539668681ab7c1e4739af8f95b2c0a X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292874 Archived-At: Philip Kaludercic wrote: > Okamsn writes: >> Michael Heerdegen wrote: >>> Does changing the internal representation of streams have an effect >>> on the speed of the run code? >> >> I think that it does make it slower. I am trying to test it, and I think >> that making records is slower than making cons cells. I think that >> accessing the rest of the stream takes longer because the accessors >> created by `cl-defstruct` always perform type checking. It seems to take >> about twice as long when compared to naively using `car` and `cdr`. >> >> Do you think that it would be better to disable the type checking in the >> accessors? If so, would you please share how to do that? The manual >> talks about using `(optimize (safety 0))` in a declare form, but it also >> seems to say that it cannot be done locally for just the `cl-defstruct` >> usage. If it cannot be done, do think it makes sense to use >> `make-record` directly, along with custom function to replace the >> generated accessors? >=20 > It the overhead noticeable, or just measurable? I=E2=80=99m not sure what counts as =E2=80=9Cnoticeable=E2=80=9D. Using the benchmark macros given at=20 https://github.com/alphapapa/emacs-package-dev-handbook#benchmarking, I=20 tested getting the "first" and =E2=80=9Crest=E2=80=9D of streams, both as f= resh streams=20 and as already evaluated streams. These are the results I get for a stream from a list using the current=20 implementation: | Form | Tot. runtime | # of GCs | Tot. GC runtime | |--------------------------+--------------+----------+-----------------| | stream 10 evald: rest | 0.015259 | 0 | 0 | | stream 10: rest | 0.044525 | 0 | 0 | | stream 10 evald: first | 0.059650 | 0 | 0 | | stream 10: first | 0.074379 | 0 | 0 | | stream 100: rest | 0.132317 | 0 | 0 | | stream 100 evald: rest | 0.132821 | 0 | 0 | | stream 100 evald: first | 0.198041 | 0 | 0 | | stream 100: first | 0.205684 | 0 | 0 | | stream 1000 evald: rest | 1.249168 | 0 | 0 | | stream 1000: rest | 1.250730 | 0 | 0 | | stream 1000 evald: first | 1.835921 | 0 | 0 | | stream 1000: first | 1.857300 | 0 | 0 | These are the results I get for a stream from a list using the=20 struct-based implementation: | Form | Tot. runtime | # of GCs | Tot. GC runtime | |--------------------------+--------------+----------+-----------------| | stream 10 evald: rest | 0.036241 | 0 | 0 | | stream 10 evald: first | 0.048213 | 0 | 0 | | stream 10: rest | 0.048221 | 0 | 0 | | stream 10: first | 0.048285 | 0 | 0 | | stream 100 evald: rest | 0.312544 | 0 | 0 | | stream 100: rest | 0.321046 | 0 | 0 | | stream 100 evald: first | 0.439694 | 0 | 0 | | stream 100: first | 0.441674 | 0 | 0 | | stream 1000: rest | 3.032329 | 0 | 0 | | stream 1000 evald: rest | 3.142683 | 0 | 0 | | stream 1000: first | 4.113174 | 0 | 0 | | stream 1000 evald: first | 4.132561 | 0 | 0 | You can see that the struct-based run times are about twice as long. I=20 think this is from the extra work done by the accessors. For example,=20 the type-checking is run multiple times when accessing the =E2=80=9Cfirst= =E2=80=9D and=20 =E2=80=9Crest=E2=80=9D slots, because the accessors are also used in `strea= m--force`.