Changeset 6190 for icGREP


Ignore:
Timestamp:
Nov 4, 2018, 10:15:47 PM (4 months ago)
Author:
cameron
Message:

Object cache policy refinement

Location:
icGREP/icgrep-devel/icgrep/toolchain
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/toolchain/object_cache.cpp

    r6184 r6190  
    141141                    sys::path::replace_extension(fileName, ".kernel");
    142142                    fs::last_write_time(fileName.c_str(), access_time);
     143                    mNewlyCached++;
    143144                    return true;
    144145                }
     
    200201        WriteBitcodeToFile(H.get(), kernelFile);
    201202        kernelFile.close();
     203        mCacheRetrievals++;
    202204    }
    203205}
     
    209211            // Simple clean-up policy: files that haven't been touched by the
    210212            // driver in MaxCacheEntryHours are deleted.
    211 
    212             // TODO: possibly incrementally manage by size and/or total file count.
    213             // TODO: possibly determine total filecount and set items per clean up step based on
    214             // filecount
     213            // Each cleanup step removes at monst mNewlyCached + 1 files
     214            // and examines at most mNewlyCached + mCacheRetrievals files.
    215215
    216216            const auto now = std::time(nullptr);
     217            unsigned removed = 0;
     218            unsigned examined = 0;
     219            unsigned removalLimit = mNewlyCached + 1;
     220            unsigned examineLimit = mNewlyCached + mCacheRetrievals;
    217221            while (LLVM_LIKELY(mCleanupIterator != fs::directory_iterator())) {
    218222                const auto i = mCleanupIterator;
     
    223227                    if (now > expiry) {
    224228                        fs::remove(e);
    225                         break;
     229                        removed++;
     230                        if (removed >= removalLimit) break;
    226231                    }
     232                    examined++;
     233                    if (examined > examineLimit) break;
     234                }
     235                unsigned skip = rand() % 23;
     236                while ((mCleanupIterator != fs::directory_iterator()) && (skip > 0)) {
     237                    ++mCleanupIterator;
     238                    skip--;
    227239                }
    228240            }
     
    245257
    246258ParabixObjectCache::ParabixObjectCache(const StringRef dir)
    247 : mCachePath(dir) {
     259: mCacheRetrievals(0)
     260, mNewlyCached(0)
     261, mCachePath(dir) {
    248262    fs::path p(mCachePath.str());
    249263    if (LLVM_LIKELY(!mCachePath.empty())) {
  • icGREP/icgrep-devel/icgrep/toolchain/object_cache.h

    r6184 r6190  
    5050private:
    5151    std::mutex mCleanupMutex;
     52    unsigned mCacheRetrievals;
     53    unsigned mNewlyCached;
    5254    boost::filesystem::directory_iterator mCleanupIterator;
    5355    ModuleCache mCachedObject;
    5456    const Path mCachePath;
     57   
    5558};
    5659
Note: See TracChangeset for help on using the changeset viewer.