From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Efficient Gensym Hack Date: Sat, 10 Mar 2012 23:55:59 +0100 Message-ID: <87pqck83r4.fsf@gnu.org> References: <87mx7vx8zg.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1331420181 9088 80.91.229.3 (10 Mar 2012 22:56:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 10 Mar 2012 22:56:21 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Mar 10 23:56:21 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S6VD2-0007i2-Ga for guile-devel@m.gmane.org; Sat, 10 Mar 2012 23:56:20 +0100 Original-Received: from localhost ([::1]:41484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6VD1-0006Ml-Vu for guile-devel@m.gmane.org; Sat, 10 Mar 2012 17:56:19 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:40595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6VCz-0006Mb-8T for guile-devel@gnu.org; Sat, 10 Mar 2012 17:56:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S6VCx-0002IB-Du for guile-devel@gnu.org; Sat, 10 Mar 2012 17:56:16 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:58859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6VCx-0002Hz-6j for guile-devel@gnu.org; Sat, 10 Mar 2012 17:56:15 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1S6VCt-0007ef-4u for guile-devel@gnu.org; Sat, 10 Mar 2012 23:56:11 +0100 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 10 Mar 2012 23:56:11 +0100 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 10 Mar 2012 23:56:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.93 (gnu/linux) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 21 =?iso-8859-1?Q?Vent=F4se?= an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Cancel-Lock: sha1:WEiUk18W5pdQDiansIQMQxVkNr0= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14079 Archived-At: Hi Mark, Just a few questions. Mark H Weaver skribis: > Here's an implementation of the efficient gensym hack for stable-2.0. > It makes 'gensym' about 4.7 times faster on my Yeeloong. Gensyms are > not given names or even numbers until they are asked for their names or > hash values (for 'equal?' hash tables only). Ooooh, I only really understood when seeing this: + return scm_double_cell (scm_tc7_symbol | SCM_I_F_SYMBOL_LAZY_GENSYM, + SCM_UNPACK (prefix_stringbuf), (scm_t_bits) 0, + SCM_UNPACK (scm_cons (SCM_BOOL_F, SCM_EOL))); So you can actually ‘eq?’ or ‘hashq’ them regardless of whether they have a name, nice! :-) > The first patch adds an optimization for strings that is important for > gensyms. It avoids locking a mutex when setting the shared flag on a > stringbuf if the shared flag is already set. How much impact does this have? Thanks to futexes, mutex_lock should be fairly cheap when there’s no contention, no? Nice work! Thanks, Ludo’.