Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#29 Check for existing script

open
nobody
None
5
2003-09-01
2003-09-01
David
No

What about mmcache make use of file size and CRC32?
Example: Shared environement, 50 sites running the
same forum software, thus caching the exact same
scripts 50 times and waste memory

Would it be possible to check for existing cached script
with the same name, size (even CRC32) with different
path?

For dedicated server, this will be wasting cpu time, but
on shared hosting, this can helps
Maybe make it as a new optinal feature?
mmcache.check_duplicate = 1

Discussion

  • Dmitry Stogov
    Dmitry Stogov
    2003-09-01

    Logged In: YES
    user_id=124551

    I think the best way to solve this problem is to make symlink
    to the forum's directory from each site.
    Your idea about "mmcache.check_duplicate" can work, but it
    will take a lot of time to find duplicates.
    In any case I will not implement it before 2.4.0.

     
  • Xuefer
    Xuefer
    2003-09-30

    Logged In: YES
    user_id=185131

    what about caching crc with content?
    and hash crc, not only filename or inode
    (i doubt crc32 is enough, md5 should be fine)

    explain in php: (i didn't look into mmcache source)
    $md5 = md5($content);
    $md5_to_filename[$md5] = $filename;
    $filename_to_info[$filename] = array(
    'opcode' => compile($content), // NULL if we can use md5
    to find another cached file
    'md5' => $md5
    'mtime' => mtime($filename),
    );

    lookup:
    if (isset($filename_to_info[$filename])) {
    $info = &$filename_to_info[$filename];
    if (!$info['opcode']) {
    $f = &$md5_to_filename[$md5];
    if (isset($filename_to_info[$filename])) {
    $info = &$filename_to_info[$filename];
    if ($info['opcode']) {
    // found
    }
    else {
    // not found
    }
    }
    else {
    // not found
    }
    }
    else {
    $opcode = &$info['opcode'];
    // found
    }
    }

     
  • David
    David
    2003-09-30

    Logged In: YES
    user_id=851701

    Why won't CRC32 be enough?
    MD5 is overkill and is slower than a crc32