GNU bug report logs - #28362
26.0.50; [PATCH] gensym in core elisp

Previous Next

Package: emacs;

Reported by: Mark Oteiza <mvoteiza <at> udel.edu>

Date: Tue, 5 Sep 2017 17:12:01 UTC

Severity: wishlist

Tags: patch

Found in version 26.0.50

Done: Mark Oteiza <mvoteiza <at> udel.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28362 in the body.
You can then email your comments to 28362 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#28362; Package emacs. (Tue, 05 Sep 2017 17:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mark Oteiza <mvoteiza <at> udel.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 05 Sep 2017 17:12:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50; [PATCH] gensym in core elisp
Date: Tue, 05 Sep 2017 13:11:23 -0400
[Message part 1 (text/plain, inline)]
Wishlist.

It would be nice to have gensym live in subr.el or C for the utility of
having uniquely named uninterned symbols.  It is helpful, for instance,
in the readability of macroexpansions of pcase and other macros that
generate many uninterned symbols of the same name.

As far as C vs Elisp--cl-gensym is about 10x slower than make-symbol,
but as far as macroexpansion goes, I get the impression gensym is not a
big contributing factor. Consider the following:

(defmacro case-lambda (&rest spec)
  "Return an arbitrary arity function."
  (declare (indent 0) (debug (&rest (pcase-QPAT body))))
  (let ((args (make-symbol "args")))
   `(lambda (&rest ,args)
      (pcase-exhaustive ,args ,@spec))))

(benchmark-run-compiled 1000
  (macroexpand-all
   '(case-lambda
      (`() t)
      (`(,x) (cons x 1))
      (`(,x ,y) (list x y 2))
      (`(,x ,y . ,z) (pcase-lambda (`(,cat ,dog))
                       (vector cat dog x y z 8)))))

The difference between the benchmark with make-symbol and make-symbol
fset to gensym is less than 1% (looking at profiler samples, interval
set to 1us).

I wrote a naïve gensym in C that is only about 1.5x to 2x faster than
cl-gensym (and incompatible because of the inaccessible counter). Patch
attached.

I also attached a patch putting gensym into subr.el.

I've tested both patches.

[gensym_alloc_c.patch (text/x-patch, attachment)]
[gensym.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28362; Package emacs. (Tue, 05 Sep 2017 17:28:01 GMT) Full text and rfc822 format available.

Message #8 received at 28362 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: 28362 <at> debbugs.gnu.org
Subject: Re: 26.0.50; [PATCH] gensym in core elisp
Date: Tue, 5 Sep 2017 13:27:33 -0400
[Message part 1 (text/plain, inline)]
On 05/09/17 at 01:11pm, Mark Oteiza wrote:
>I wrote a naïve gensym in C that is only about 1.5x to 2x faster than
>cl-gensym (and incompatible because of the inaccessible counter). Patch
>attached.

There was a bunch of other crap in that patch--clean one attached.

[gensym_alloc_c.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28362; Package emacs. (Mon, 11 Sep 2017 20:36:02 GMT) Full text and rfc822 format available.

Message #11 received at 28362 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: 28362 <at> debbugs.gnu.org
Subject: Re: 26.0.50; [PATCH] gensym in core elisp
Date: Mon, 11 Sep 2017 16:35:01 -0400
On 05/09/17 at 01:11pm, Mark Oteiza wrote:
> 
> Wishlist.
> 
> I attached a patch putting gensym into subr.el.

Any comments?  Moving gensym doesn't affect much, so I'll happily
commit, say, at the end of the week.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28362; Package emacs. (Tue, 12 Sep 2017 14:40:02 GMT) Full text and rfc822 format available.

Message #14 received at 28362 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: 28362 <at> debbugs.gnu.org
Subject: Re: bug#28362: 26.0.50; [PATCH] gensym in core elisp
Date: Tue, 12 Sep 2017 17:39:12 +0300
> Date: Mon, 11 Sep 2017 16:35:01 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> 
> On 05/09/17 at 01:11pm, Mark Oteiza wrote:
> > 
> > Wishlist.
> > 
> > I attached a patch putting gensym into subr.el.
> 
> Any comments?  Moving gensym doesn't affect much, so I'll happily
> commit, say, at the end of the week.

I see no reasons to have gensym in C, so let's go with the Lisp
version.

Please also add a NEWS entry about this.

Thanks.




Reply sent to Mark Oteiza <mvoteiza <at> udel.edu>:
You have taken responsibility. (Tue, 12 Sep 2017 15:15:02 GMT) Full text and rfc822 format available.

Notification sent to Mark Oteiza <mvoteiza <at> udel.edu>:
bug acknowledged by developer. (Tue, 12 Sep 2017 15:15:02 GMT) Full text and rfc822 format available.

Message #19 received at 28362-done <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 28362-done <at> debbugs.gnu.org
Subject: Re: bug#28362: 26.0.50; [PATCH] gensym in core elisp
Date: Tue, 12 Sep 2017 11:14:24 -0400
On 12/09/17 at 05:39pm, Eli Zaretskii wrote:
> > Date: Mon, 11 Sep 2017 16:35:01 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > 
> > On 05/09/17 at 01:11pm, Mark Oteiza wrote:
> > > 
> > > Wishlist.
> > > 
> > > I attached a patch putting gensym into subr.el.
> > 
> > Any comments?  Moving gensym doesn't affect much, so I'll happily
> > commit, say, at the end of the week.
> 
> I see no reasons to have gensym in C, so let's go with the Lisp
> version.
> 
> Please also add a NEWS entry about this.

Done, thank you.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 11 Oct 2017 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 314 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.