Re: B-tree cache prefetches - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: B-tree cache prefetches
Date
Msg-id 1B4E24CF-9767-43CA-BE89-5CFACA5D7883@yandex-team.ru
Whole thread Raw
In response to Re: B-tree cache prefetches  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: B-tree cache prefetches  (Thomas Munro <thomas.munro@enterprisedb.com>)
List pgsql-hackers
Hello!

31 авг. 2018 г., в 2:40, Thomas Munro <thomas.munro@enterprisedb.com> написал(а):
A related topic is the cache-unfriendliness of traditional binary
searches of sorted data.  Check out "Array Layouts for
Comparison-Based Searching"[1] if you haven't already.  It says that
if your array fits in L2 cache, as our btree pages do, then binary
search still wins against Eytzinger et al, which I was a bit
disappointed 
I've re-read that paper. Their results are not about our case, here's a quote:
> For arrays small enough _to be kept_ in L2 cache, the branch-free binary search code listed in Listing 2 is the fastest algorithm

Surely, we cannot keep all pages in L2. Eytzinger layout could be realistic possibility, except one simple problem: I do not see how can we insert items into this layout.

Also, that research is quite distant from B-tree binsearch: thier data items are small and do not represent reference to actual data. Eytzinger exploits the fact that two posiible future keys share same cache line. But it is hard to provide, given we place items at quite random place of the page.

Best regards, Andrey Borodin.

pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: Experimenting with hash join prefetch
Next
From: Dmitry Dolgov
Date:
Subject: Re: Experimenting with hash join prefetch