Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Data-Rx CPAN distribution.

Report information
The Basics
Id: 76334
Status: resolved
Priority: 0/
Queue: Data-Rx

People
Owner: Nobody in particular
Requestors: lidl [...] pix.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.100110
Fixed in: (no value)



I am using Data::Rx in a web application, to check the validity of JSON encoded data that is submitted from Javascript running in the UI/frontend part of the application. This is all well and good. It works. The backend software is running under Apache 2.2.22 w/ mod_perl 2.0.5. It happens to run on a FreeBSD 8.2-RELEASE machine, but that isn't really part of the issue. Since my software runs under mod_perl, I like to pay the startup penalty for Perl once, by using 'require' in the startup.pl script that the master Apache process reads, before forking its children. That way, any perl module loaded there is shared across all the child apache processes. That works pretty well, but not for Data::Rx and its CoreType modules. They are loaded for each web request that does checking against my Data::Rx configuration. Which works out to be just about every request that isn't getting a static resource from the webserver. Using ktrace to show the system calls from the Apache process show me this: 43379 httpd NAMI "../Data/Rx/CoreType" 43379 httpd NAMI "/homes/staff/lidl/rmdb/websvc/Data/Rx/CoreType" 43379 httpd NAMI "/usr/local/lib/perl5/5.14.2/BSDPAN/Data/Rx/CoreType" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/mach/Data/Rx/CoreType" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType" 43379 httpd NAMI "/" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/def.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/fail.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/one.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/str.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/bool.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/any.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/nil.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/num.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/int.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/all.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/map.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/arr.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/rec.pm" 43379 httpd NAMI "/usr/local/lib/perl5/site_perl/5.14.2/Data/Rx/CoreType/seq.pm" I believe this behavior is due to Data::Rx's usage of Module::Pluggable:Object to load the different Core Rx types when a new Rx object is created. What I would like to have happen is the list of plugins to be evaluated once in some manner that is cached so it doesn't have to be evaluated each time a Rx object is created. Could this be accomplished by moving the evaluation of the plugins into an INIT block in the Data::Rx module? Or would it better to extend Module::Pluggable's logic when require=>1 to check and see if it already exists in the perl namespace? (Those modules are already loaded for me, because I have 'use Data::Rx::CoreType ();' in my startup.pl file for Apache. Thanks for you attention.
I think — and I say this tentatively — that this behavior is okay. What you should do is, prefork, build a Data::Rx object and then use it in all your forks. How's that sound? -- rjbs
I'm sticking with my earlier suggestion, although I have also just updated this code to avoid Module::Pluggable. It should be somewhat more efficient even with no changes. -- rjbs