You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jeff Ambrosino <jb...@gmail.com> on 2005/10/24 20:27:52 UTC

[mp2] pnotes-like facility for $c connection object?

I've made great use of $r->pnotes, and now finding myself in need of a
similar way to stash objects within the connection object.  While
there are regular 'notes' offered by the connection ($c->notes),
unfortunately there is no 'pnotes'.  Any suggestions for a workaround?

The requirement is as follows: to store a Time::HiRes object in a
pnote for establishing HTTP cycle benchmarks.  Using Time::HiRes, I've
already done this successfully to benchmark the "round trip"
associated with my mod_proxy's request to the web server.  But, since
I also run mod_ssl, my requirement now is to be able to benchmark the
SSL handshake phase on the proxy itself by measuring elapsed time
(tv_interval) between ProcessConnectionHandler and
PostReadRequestHandler.  As you can see, it's all very simple, except
where to store the Time::HiRes object from the
ProcessConnectionHandler?  I'm hoping there's a decent way to do this
without resorting to $c->notes and serialize/freeze/thaw...

Thank you in advance for any ideas/suggestions.

cheers
JB

p.s. off-topic inquiry:  does anyone happen to know (roughly) what the
division of computational labor is between client and server during an
SSL handshake?  For example (contrived numbers): 40% of the
computational work is done by the client, 60% by the server...  any
ideas?

Re: [mp2] pnotes-like facility for $c connection object?

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Geoffrey Young wrote:
> try this patch, which makes the following possible
> but more vigorous testing always appreciated.
+1

The new tests pass on all of the following combinations for FreeBSD 7.0-current:
(perlver-httpdver-mpm)

         5.8.7_2.0.49_prefork
         5.8.7_2.0.50_prefork
         5.8.7_2.0.51_prefork
         5.8.7_2.0.52_prefork
         5.8.7_2.0.53_prefork
         5.8.7_2.0.54_prefork
         5.8.7_2.0.55_prefork
         5.8.7_2.1.8-beta_prefork
         5.8.7_svn_prefork

         5.8.7_2.0.51_prefork-threaded
         5.8.7_2.0.52_prefork-threaded
         5.8.7_2.0.53_prefork-threaded
         5.8.7_2.0.54_prefork-threaded
         5.8.7_2.0.55_prefork-threaded
         5.8.7_2.1.8-beta_prefork-threaded
         5.8.7_svn_prefork-threaded

         5.8.7-ithread_2.0.51_prefork-threaded
         5.8.7-ithread_2.0.52_prefork-threaded
         5.8.7-ithread_2.0.53_prefork-threaded
         5.8.7-ithread_2.0.54_prefork-threaded
         5.8.7-ithread_2.0.55_prefork-threaded
         5.8.7-ithread_2.1.8-beta_prefork-threaded
         5.8.7-ithread_svn_prefork-threaded

         5.8.7-ithread_2.0.52_worker-threaded
         5.8.7-ithread_2.0.53_worker-threaded
         5.8.7-ithread_2.0.54_worker-threaded
         5.8.7-ithread_2.0.55_worker-threaded
         5.8.7-ithread_2.1.8-beta_worker-threaded
         5.8.7-ithread_svn_worker-threaded



-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

Re: [mp2] pnotes-like facility for $c connection object?

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Geoffrey Young wrote:
> blarg, that patch was incomplete.  here's the right one (I hope).
I'm apparently missing something obvious here.... anyone want to tell me what it is

cd modperl/trunk
patch < ~/dev/patches/conn_pnotes.diff
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: src/modules/perl/modperl_config.c

|===================================================================

|--- src/modules/perl/modperl_config.c	(revision 328346)

|+++ src/modules/perl/modperl_config.c	(working copy)

--------------------------
Patching file src/modules/perl/modperl_config.c using Plan A...
Hunk #1 failed at 147.
1 out of 1 hunks failed--saving rejects to src/modules/perl/modperl_config.c.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: src/modules/perl/modperl_types.h

|===================================================================

|--- src/modules/perl/modperl_types.h	(revision 328346)

|+++ src/modules/perl/modperl_types.h	(working copy)

--------------------------
Patching file src/modules/perl/modperl_types.h using Plan A...
Hunk #1 failed at 259.
1 out of 1 hunks failed--saving rejects to src/modules/perl/modperl_types.h.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: src/modules/perl/modperl_config.h

|===================================================================

|--- src/modules/perl/modperl_config.h	(revision 328346)

|+++ src/modules/perl/modperl_config.h	(working copy)

--------------------------
Patching file src/modules/perl/modperl_config.h using Plan A...
Hunk #1 failed at 26.
Hunk #2 failed at 80.
2 out of 2 hunks failed--saving rejects to src/modules/perl/modperl_config.h.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: xs/maps/modperl_functions.map

|===================================================================

|--- xs/maps/modperl_functions.map	(revision 328346)

|+++ xs/maps/modperl_functions.map	(working copy)

--------------------------
Patching file xs/maps/modperl_functions.map using Plan A...
Hunk #1 failed at 91.
1 out of 1 hunks failed--saving rejects to xs/maps/modperl_functions.map.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: xs/tables/current/ModPerl/FunctionTable.pm

|===================================================================

|--- xs/tables/current/ModPerl/FunctionTable.pm	(revision 328346)

