Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize iterating over replacement policy purge lists #202

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/MemStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class MemStore: public Store::Controlled, public Ipc::StoreMapCleaner
void stat(StoreEntry &e) const override;
void reference(StoreEntry &e) override;
bool dereference(StoreEntry &e) override;
void lockInPolicy(StoreEntry &) override {}
void unlockInPolicy(StoreEntry &) override {}
void updateHeaders(StoreEntry *e) override;
void maintain() override;
bool anchorToCache(StoreEntry &) override;
Expand Down
12 changes: 8 additions & 4 deletions src/RemovalPolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ class RemovalPolicy

public:
const char *_type;
void *_data;
void *_dataIdle;
void *_dataBusy;
void (*Free) (RemovalPolicy * policy);
void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
void (*Locked) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
void (*Unlocked) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
Expand All @@ -58,7 +61,8 @@ class RemovalPolicyWalker

public:
RemovalPolicy *_policy;
void *_data;
void *_dataIdle;
void *_dataBusy;
const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
void (*Done) (RemovalPolicyWalker * walker);
};
Expand All @@ -69,8 +73,8 @@ class RemovalPurgeWalker

public:
RemovalPolicy *_policy;
void *_data;
int scanned, max_scan, locked;
void *_dataIdle;
int scanned, max_scan;
StoreEntry *(*Next) (RemovalPurgeWalker * walker);
void (*Done) (RemovalPurgeWalker * walker);
};
Expand Down
2 changes: 2 additions & 0 deletions src/Transients.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class Transients: public Store::Controlled, public Ipc::StoreMapCleaner
void stat(StoreEntry &e) const override;
void reference(StoreEntry &e) override;
bool dereference(StoreEntry &e) override;
void lockInPolicy(StoreEntry &) override {}
void unlockInPolicy(StoreEntry &) override {}
void evictCached(StoreEntry &) override;
void evictIfFound(const cache_key *) override;
void maintain() override;
Expand Down
18 changes: 18 additions & 0 deletions src/fs/rock/RockSwapDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,24 @@ Rock::SwapDir::dereference(StoreEntry &e)
return false;
}

void
Rock::SwapDir::lockInPolicy(StoreEntry &e)
{
debugs(47, 5, &e << ' ' << e.swap_dirn << ' ' << e.swap_filen);

if (repl && repl->Locked)
repl->Locked(repl, &e, &e.repl);
}

void
Rock::SwapDir::unlockInPolicy(StoreEntry & e)
{
debugs(47, 5, &e << ' ' << e.swap_dirn << ' ' << e.swap_filen);

if (repl && repl->Unlocked)
repl->Unlocked(repl, &e, &e.repl);
}

bool
Rock::SwapDir::unlinkdUseful() const
{
Expand Down
2 changes: 2 additions & 0 deletions src/fs/rock/RockSwapDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class SwapDir: public ::SwapDir, public IORequestor, public Ipc::StoreMapCleaner
void diskFull() override;
void reference(StoreEntry &e) override;
bool dereference(StoreEntry &e) override;
void lockInPolicy(StoreEntry &) override;
void unlockInPolicy(StoreEntry &) override;
void updateHeaders(StoreEntry *e) override;
bool unlinkdUseful() const override;
void statfs(StoreEntry &e) const override;
Expand Down
18 changes: 18 additions & 0 deletions src/fs/ufs/UFSSwapDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,24 @@ Fs::Ufs::UFSSwapDir::dereference(StoreEntry & e)
return true; // keep e in the global store_table
}

void
Fs::Ufs::UFSSwapDir::lockInPolicy(StoreEntry &e)
{
debugs(47, 3, &e << " " << e.swap_dirn << "/" << e.swap_filen);

if (repl && repl->Locked)
repl->Locked(repl, &e, &e.repl);
}

void
Fs::Ufs::UFSSwapDir::unlockInPolicy(StoreEntry &e)
{
debugs(47, 3, &e << " " << e.swap_dirn << "/" << e.swap_filen);

if (repl && repl->Unlocked)
repl->Unlocked(repl, &e, &e.repl);
}

StoreIOState::Pointer
Fs::Ufs::UFSSwapDir::createStoreIO(StoreEntry &e, StoreIOState::STIOCB * const aCallback, void * const callback_data)
{
Expand Down
2 changes: 2 additions & 0 deletions src/fs/ufs/UFSSwapDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class UFSSwapDir : public SwapDir
bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const override;
void reference(StoreEntry &) override;
bool dereference(StoreEntry &) override;
void lockInPolicy(StoreEntry &) override;
void unlockInPolicy(StoreEntry &) override;
StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STIOCB *, void *) override;
StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STIOCB *, void *) override;
void openLog() override;
Expand Down
Loading