[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH]: Add new bytecode op `switch' for implementing branch tables

From: Vibhav Pant
Subject: Re: [PATCH]: Add new bytecode op `switch' for implementing branch tables.
Date: Fri, 10 Feb 2017 09:42:11 +0530

The linear search code has been shifted to bytecode.c, since there are a couple of assumptions about the jump table that we can't make for a regular hash table, so regular gethash shouldn't be affected.

Vibhav Pant

On 10-Feb-2017 12:45 AM, "Clément Pit-Claudel" <address@hidden> wrote:
On 2017-02-08 08:38, Vibhav Pant wrote:
> On Tue, Feb 7, 2017 at 9:26 PM, Clément Pit-Claudel
> <address@hidden> wrote:
>> The timings fluctuate quite a bit, but the byte-switch branch seems to be about 5-7% slower.  Hopefully linear-scan hash tables will make things much faster :)
> The following patch makes hash_lookup use linear search when the number of keys
> in the hash table is <= 5 (chosen arbitrarily). switch bytecode run with this
> patch takes 15.96 seconds to run the benchmark, while the goto-if-nil code takes
> 17.15 seconds.

Here's another test that your patch seems to improve a bit:

(defvar ~/maps nil)

(dotimes (n 50)
  (let ((map (make-hash-table :test #'eq)))
    (dotimes (k 2)
      (puthash k n map))
    (push map ~/maps)))

(benchmark-run-compiled 1000000
  (dolist (mp ~/maps)
    (gethash 1 mp)))

Are linear scans used on all small hash tables, then?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]