Skip to content

Commit

Permalink
[CMSD] Implement new affinity selection algorithm for he redirector.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Jun 18, 2020
1 parent 0c7ba84 commit 829854c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
35 changes: 26 additions & 9 deletions src/XrdCms/XrdCmsCluster.cc
Expand Up @@ -1558,7 +1558,15 @@ int XrdCmsCluster::SelNode(XrdCmsSelect &Sel, SMask_t pmask, SMask_t amask)

// Indicate whether or not stable selection is required
//
selR.selPack = (Sel.Opts & XrdCmsSelect::Pack) != 0;
if (!(Sel.Opts & XrdCmsSelect::Pack)) selR.selPack = 0;
else {SMask_t sVec = pmask;
int count;
for (count = 0; sVec; count++) sVec &= (sVec - 1);
if (count) selR.selPack = (Sel.Path.Hash % count) + 1;
else selR.selPack = 0;
TRACE(Redirect, "affinity " <<(int)selR.selPack <<" of " <<count
<<" for " <<Sel.Path.Val);
}

// There is a difference bwteen needing space and needing r/w access. The former
// is needed when we will be writing data the latter for inode modifications.
Expand Down Expand Up @@ -1704,17 +1712,19 @@ XrdCmsNode *XrdCmsCluster::SelbyCost(SMask_t mask, XrdCmsSelector &selR)
if (np->isBad) {selR.xSusp = true; continue;}
if (selR.needSpace && np->isNoStage) {selR.xFull = true; continue;}
if (!sp) sp = np;
else{if (abs(sp->myCost - np->myCost) <= Config.P_fuzz)
else{Multi = true;
if (abs(sp->myCost - np->myCost) <= Config.P_fuzz)
{ if (selR.selPack)
{if (sp->Inst() > np->Inst()) sp=np;}
{if (--selR.selPack) sp=np;
else break;
}
else if (selR.needSpace)
{if (sp->RefW > (np->RefW+Config.DiskLinger))
sp=np;
}
else if (sp->RefR > np->RefR) sp=np;
}
else if (sp->myCost > np->myCost) sp=np;
Multi = true;
}
}

Expand Down Expand Up @@ -1750,23 +1760,27 @@ XrdCmsNode *XrdCmsCluster::SelbyLoad(SMask_t mask, XrdCmsSelector &selR)
|| (reqSS && np->isNoStage)))
{selR.xFull = true; continue;}
if (!sp) sp = np;
else{if (selR.needSpace)
else{Multi = true;
if (selR.needSpace)
{if (abs(sp->myMass - np->myMass) <= Config.P_fuzz)
{if (selR.selPack)
{if (sp->Inst() > np->Inst()) sp=np;}
{if (--selR.selPack) sp=np;
else break;
}
else
if (sp->RefW > (np->RefW+Config.DiskLinger)) sp=np;
}
else if (sp->myMass > np->myMass) sp=np;
} else {
if (abs(sp->myLoad - np->myLoad) <= Config.P_fuzz)
{if (selR.selPack)
{if (sp->Inst() > np->Inst()) sp=np;}
{if (--selR.selPack) sp=np;
else break;
}
else if (sp->RefR > np->RefR) sp=np;
}
else if (sp->myLoad > np->myLoad) sp=np;
}
Multi = true;
}
}

Expand Down Expand Up @@ -1802,7 +1816,10 @@ XrdCmsNode *XrdCmsCluster::SelbyRef(SMask_t mask, XrdCmsSelector &selR)
{selR.xFull = true; continue;}
if (!sp) sp = np;
else {Multi = true;
if (selR.selPack) {if (sp->Inst() > np->Inst())sp=np;}
if (selR.selPack)
{if (--selR.selPack) sp=np;
else break;
}
else if (selR.needSpace)
{if (sp->RefW > (np->RefW+Config.DiskLinger)) sp=np;}
else if (sp->RefR > np->RefR) sp=np;
Expand Down
2 changes: 1 addition & 1 deletion src/XrdCms/XrdCmsSelect.hh
Expand Up @@ -142,7 +142,7 @@ const char *reason;
short nPick;
char needNet;
char needSpace;
bool selPack;
char selPack;
bool xFull;
bool xNoNet;
bool xOff;
Expand Down

0 comments on commit 829854c

Please sign in to comment.