From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Geoghegan <peter(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: [PATCH 04/16] Add embedded list interface (header only) |
Date: | 2012-06-22 14:48:23 |
Message-ID: | 201206221648.23789.andres@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Friday, June 22, 2012 04:41:20 PM Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > Oh, I and Peter weren't talking about the pg_list.h stuff, it was about
> > my 'embedded list' implementation which started this subthread. The
> > pg_list.h/list.c stuff isn't problematic as far as I have seen in
> > profiles; its checks are pretty simple so I do not find that surprising.
> > We might want to disable it by default anyway.
> >
> > In my code the list checking stuff iterates over the complete list after
> > modifications and checks that all prev/next pointers are correct so its
> > linear in itself...
>
> Well, so does list.c, so I'd expect the performance risks to be similar.
> Possibly you're testing on longer lists than are typical in the backend.
I don't think list.c does so:
static void
check_list_invariants(const List *list)
{
if (list == NIL)
return;
Assert(list->length > 0);
Assert(list->head != NULL);
Assert(list->tail != NULL);
Assert(list->type == T_List ||
list->type == T_IntList ||
list->type == T_OidList);
if (list->length == 1)
Assert(list->head == list->tail);
if (list->length == 2)
Assert(list->head->next == list->tail);
Assert(list->tail->next == NULL);
}
But yes, the lists I deal with are significantly longer, so replacing O(n) by
O(n^2) is rather painful there...
Andres
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2012-06-22 14:51:14 | Re: pl/perl and utf-8 in sql_ascii databases |
Previous Message | Andres Freund | 2012-06-22 14:45:10 | Re: [PATCH 01/16] Overhaul walsender wakeup handling |