Re: [PHP] register_shutdown_function vs require (with pseudocode example)

2002-02-20 Thread Arpad Tamas

Hi,
No one has any idea on this topic? Or the question wasn't clear?
Thanks,
Arpi

 Hi again,
 I read my email back and found a little hard to understand :)), so
 I thought a code exmplae might help.
 It's just pseudo code for explaining how my cache works:

 //simplified main code
 if page is in cache {
   deliver the old one
   register_shutdown_function(regenerate)
 } else {
   regenerate()
   deliver
 }

 //registered shutdown function
 function regenerate() {
   if it's locked by another process {
   return
   } else {
   lock
   require_once(...);
   require_once(...);
   require_once(...);
   require_once(...);
   require_once(...);
   creation of many classes
   calling of many methods (the code is approx 1,6Megs)
   store
   unlock
   }
 }
 The main code delivers the page and reigsters the regenerate()
 function, and that's all what it should do. It takes about 0.04s,
 but this time unfortunately depends on what the regenerate()
 function does. If the page is locked then it finishes quickly (the
 overall time is 0.04s again), but when it can be regenerated it
 takes 0.25s. By the way the whole page regeneration takes 1.1s,
 that's why I really don't understand the 0.25s.
 I hope it was clearer with the two mails :)), and someone has an
 idea of whats happening here.

 Thanks for your help,
   Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] register_shutdown_function vs require

2002-02-19 Thread Arpad Tamas

Hi,
I'm trying to make some kind of caching system that first delivers 
the old page, and then regenerate the new one in the background. I 
achieved this with register_shutdown_function(). The registered 
function starts the real work, the normal php script just delivers 
the old page (of course if it were generated into the cahce before).
In the normal part of the program I required only the needed files to 
make the cache faster. It worked fine in older releases of php (maybe 
4.0.4, 4.0.5 I don't remember), but now 4.0.6 seems to include the 
files even if they aren't needed, and it slows down my cache. Without 
the requires (I commented out them) it delivers a page in avg 
0.04sec, but with the requires it's only 0.25 and it's too much for a 
cache.
The requires are called in the registered function, so they shouldn't 
affect the normal code. What is more interesting that it depends on 
the flow of the registered php code. For example if the page that 
should be regenarated is locked by another process and it can't be 
regenerated in the backround the cache delivers the page fast 
(0.04s), but if it's not locked (it can be regenerated) the cache 
becomes slow again (0.25s).
So what I don't understand: why the flow of the php code that is 
registered with register_shutdown_function affects the normal code's 
run? In theory it runs only when the normal code finished and the 
connection is released, and doesn't have anything to do with the 
normal script (that's why I started to use this method of caching).

(4.1.x is worse in this case because of bug #15209, it doesn't 
release the connection while the registered function is running)

Thanks for your help,
Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] register_shutdown_function vs require (with pseudocode example)

2002-02-19 Thread Tamas Arpad

Hi again, 
I read my email back and found a little hard to understand :)), so I 
thought a code exmplae might help.
It's just pseudo code for explaining how my cache works:

//simplified main code
if page is in cache {
deliver the old one
register_shutdown_function(regenerate)
} else {
regenerate()
deliver
}

//registered shutdown function
function regenerate() {
if it's locked by another process {
return
} else {
lock
require_once(...);
require_once(...);
require_once(...);
require_once(...);
require_once(...);
creation of many classes
calling of many methods (the code is approx 1,6Megs)
store
unlock
}
}
The main code delivers the page and reigsters the regenerate() 
function, and that's all what it should do. It takes about 0.04s, but 
this time unfortunately depends on what the regenerate() function 
does. If the page is locked then it finishes quickly (the overall 
time is 0.04s again), but when it can be regenerated it takes 0.25s. 
By the way the whole page regeneration takes 1.1s, that's why I 
really don't understand the 0.25s.
I hope it was clearer with the two mails :)), and someone has an 
idea of whats happening here.

Thanks for your help,
Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php