|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-11-17 07:48 UTC] xuefer at 21cn dot com
Description:
------------
1. use != instead of < for mtime compare
2. use atime if ctime > mtime
was done before but reverted, Smarty and other compile language need this, without it cause it hard to update Smarty Modules.(must restart apache)
comments from source:
/*
* I generally disagree with using the ctime here because you lose the
* ability to warm up new content by saving it to a temporary file, hitting
* it once to cache it and then renaming it into its permanent location.
*/
i doubt if "warm up" really help if the content is generate on the fly.
suppose there're many processes check for a file, realizing it not exists
if (file_need_update($file)) {
mylock(); <--- all other locked here
if (file_need_update($file)) { // recheck
generate($file); <--- only 1 get here
hit_the_file_by_include(); // <- to hit or not to hit, this is a question
rename();
}
myunlock();
}
include($file);
all other process is locked there! why do we need hit before rename?
if we don't hit, just rename, everything is same, all process locked on include($file), recompile and reoptimize
this is problem of apc, not phpscript.
apc should re-check the file and cache entry AFTER lock and BEFORE compile, this means only 1 process can compile a file(not on "each" file), this is much better than many process compile 1 file.
well, this should be another suggestion, not ctime problem
3. add filesize compare, not only inode/device
many ftp software, including scp, when uploading file in a heavy site, will cause apc cached half of a file.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
1. i'm lost i see only: if ((*slot)->key.mtime < key.mtime) { where is < 2 ? 2. by read the source, i know we don't lock until cache_insert, but how about adding 1 more lock? in my previous example, there's already 2 locks: 1 my*lock(), 2 include(), the one by apc lock(compile_lock) (different from cache lock) recheck(); allocate() complile() optimize() apc_cache_insert() (which also do lock/unlock) unlock(compile_lock) this, however, make only 1 file (and by 1 process) at a time. but: 1. it's good for "after restart", or a "cache clear". also simpler than user do themself 2. user can do nothing with static php file, apc should take care of warming up. 3. win32 have no inode, only filename(if we implement it), rename()+hit is useless to warm up although, win32 is only a devel-test for meoops, i didn't see the cvs before i post this bug i never meant to hurt "if(t - buf.st_mtime < 2)" 1. the request for != is about "if ((*slot)->key.mtime < key.mtime) {". my point is: some ftp may preserve mtime when uploading or downloading. well, maybe i (and other users) should configure the client not to do so. but i still don't know why we need < not != 2. lock is expensive, but not each request need compile_lock. only when we're going to compile. if (check_if_should_compile()) { lock(compile_lock); if (check_if_should_compile()) { // again ...... } unlock(compile_lock); } your slam_defense way looks good for me. it won't make too much child locking together even without a nonblocking-lock 3. i never meant to remove inode checking, and yes, use #ifdef (filename for win32) + (inode for most other system) is done by mmcache. apc can do it too.