![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, just a curiosity, how does PG manage PL/Perl? Is it loaded on the same process space of PG (a la mod_perl) or is it called via IPC? This question can be referred to other languages integrated in PG too. |
#3
| |||
| |||
|
|
They all work the same by design. As the documentation explains, you can even add your own languages. http://www.postgresql.org/docs/curre...ic/xplang.html has: The [language] handler itself is a C language function compiled into a shared object and loaded on demand, just like any other C function. They are shared objects that are loaded into the backend process. You can see them in your libdir as pl<name>.<shlib-extension |

#4
| |||
| |||
|
|
And here: http://www.postgresql.org/docs/curre....html#XFUNC-C- DYNLOAD it is stated that "Presently, unloads are disabled and will never occur, but this may change in the future", so is it correct to think that the libperl.so* is kept in memory after the first invocation? If yes, is it the perl stored procedure AST compiled on creation and then kept in memory after the first invocation? Another question, there are not references to language handlers here? |
#5
| |||
| |||
|
|
On Thu, 07 Jan 2010 15:54:40 +0100, Anselmo Canfora wrote: And here: http://www.postgresql.org/docs/curre....html#XFUNC-C- DYNLOAD it is stated that "Presently, unloads are disabled and will never occur, but this may change in the future", so is it correct to think that the libperl.so* is kept in memory after the first invocation? If yes, is it the perl stored procedure AST compiled on creation and then kept in memory after the first invocation? Another question, there are not references to language handlers here? 1) The library is opened using dlopen library function which is described here: http://linux.die.net/man/3/dlopen. This function is defined in /usr/lib/libdl.so. Essentially, you can read the name of the library that you want to open from a config or a database file and open it using dlopen. After that, all the symbols from the library are available to your program. Run time linker acts behind the scene here. 2) Plperl is probably a hacked version of perl.so, also known as "perl lib". That is an open source project which makes perl interpreter available for embedding. It must be hacked, in order to distinguish between "trusted" and "untrusted' operations. I haven't checked the source code, but that's what I expect it to be. 3) Perl code is never compiled. It's stored as a string. The entire string is passed to the embedded perl interpreter which executes it. Each server process (aka "handler process" maps the embedded perl interpreter in its address space, so there aren't any multi-threading problems. I don't use Winduhs so I don't know how are things there. Winduhs OS uses threads instead of processes which may or may not present some problems with multi-threading. |
#6
| |||
| |||
|
|
Perl interpreter does a sort of "compilation", see for example: http://www.perlfoundation.org/perl5/...gi?optree_guts I wish to know if the result of this compilation is kept in memory as it does for apache mod_perl |
#7
| |||
| |||
|
|
On Fri, 08 Jan 2010 10:44:36 +0100, Anselmo Canfora wrote: Perl interpreter does a sort of "compilation", see for example: http://www.perlfoundation.org/perl5/...gi?optree_guts I wish to know if the result of this compilation is kept in memory as it does for apache mod_perl Of course it is. It is not saved to the disk, if that's what you think. It's a perl optimization, done by the interpreter on the fly. |
do you know mod_perl?
#8
| |||
| |||
|
|
Il 08/01/2010 14.19, Mladen Gogala ha scritto: On Fri, 08 Jan 2010 10:44:36 +0100, Anselmo Canfora wrote: Perl interpreter does a sort of "compilation", see for example: http://www.perlfoundation.org/perl5/...gi?optree_guts I wish to know if the result of this compilation is kept in memory as it does for apache mod_perl Of course it is. It is not saved to the disk, if that's what you think. It's a perl optimization, done by the interpreter on the fly. mod_perl does not save on disk optrees do you knowmod_perl? |
#9
| |||
| |||
|
|
On Fri, 08 Jan 2010 18:01:26 +0100, Anselmo Canfora wrote: Il 08/01/2010 14.19, Mladen Gogala ha scritto: On Fri, 08 Jan 2010 10:44:36 +0100, Anselmo Canfora wrote: Perl interpreter does a sort of "compilation", see for example: http://www.perlfoundation.org/perl5/...gi?optree_guts I wish to know if the result of this compilation is kept in memory as it does for apache mod_perl Of course it is. It is not saved to the disk, if that's what you think. It's a perl optimization, done by the interpreter on the fly. mod_perl does not save on disk optrees do you knowmod_perl? No, I don't know mod_perl. I am an oracle DBA in the process of becoming acquainted with Postgres. I must confess to liking PostgreSQL better than I thought I would. |
#10
| ||||
| ||||
|
|
now I am wondering how PG manage the perl interpreter, I am not a C programmer, so I do not know a lot of things, however I would like to understand something about the performance of perl stored procedures in PG, for example if they are managed in a similar manner of apache/mod_perl, and if they are as fast as it in same tasks. |
|
It seems that the language handler loads the interpreter as shared library: |
|
And here: http://www.postgresql.org/docs/curre...FUNC-C-DYNLOAD it is stated that "Presently, unloads are disabled and will never occur, but this may change in the future", so is it correct to think that the libperl.so* is kept in memory after the first invocation? If yes, is it the perl stored procedure AST compiled on creation and then kept in memory after the first invocation? |
|
Another question, there are not references to language handlers here? root@pluto:/usr/lib/postgresql/8.3# ldd bin/post* | grep -i pl root@pluto:/usr/lib/postgresql/8.3# |
![]() |
| Thread Tools | |
| Display Modes | |
| |