Skip to content

Commit

Permalink
Don't waste time inserting non-matches into the heap(s)
Browse files Browse the repository at this point in the history
Non-matches will have score 0.0, so we can skip those. In the edge-case
of the zero-width search string, all matches have score 1.0 (with
alpha-ordering taking care of tie-breaking). So, we can safely skip the
heap operations for items scoring 0.0.

Improves our baseline:

Summary of cpu time and (wall-clock time):
                    best      avg      sd     +/-   p   (best)    (avg)      (sd)     +/-   p
     pathological  1.12000  1.19600 0.12290 [+1.8%]   (1.11718) (1.20318) (0.12606) [+2.2%]
        command-t  1.45000  1.54400 0.11271 [+0.8%]   (1.44169) (1.54049) (0.11130) [+0.8%]
chromium (subset)  5.50000  5.58400 0.06406 [+0.4%]   (0.93548) (0.96777) (0.01784) [-3.2%]
 chromium (whole)  7.73000  7.92200 0.18498 [+0.5%]   (1.07602) (1.22772) (0.18294) [+6.0%]
       big (400k) 11.61000 11.88200 0.14851 [-1.4%]   (1.67856) (1.85601) (0.17784) [+0.3%]

To:

Summary of cpu time and (wall-clock time):
                    best    avg      sd      +/-     p    (best)    (avg)      (sd)      +/-     p
     pathological 1.07000 1.11600 0.02653  [-7.2%]      (1.07558) (1.11756) (0.02452)  [-7.7%]
        command-t 0.89000 0.97600 0.10111 [-58.2%] 0.05 (0.89123) (0.97778) (0.10287) [-57.5%] 0.05
chromium (subset) 3.68000 3.83400 0.08499 [-45.6%] 0.05 (0.67209) (0.72860) (0.04759) [-32.8%] 0.05
 chromium (whole) 5.99000 6.23200 0.13167 [-27.1%] 0.05 (0.82809) (0.86220) (0.02334) [-42.4%] 0.05
       big (400k) 8.87000 9.06600 0.10307 [-31.1%] 0.05 (1.27407) (1.31064) (0.03354) [-41.6%] 0.05

So pretty big drops across the board.
  • Loading branch information
wincent committed Apr 19, 2017
1 parent 44f44d2 commit 34b03d5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ruby/command-t/ext/command-t/matcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ void *match_thread(void *thread_args)
args->needle_bitmask,
&args->matches[i].bitmask
);
if (args->matches[i].score == 0.0) {
continue;
}
if (heap) {
if (heap->count == args->limit) {
score = ((match_t *)HEAP_PEEK(heap))->score;
Expand Down

0 comments on commit 34b03d5

Please sign in to comment.