From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master f18af6c: Audit use of lsh and fix glitches Date: Sat, 25 Aug 2018 15:02:56 +0000 Message-ID: References: <20180821204437.16880.99611@vcs0.savannah.gnu.org> <20180821204439.62390209A6@vcs0.savannah.gnu.org> <53d0c06e-2383-955a-0a17-650fd842b483@cornell.edu> <4c677990-0d1c-acdb-596c-2bce02756a61@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1535209369 29572 195.159.176.226 (25 Aug 2018 15:02:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 25 Aug 2018 15:02:49 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: eggert@cs.ucla.edu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 25 17:02:44 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fta5K-0007ZA-Lf for ged-emacs-devel@m.gmane.org; Sat, 25 Aug 2018 17:02:42 +0200 Original-Received: from localhost ([::1]:46161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fta7P-0007wy-ST for ged-emacs-devel@m.gmane.org; Sat, 25 Aug 2018 11:04:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fta6C-0007da-Kp for emacs-devel@gnu.org; Sat, 25 Aug 2018 11:03:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fta6B-0006mU-MV for emacs-devel@gnu.org; Sat, 25 Aug 2018 11:03:36 -0400 Original-Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:36345) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fta6B-0006m3-D2 for emacs-devel@gnu.org; Sat, 25 Aug 2018 11:03:35 -0400 Original-Received: by mail-lf1-x133.google.com with SMTP id c21-v6so8758745lfh.3 for ; Sat, 25 Aug 2018 08:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mVpa4CwPNDwP36msl0c7ATRJ40kWO7nWr4JYcd06rpg=; b=jqzCelZe5kw6Oo350wH2DpYoHjCGITJpEPHGYt9jCEGr7T24b13Cj+jikFSOB7BzFM EgKdRG8lp6t5+J4Fb0w3m3y4yE9qiZnfHNZlHuiLjw1pqI2DAP2rIIZYMpA0QvSceTL5 wVBporOrEb2Z7nybTFCKVPc3QJ85hI99QvH3gpXx2KQ5XGn4bpagLWoYcaklv+AKowYl EZAlCEoIEmg0uw1X7kJo86/Ptj2ug5HCfpRsOJRF/6BudH+M7X2rRpNEnsuNlIz+uKjM WeuESiUaPjDV4O9J70UJKELp2zOxNa3oPLOrsiY9yCjvgTIetz34gehItJrhlmgaYCpy WsUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mVpa4CwPNDwP36msl0c7ATRJ40kWO7nWr4JYcd06rpg=; b=Jw2zdDfPNTPCwOf+CMTNnyY914l09SXkjpbCj6gkjYbZPRG0Z4x7xN/QP0ljpFkkM7 c6zza/bQbLAsnEc0pKqNBqeVpINlAPA5eRnWsuOveMa/ALLVVm2+cl9rP7ofw3Bew1RS nkAicikovyPfcWwnZxai1/YcHhLyz5EG9hThUxDtkESBCKgHUKUPSPFujaiZybPyNZyi VDSB/LsWATYFWnp5H65V69JDrOKkN8jd/th6pxEnJ+lAeqlOXrtHc/j2x/1Xd6b7VBsJ f1cRzY4bsydDfFrHcHm6ZVdp7Ddtsi3z/8t3SKFmZ/6aoBhVRJDKZGsUPoHnNAWUM2el tzKQ== X-Gm-Message-State: APzg51ANGAJ/KCfBW8K+mFi4aN9vGunHAjnP1A9eevsDuGF6qsbzB8ju lqznBojEICTMosTBwCDUWAAmK8ojRf0RLXfB3is= X-Google-Smtp-Source: ANB0VdbGD9dplZEuAN0DWdgZC13sGaw8dfji730RNV/l4r1GV89eAXOLPGG7tU8sJdtBgBGJdFL2IonyPvIT70bOztA= X-Received: by 2002:a19:ead4:: with SMTP id y81-v6mr3926155lfi.110.1535209414221; Sat, 25 Aug 2018 08:03:34 -0700 (PDT) In-Reply-To: <4c677990-0d1c-acdb-596c-2bce02756a61@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::133 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228899 Archived-At: On Fri, Aug 24, 2018 at 8:55 PM Paul Eggert wrote: > On my to-do list of things to try is to use 4 adjacent type codes for fixnums, > bignums, immediate floats and indirect floats, so that INTEGERP, BIGNUMP, > FIXNUMP, FLOATP, and NUMBERP can each be done by a single mask-and-compare. I'm already using a separate tag value for bignums, though it might help to use tag value 0 instead of a nonzero one (but then Qnil couldn't be all-zeroes in memory). I've discovered that the sequence gcc (trunk) emits for a mask-and-compare is: mov %rax, %rbx and $7, %rbx cmp $7, %rbx where I would use lea 1(%rax), %ebx test $7, %bl I can force the latter by testing ((char)((int)(XLI (x) + 8 - Lisp_String)) & 7) == 0 rather than the (equivalent, AFAICS) (XLI (x) & 7) == Lisp_String (sometimes gcc uses a longer sequence, though). At this point, I think gcc should be emitting the shorter two-insn sequence for both C expressions. With this "improvement", the code size difference is 13184 bytes. I'm unable to measure a performance difference, since it is lost in the noise. I've benchmarked the hash-cons approach, though the implementation I used was rather trivial, and simple bignum calculations appear to be about 20-50% slower. Again, I expect that number to increase once the extra copy in make_number is removed. (For floats, the slowdown is worse.) I still think there are problems with collisions, accidental or intentional, and with shrinking the hash table again after a calculation is finished. And I think those problems would be worse if strings ever become immutable but eq-when-equal.