http-walker: reduce O(n) ops with doubly-linked list
commit94e99012fc7a02c5504214294279fa49b4cc8ce3
authorEric Wong <e@80x24.org>
Mon, 11 Jul 2016 20:51:31 +0000 (11 20:51 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Jul 2016 22:17:42 +0000 (12 15:17 -0700)
tree6d60fd9cd99b5ea19a3fc9a32e48bcd74342fc42
parent17966c0a63d25b1cc2dd1e98d30873e643bd581f
http-walker: reduce O(n) ops with doubly-linked list

Using the a Linux-kernel-derived doubly-linked list
implementation from the Userspace RCU library allows us to
enqueue and delete items from the object request queue in
constant time.

This change reduces enqueue times in the prefetch() function
where object request queue could grow to several thousand
objects.

I left out the list_for_each_entry* family macros from list.h
which relied on the __typeof__ operator as we support platforms
without it.  Thus, list_entry (aka "container_of") needs to be
called explicitly inside macro-wrapped for loops.

The downside is this costs us an additional pointer per object
request, but this is offset by reduced overhead on queue
operations leading to improved performance and shorter queue
depths.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http-walker.c
list.h [new file with mode: 0644]