Skip to content

Commit

Permalink
[SSI] Use exchange buffering to avoid using memcpy for improved pefor…
Browse files Browse the repository at this point in the history
…mance.
  • Loading branch information
abh3 committed Jun 13, 2020
1 parent 7671b0a commit 71e8216
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 38 deletions.
11 changes: 10 additions & 1 deletion src/XrdSsi/XrdSsiFile.cc
Expand Up @@ -38,7 +38,6 @@
#include "XrdOuc/XrdOucPList.hh"

#include "XrdSfs/XrdSfsAio.hh"
#include "XrdSfs/XrdSfsXio.hh"

#include "XrdSsi/XrdSsiFile.hh"
#include "XrdSsi/XrdSsiFileSess.hh"
Expand Down Expand Up @@ -369,6 +368,16 @@ int XrdSsiFile::SendData(XrdSfsDio *sfDio,
return fSessP->SendData(sfDio, offset, size);
}

/******************************************************************************/
/* s e t X i o */
/******************************************************************************/

void XrdSsiFile::setXio(XrdSfsXio *xP)
{
if (fSessP) fSessP->setXio(xP);
if (fsFile) fsFile->setXio(xP);
}

/******************************************************************************/
/* s t a t */
/******************************************************************************/
Expand Down
5 changes: 2 additions & 3 deletions src/XrdSsi/XrdSsiFile.hh
Expand Up @@ -81,7 +81,7 @@ public:
XrdSfsFileOffset offset,
XrdSfsXferSize size);

void setXio(XrdSfsXio *xP) {xioP = xP;}
void setXio(XrdSfsXio *xP);

int stat(struct stat *buf);

Expand All @@ -101,15 +101,14 @@ public:
//
XrdSsiFile(const char *user, int MonID)
: XrdSfsFile(myEInfo), fsFile(0), fSessP(0),
xioP(0), myEInfo(user, MonID) {}
myEInfo(user, MonID) {}

virtual ~XrdSsiFile();

private:

XrdSfsFile *fsFile;
XrdSsiFileSess *fSessP;
XrdSfsXio *xioP;
XrdOucErrInfo myEInfo;
};
#endif
9 changes: 4 additions & 5 deletions src/XrdSsi/XrdSsiFileReq.cc
Expand Up @@ -36,7 +36,6 @@
#include "XrdOuc/XrdOucERoute.hh"
#include "XrdOuc/XrdOucErrInfo.hh"
#include "XrdSfs/XrdSfsDio.hh"
#include "XrdSfs/XrdSfsXio.hh"
#include "XrdSsi/XrdSsiAlert.hh"
#include "XrdSsi/XrdSsiFileReq.hh"
#include "XrdSsi/XrdSsiFileResource.hh"
Expand Down Expand Up @@ -102,7 +101,7 @@ int XrdSsiFileReq::freeMax = 256;
/* A c t i v a t e */
/******************************************************************************/

void XrdSsiFileReq::Activate(XrdOucBuffer *oP, XrdSfsXioHandle *bR, int rSz)
void XrdSsiFileReq::Activate(XrdOucBuffer *oP, XrdSfsXioHandle bR, int rSz)
{
EPNAME("Activate");

Expand Down Expand Up @@ -536,7 +535,7 @@ char *XrdSsiFileReq::GetRequest(int &rLen)
//
rLen = reqSize;
if (oucBuff) return oucBuff->Data();
return sfsBref->Buffer();
return XrdSfsXio::Buffer(sfsBref);
}

/******************************************************************************/
Expand Down Expand Up @@ -795,7 +794,7 @@ void XrdSsiFileReq::Recycle()
// and sfs buffer, put it on the defered release queue.
//
if (oucBuff) {oucBuff->Recycle(); oucBuff = 0;}
else if (sfsBref) {sfsBref->Recycle(); sfsBref = 0;}
else if (sfsBref) {XrdSfsXio::Reclaim(sfsBref);}
reqSize = 0;

// Add to queue unless we have too many of these. If we add it back to the
Expand Down Expand Up @@ -829,7 +828,7 @@ void XrdSsiFileReq::RelRequestBuffer()
// Release buffers
//
if (oucBuff) {oucBuff->Recycle(); oucBuff = 0;}
else if (sfsBref) {sfsBref->Recycle(); sfsBref = 0;}
else if (sfsBref) {XrdSfsXio::Reclaim(sfsBref);}
reqSize = 0;
}

