all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gdobbins <gdobbins@protonmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Add new lisp function length= with bytecode support
Date: Tue, 07 Mar 2017 22:31:14 -0500	[thread overview]
Message-ID: <_Va7JCNtNKbVk4Ny13mMvZV7vv7_mFkIgMV2kPJGqlqrSV_XBS2tYZJWixctC4j4c4a4FpeTrpeSpqahEVbKHZyoGCgL4eaZZW1RtCHSnKU=@protonmail.com> (raw)
In-Reply-To: <jwv37eoh4rz.fsf-monnier+gmane.emacs.devel@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1849 bytes --]

> is there some benchmark or test case that drives your desire to add that bytecode?

I don't have a specific benchmark in mind, but I did some tests with `benchmark-run` before I submitted the first patch to see how much faster it was. I remember the break even point between length= in C without a bytecode and just using = and length in byte-compiled code being somewhat high, on the order of 100. It is also necessarily slower when none of the arguments are lists. So it is difficult to know whether converting such cases to length= with a compiler macro is worth while since I don't know the average length of lists which are being compared this way, but I suspect it isn't. Compounding the issue would be the increase in size of the .elc files.

> but without dedicating a bytecode to it

I didn't actually add a bytecode. Instead I re-purposed the = bytecode to handle both cases, since (= list1 list2) isn't acceptable anyway. Because of this you actually get a bytecode for length= for free. Done this way length= always beats = and length separately. Plus, the .elc files actually get smaller since two bytecodes (= and length) are replaced with one (= alone).

The only real downside to overloading this bytecode is a loss of type-checking to =. To compensate and aid in debugging any issues caused by this I made the compiler surround all the arguments to = with nonsense additions of 0 to regain the type-checking when `byte-compile-delete-errors` was nil. Consequently I changed that variables default value to t, otherwise you've lost more than you've gained by doing this.

So I suppose the first real issue is whether or not that change to `byte-compile-delete-errors` is acceptable, or using some alternative option which defaults to allowing = to be byte-compiled with this loss of type-checking is acceptable.


-- Graham Dobbins

[-- Attachment #2: Type: text/html, Size: 2141 bytes --]

  reply	other threads:[~2017-03-08  3:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 13:52 [PATCH] Add new lisp function length= with bytecode support Constantin Kulikov
2017-03-08  2:00 ` Gdobbins
2017-03-08  2:46   ` Stefan Monnier
2017-03-08  3:31     ` Gdobbins [this message]
2017-03-08  4:13       ` Stefan Monnier
2017-03-08  7:01         ` Gdobbins
2017-03-08 16:47           ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2017-02-26 22:04 Gdobbins
2017-02-27 16:14 ` Eli Zaretskii
2017-02-27 18:43   ` Gdobbins
2017-02-27 23:06     ` Paul Eggert
2017-02-28  0:35       ` Gdobbins
2017-02-28  9:24 ` Andreas Schwab
2017-03-06  1:59   ` Gdobbins
2017-03-06  6:13     ` Elias Mårtenson
2017-03-06  7:43       ` John Wiegley
2017-03-06 18:00         ` Richard Stallman
2017-03-06 20:36           ` Gdobbins
2017-03-06 20:45             ` Clément Pit-Claudel
2017-03-06 21:03               ` Gdobbins
2017-03-07  0:29                 ` Gdobbins
2017-03-10 10:20                   ` Ken Raeburn
2017-03-10 22:25                     ` Gdobbins
2017-03-13  2:51                       ` Gdobbins
2017-03-13  3:20                         ` Stefan Monnier
2017-03-14  6:06                           ` Gdobbins

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='_Va7JCNtNKbVk4Ny13mMvZV7vv7_mFkIgMV2kPJGqlqrSV_XBS2tYZJWixctC4j4c4a4FpeTrpeSpqahEVbKHZyoGCgL4eaZZW1RtCHSnKU=@protonmail.com' \
    --to=gdobbins@protonmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.