From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Noah Misch <noah(at)leadboat(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: strncmp->memcmp when we know the shorter length |
Date: | 2010-12-21 23:24:25 |
Message-ID: | AANLkTi=0OK7WTuptSa=mvtt2iH3RjP6yd6R3JcQtMOyN@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Dec 20, 2010 at 1:10 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> When the caller knows the smaller string length, memcmp and strncmp are
> functionally equivalent. Since memcmp need not watch each byte for a NULL
> terminator, it often compares a CPU word at a time for better performance. The
> attached patch changes use of strncmp to memcmp where we have the length of the
> shorter string. I was most interested in the varlena.c instances, but I tried
> to find all applicable call sites. To benchmark it, I used the attached
> "bench-texteq.sql". This patch improved my 5-run average timing of the SELECT
> from 65.8s to 56.9s, a 13% improvement. I can't think of a case where the
> change should be pessimal.
This is a good idea. I will check this over and commit it.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-12-21 23:37:52 | Re: The cost of visibillity testing? (gin-search) |
Previous Message | Robert Haas | 2010-12-21 22:59:56 | Re: Comment typo in nodeWindowAgg.c |