|+++ xs/tables/current/ModPerl/FunctionTable.pm	(working copy)

--------------------------
Patching file xs/tables/current/ModPerl/FunctionTable.pm using Plan A...
Hunk #1 failed at 1481.
Hunk #2 failed at 6192.
2 out of 2 hunks failed--saving rejects to 
xs/tables/current/ModPerl/FunctionTable.pm.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: t/response/TestModperl/pnotes.pm

|===================================================================

|--- t/response/TestModperl/pnotes.pm	(revision 328346)

|+++ t/response/TestModperl/pnotes.pm	(working copy)

--------------------------
Patching file t/response/TestModperl/pnotes.pm using Plan A...
Hunk #1 failed at 4.
Hunk #2 failed at 12.
2 out of 2 hunks failed--saving rejects to t/response/TestModperl/pnotes.pm.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|

|--- /dev/null	2005-10-24 04:58:49.190343808 -0700

|+++ t/modperl/pnotes.t	2005-10-25 10:56:46.000000000 -0700

--------------------------
(Creating file t/modperl/pnotes.t...)
Patching file t/modperl/pnotes.t using Plan A...
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|

|--- /dev/null	2005-10-24 04:58:49.190343808 -0700

|+++ xs/Apache2/ConnectionUtil/Apache2__ConnectionUtil.h	2005-10-25 
10:33:27.000000000 -0700

--------------------------
(Creating file Apache2__ConnectionUtil.h...)
Patching file Apache2__ConnectionUtil.h using Plan A...
Hunk #1 succeeded at 1.
done


-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

Re: [mp2] pnotes-like facility for $c connection object?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Torsten Foertsch wrote:
> On Tuesday 25 October 2005 20:18, Geoffrey Young wrote:
> 
>> typedef struct {
>>     MpAV *handlers_connection[MP_HANDLER_NUM_CONNECTION];
>>+    HV *pnotes;
>> } modperl_config_con_t;
> 
> 
> Just a thought, will that work with ITHREADS?

hmm...

well, I don't see how it's any different than the same declaration in
modperl_config_req_t, and my worker tests seemed to pass ok the dozen or so
times I ran them...

but I hate threads.  test patches that exercise pnotes() (both $c and $r)
across interpreters most welcome...

--Geoff


Re: [mp2] pnotes-like facility for $c connection object?

Posted by Torsten Foertsch <to...@gmx.net>.
On Tuesday 25 October 2005 20:18, Geoffrey Young wrote:
>  typedef struct {
>      MpAV *handlers_connection[MP_HANDLER_NUM_CONNECTION];
> +    HV *pnotes;
>  } modperl_config_con_t;

Just a thought, will that work with ITHREADS?

Torsten

Re: [mp2] pnotes-like facility for $c connection object?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Philip M. Gollucci wrote:
> Geoffrey Young wrote:
> 
>> blarg, that patch was incomplete.  here's the right one (I hope).
> 
> 
> D'oh... If anyone tries to apply this, you have to create the directory
> xs/Apache2/ConnectionUtil manually *before* applying otherwise 'patch'
> pukes on itself.

blarg, that shouldn't happen...

> 
> That only took an hour.

very, very sorry about that.

--Geoff

Re: [mp2] pnotes-like facility for $c connection object?

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Geoffrey Young wrote:
> blarg, that patch was incomplete.  here's the right one (I hope).

D'oh... If anyone tries to apply this, you have to create the directory
xs/Apache2/ConnectionUtil manually *before* applying otherwise 'patch' pukes on 
itself.

That only took an hour.



-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

Re: [mp2] pnotes-like facility for $c connection object?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Geoffrey Young wrote:
> 
> Jeff Ambrosino wrote:
> 
>>I've made great use of $r->pnotes, and now finding myself in need of a
>>similar way to stash objects within the connection object.  While
>>there are regular 'notes' offered by the connection ($c->notes),
>>unfortunately there is no 'pnotes'.  Any suggestions for a workaround?
> 
> 
> try this patch

blarg, that patch was incomplete.  here's the right one (I hope).

sorry.

--Geoff

Re: [mp2] pnotes-like facility for $c connection object?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Jeff Ambrosino wrote:
> I've made great use of $r->pnotes, and now finding myself in need of a
> similar way to stash objects within the connection object.  While
> there are regular 'notes' offered by the connection ($c->notes),
> unfortunately there is no 'pnotes'.  Any suggestions for a workaround?

try this patch, which makes the following possible

  use Apache2::ConnectionUtil ();
  ...
  my $note = $c->pnotes('foo');

you'll need to 'make realclean' before applying the patch, then completely
rebuild again in order for the new method to be picked up and the tests to
be present.

the tests are in the (now expanded) t/modperl/pnotes.t test.  I've tested it
against 2.0 (worker) and 2.1 (prefork) and it seems to work and not
coredump, but more vigorous testing always appreciated.

--Geoff

Re: [mp2] pnotes-like facility for $c connection object?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Jeff Ambrosino wrote:
> I've made great use of $r->pnotes, and now finding myself in need of a
> similar way to stash objects within the connection object.  While
> there are regular 'notes' offered by the connection ($c->notes),
> unfortunately there is no 'pnotes'.  Any suggestions for a workaround?

hmm, that's a good idea.  it will require a patch of some difficult, though.
 if I have time this week I'll give it a whirl...

--Geoff