From: Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Philip Kaludercic <philipk@posteo.net>
Cc: michael_heerdegen@web.de, 73431@debbugs.gnu.org,
nicolas@petton.fr, monnier@iro.umontreal.ca
Subject: bug#73431: Add `setf` support for `stream.el` in ELPA
Date: Thu, 03 Oct 2024 00:19:28 +0000 [thread overview]
Message-ID: <932d7782-5685-4a43-b34c-fc0bb3a958e4@protonmail.com> (raw)
In-Reply-To: <875xqa8fby.fsf@posteo.net>
Philip Kaludercic wrote:
> Okamsn <okamsn@protonmail.com> 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?
>
> It the overhead noticeable, or just measurable?
I’m not sure what counts as “noticeable”.
Using the benchmark macros given at
https://github.com/alphapapa/emacs-package-dev-handbook#benchmarking, I
tested getting the "first" and “rest” of streams, both as fresh streams
and as already evaluated streams.
These are the results I get for a stream from a list using the current
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
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
think this is from the extra work done by the accessors. For example,
the type-checking is run multiple times when accessing the “first” and
“rest” slots, because the accessors are also used in `stream--force`.
next prev parent reply other threads:[~2024-10-03 0:19 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-23 1:33 bug#73431: Add `setf` support for `stream.el` in ELPA Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-24 10:15 ` Philip Kaludercic
2024-09-24 13:56 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-25 0:17 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-25 2:56 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-25 20:22 ` Philip Kaludercic
2024-09-26 13:53 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-27 15:11 ` Philip Kaludercic
2024-09-27 16:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-27 20:08 ` Philip Kaludercic
2024-09-27 20:39 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-28 3:08 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-28 14:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-29 19:30 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-30 22:19 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-02 1:02 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-02 19:39 ` Philip Kaludercic
2024-10-03 0:19 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-10-04 8:55 ` Philip Kaludercic
2024-10-05 2:44 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-05 9:14 ` Philip Kaludercic
2024-10-06 1:36 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-05 13:32 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-06 0:37 ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-27 23:55 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=932d7782-5685-4a43-b34c-fc0bb3a958e4@protonmail.com \
--to=bug-gnu-emacs@gnu.org \
--cc=73431@debbugs.gnu.org \
--cc=michael_heerdegen@web.de \
--cc=monnier@iro.umontreal.ca \
--cc=nicolas@petton.fr \
--cc=okamsn@protonmail.com \
--cc=philipk@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).