Re: Optimize PL/Perl function argument passing [PATCH]
От | Alex Hunsaker |
---|---|
Тема | Re: Optimize PL/Perl function argument passing [PATCH] |
Дата | |
Msg-id | AANLkTimP+YFW3x5qsi2B7kre8h-gUb89er=GqyNyjRu7@mail.gmail.com обсуждение исходный текст |
Ответ на | Optimize PL/Perl function argument passing [PATCH] (Tim Bunce <Tim.Bunce@pobox.com>) |
Ответы |
Re: Optimize PL/Perl function argument passing [PATCH]
|
Список | pgsql-hackers |
On Tue, Dec 7, 2010 at 07:24, Tim Bunce <Tim.Bunce@pobox.com> wrote: > Changes: > > Sets the local $_TD via C instead of passing an extra argument. > So functions no longer start with "our $_TD; local $_TD = shift;" > > Pre-extend stack for trigger arguments for slight performance gain. > > Passes installcheck. Cool, surprisingly in the non trigger case I saw up to an 18% speedup. The trigger case remained about the same, I suppose im I/O bound. Find attached a v2 with some minor fixes, If it looks good to you Ill mark this as "Ready for Commit". Changes: - move up a declaration to make it c90 safe - avoid using tg_trigger before it was initialized - only extend the stack to the size we need (there was + 1 which unless I am missing something was needed because we used to push $_TD on the stack, but we dont any more) Benchmarks: --- create table t (a int); create or replace function func(int) returns int as $$ return $_[0]; $$ language plperl; create or replace function trig() returns trigger as $$ $_TD->{'new'}{'a'}++; return 'MODIFY'; $$ language plperl; -- pre patch, simple function call, 3 runs SELECT sum(func(1)) from generate_series(1, 10000000); Time: 30908.675 ms Time: 30916.995 ms Time: 31173.122 ms -- post patch SELECT sum(func(1)) from generate_series(1, 10000000); Time: 26460.987 ms Time: 26465.480 ms Time: 25958.016 ms -- pre patch, trigger insert into t (a) select generate_series(1, 1000000); Time: 18186.390 ms Time: 21291.721 ms Time: 20782.238 ms -- post insert into t (a) select generate_series(1, 1000000); Time: 19136.633 ms Time: 21140.095 ms Time: 22062.578 ms
Вложения
В списке pgsql-hackers по дате отправления: