On Thu, Jan 19, 2012 at 3:54 AM, Josep Blanquer <blanq...@rightscale.com> wrote:
>
>
> On Wed, Jan 18, 2012 at 12:44 PM, Jonathan Ellis <jbel...@gmail.com> wrote:
>>
>> On Wed, Jan 18, 2012 at 12:31 PM, Josep Blanquer
>> <blanq...@rightscale.com> wrote:
>> > If I do a slice without a start (i.e., get me the first column)...it
>> > seems
>> > to fly. GET("K", :count => 1 )
>>
>> Yep, that's a totally different code path (SimpleSliceReader instead
>> of IndexedSliceReader) that we've done to optimize this common case.
>>
>
> Thanks Jonathan, yup, that makes sense. It was surprising to me that
> "avoiding the seek" was that much faster..but I guess if it's a completely
> different code path, there might be many other things in play.
>
>>
>> > The same starting at the last one.  GET("K",:start
>> > => '1c1b9b32-416d-11e1-83ff-dd2796c3abd7' , :count => 1 )
>> > -- 6.489683  -> Much faster than any other slice ... although not quite
>> > as
>> > fast as not using a start column
>>
>> That's not a special code path, but I'd guess that the last column is
>> more likely to be still in memory instead of on disk.
>>
>
> Well, no need to prolong the thread, but my tests are exclusively in
> Memtable reads (data has not flushed)...so there's no SSTable read involved
> here...which is exactly why is felt a bit funny to have that case be
> considerably faster. I just wanted to bring it up to you guys, in case you
> can think of some cause and/or potential issue.

That's not necessarily surprising. Any algorithm that search an
element in a sorted collection (which is exactly what we do here) is
likely to return some elements more quickly than others (which one
exactly depends on the algorithm detail). And since what you do is
basically micro-benchmarking that search algorithm, your results are
not necessarily surprising. For info, trunk internally uses
https://github.com/nbronson/snaptree/ as it's backing map for rows in
memtable. It's basically a balanced binary tree, so the search for the
start is basically a binary search.

--
Sylvain

Reply via email to