Expand Down
6 changes: 3 additions & 3 deletions src/XrdSsi/XrdSsiFileReq.hh
Expand Up @@ -35,13 +35,13 @@
#include "Xrd/XrdJob.hh"
#include "Xrd/XrdScheduler.hh"
#include "XrdSfs/XrdSfsInterface.hh"
#include "XrdSfs/XrdSfsXio.hh"
#include "XrdSsi/XrdSsiRequest.hh"
#include "XrdSsi/XrdSsiResponder.hh"
#include "XrdSsi/XrdSsiStream.hh"
#include "XrdSys/XrdSysPthread.hh"

class XrdOucErrInfo;
class XrdSfsXioHandle;
class XrdSsiAlert;
class XrdSsiFileResource;
class XrdSsiFileSess;
Expand All @@ -57,7 +57,7 @@ public:

// SsiRequest methods
//
void Activate(XrdOucBuffer *oP, XrdSfsXioHandle *bR, int rSz);
void Activate(XrdOucBuffer *oP, XrdSfsXioHandle bR, int rSz);

void Alert(XrdSsiRespInfoMsg &aMsg);

Expand Down Expand Up @@ -154,7 +154,7 @@ long long respOff;
union {long long fileSz;
int respLen;
};
XrdSfsXioHandle *sfsBref;
XrdSfsXioHandle sfsBref;
XrdOucBuffer *oucBuff;
XrdSsiStream::Buffer *strBuff;
reqState myState;
Expand Down
27 changes: 11 additions & 16 deletions src/XrdSsi/XrdSsiFileSess.cc
Expand Up @@ -46,7 +46,6 @@
#include "XrdSec/XrdSecEntity.hh"

#include "XrdSfs/XrdSfsAio.hh"
#include "XrdSfs/XrdSfsXio.hh"

#include "XrdSsi/XrdSsiEntity.hh"
#include "XrdSsi/XrdSsiFileSess.hh"
Expand Down Expand Up @@ -74,7 +73,9 @@ extern XrdSsiService *Service;
extern XrdSsiStats Stats;
extern XrdSysError Log;
extern int respWT;
};
extern int minRSZ;
extern int maxRSZ;
}

using namespace XrdSsi;

Expand Down Expand Up @@ -118,8 +119,6 @@ int XrdSsiFileSess::freeAbs = 200;

bool XrdSsiFileSess::authDNS = false;

int XrdSsiFileSess::maxRSZ = 0;

/******************************************************************************/
/* A l l o c */
/******************************************************************************/
Expand Down Expand Up @@ -361,7 +360,7 @@ void XrdSsiFileSess::Init(XrdOucErrInfo &einfo, const char *user, bool forReuse)

bool XrdSsiFileSess::NewRequest(unsigned int reqid,
XrdOucBuffer *oP,
XrdSfsXioHandle *bR,
XrdSfsXioHandle bR,
int rSz)
{
XrdSsiFileReq *reqP;
Expand Down Expand Up @@ -709,17 +708,13 @@ XrdSfsXferSize XrdSsiFileSess::write(XrdSfsFileOffset offset, // In
// the request object, and then activate it for processing.
//
if (reqSize == blen && xioP)
{XrdSfsXioHandle *bRef;
XrdSfsXio::XioStatus xStat = xioP->Swap(buff, bRef);
if (xStat != XrdSfsXio::allOK)
{char etxt[16];
sprintf(etxt, "%d", xStat);
Log.Emsg(epname, "Xio.Swap() return error status of ", etxt);
return XrdSsiUtils::Emsg(epname, ENOMEM, "write", gigID, *eInfo);
}
if (!NewRequest(reqID, 0, bRef, reqPass))
return XrdSsiUtils::Emsg(epname, ENOMEM, "write", gigID, *eInfo);
return blen;
{XrdSfsXioHandle bRef = xioP->Claim(buff, reqSize, minRSZ);
if (!bRef)
{if (errno) Log.Emsg(epname,"Xio.Claim() failed;",XrdSysE2T(errno));}
else {if (!NewRequest(reqID, 0, bRef, reqPass))
return XrdSsiUtils::Emsg(epname,ENOMEM,"write",gigID,*eInfo);
return blen;
}
}

// The full request is not present, so get a buffer to piece it together
Expand Down
8 changes: 2 additions & 6 deletions src/XrdSsi/XrdSsiFileSess.hh
Expand Up @@ -33,14 +33,14 @@
#include <sys/types.h>

#include "XrdSfs/XrdSfsInterface.hh"
#include "XrdSfs/XrdSfsXio.hh"
#include "XrdSsi/XrdSsiBVec.hh"
#include "XrdSsi/XrdSsiFileReq.hh"
#include "XrdSsi/XrdSsiFileResource.hh"
#include "XrdSsi/XrdSsiRRTable.hh"
#include "XrdSys/XrdSysPthread.hh"

class XrdOucEnv;
class XrdSfsXioHandle;
struct XrdSsiRespInfo;

class XrdSsiFileSess
Expand Down Expand Up @@ -81,8 +81,6 @@ XrdSsiFileResource &Resource() {return fileResource;}
XrdSfsXferSize size);

static void SetAuthDNS() {authDNS = true;}

static void SetMaxSz(int mSz) {maxRSZ = mSz;}

void setXio(XrdSfsXio *xP) {xioP = xP;}

Expand All @@ -102,7 +100,7 @@ private:

void Init(XrdOucErrInfo &einfo, const char *user, bool forReuse);
bool NewRequest(unsigned int reqid, XrdOucBuffer *oP,
XrdSfsXioHandle *bR, int rSz);
XrdSfsXioHandle bR, int rSz);
void Reset();
XrdSfsXferSize writeAdd(const char *buff, XrdSfsXferSize blen,
unsigned int rid);
Expand All @@ -113,8 +111,6 @@ static int freeNum;
static int freeNew;
static int freeMax;
static int freeAbs;

static int maxRSZ;
static bool authDNS;

XrdSsiFileResource fileResource;
Expand Down
13 changes: 13 additions & 0 deletions src/XrdSsi/XrdSsiSfs.cc
Expand Up @@ -70,6 +70,7 @@
#include "XrdSec/XrdSecEntity.hh"
#include "XrdSfs/XrdSfsAio.hh"
#include "XrdSfs/XrdSfsInterface.hh"
#include "XrdSfs/XrdSfsFlags.hh"

#include "XrdVersion.hh"

Expand Down Expand Up @@ -148,6 +149,7 @@ XrdSfsFileSystem *XrdSfsGetFileSystem2(XrdSfsFileSystem *nativeFS,

// All done, we can return the callout vector to these routines.
//
mySfs.setFeatures(nativeFS);
return &mySfs;
}
}
Expand Down Expand Up @@ -431,6 +433,17 @@ int XrdSsiSfs::rename(const char *old_name, // In
return SFS_ERROR;
}

/******************************************************************************/
/* Private: s e t F e a t u r e s */
/******************************************************************************/

void XrdSsiSfs::setFeatures(XrdSfsFileSystem *prevFS)
{
uint64_t fSet = (prevFS ? prevFS->Features() : 0);

FeatureSet = fSet | XrdSfs::hasSXIO;
}

/******************************************************************************/
/* Private: S p l i t */
/******************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions src/XrdSsi/XrdSsiSfs.hh
Expand Up @@ -132,6 +132,8 @@ const char *getVersion();

// Management functions
//
void setFeatures(XrdSfsFileSystem *prevFS);

static void setMax(int mVal) {freeMax = mVal;}

XrdSsiSfs() {}
Expand Down
6 changes: 3 additions & 3 deletions src/XrdSsi/XrdSsiSfsConfig.cc
Expand Up @@ -100,6 +100,9 @@ extern XrdSsiProvider *Provider;

int respWT = 0x7fffffff;

int minRSZ = 1024;
int maxRSZ = 2097152;

bool fsChk = false;

bool detReqOK = false;
Expand Down Expand Up @@ -129,7 +132,6 @@ XrdSsiSfsConfig::XrdSsiSfsConfig(bool iscms)
SvcLib = 0;
SvcParms = 0;
myRole = 0;
maxRSZ = 2097152;
respWT = 0x7fffffff;
isServer = true;
isCms = iscms;
Expand Down Expand Up @@ -336,13 +338,11 @@ int XrdSsiSfsConfig::ConfigCms(XrdOucEnv *envP)

int XrdSsiSfsConfig::ConfigObj()
{
static const int minRSZ = 8192;

// Allocate a buffer pool
//
if (maxRSZ < minRSZ) maxRSZ = minRSZ;
BuffPool = new XrdOucBuffPool(minRSZ, maxRSZ);
XrdSsiFileSess::SetMaxSz(maxRSZ);
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion src/XrdSsi/XrdSsiSfsConfig.hh
Expand Up @@ -65,7 +65,6 @@ char *CmsLib; // ->Cms Library
char *CmsParms; // ->Cms Library Parameters
char *SvcLib; // ->Svc Library
char *SvcParms; // ->Svc Library Parameters
int maxRSZ; // Maximum request size
int roleID;

int ConfigCms(XrdOucEnv *envP);
Expand Down

0 comments on commit 71e8216

Please sign in to comment.