opt performance by removing the mmap during read header file
This commit is contained in:
parent
a935e645f1
commit
24d93f5729
|
@ -431,7 +431,7 @@ char *vnodeGetHeaderFileData(SQueryRuntimeEnv *pRuntimeEnv, int32_t vnodeId, int
|
||||||
|
|
||||||
if (pVnodeFileInfo->current != fileIndex || pVnodeFileInfo->pHeaderFileData == NULL) {
|
if (pVnodeFileInfo->current != fileIndex || pVnodeFileInfo->pHeaderFileData == NULL) {
|
||||||
if (pVnodeFileInfo->current >= 0) {
|
if (pVnodeFileInfo->current >= 0) {
|
||||||
assert(pVnodeFileInfo->pHeaderFileData != NULL);
|
// assert(pVnodeFileInfo->pHeaderFileData != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do close the current memory mapped header file and corresponding fd
|
// do close the current memory mapped header file and corresponding fd
|
||||||
|
@ -488,15 +488,16 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
read(fd, data, tmsize + TSDB_FILE_HEADER_LEN);
|
read(fd, data, tmsize + TSDB_FILE_HEADER_LEN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int64_t offset = TSDB_FILE_HEADER_LEN + sizeof(SCompHeader) * pMeterObj->sid;
|
||||||
|
|
||||||
|
#if 0
|
||||||
// check the offset value integrity
|
// check the offset value integrity
|
||||||
if (validateHeaderOffsetSegment(pQInfo, pRuntimeEnv->vnodeFileInfo.headerFilePath, pMeterObj->vnode, data,
|
if (validateHeaderOffsetSegment(pQInfo, pRuntimeEnv->vnodeFileInfo.headerFilePath, pMeterObj->vnode, data,
|
||||||
getCompHeaderSegSize(pCfg)) < 0) {
|
getCompHeaderSegSize(pCfg)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t offset = TSDB_FILE_HEADER_LEN + sizeof(SCompHeader) * pMeterObj->sid;
|
|
||||||
SCompHeader *compHeader = (SCompHeader *)(data + offset);
|
SCompHeader *compHeader = (SCompHeader *)(data + offset);
|
||||||
|
|
||||||
// no data in this file for specified meter, abort
|
// no data in this file for specified meter, abort
|
||||||
if (compHeader->compInfoOffset == 0) {
|
if (compHeader->compInfoOffset == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -507,14 +508,29 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
getCompHeaderStartPosition(pCfg)) < 0) {
|
getCompHeaderStartPosition(pCfg)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
char* buf = calloc(1, getCompHeaderSegSize(pCfg));
|
||||||
|
SQueryFilesInfo *pVnodeFileInfo = &pRuntimeEnv->vnodeFileInfo;
|
||||||
|
|
||||||
#if 1
|
lseek(pVnodeFileInfo->headerFd, TSDB_FILE_HEADER_LEN, SEEK_SET);
|
||||||
|
read(pVnodeFileInfo->headerFd, buf, getCompHeaderSegSize(pCfg));
|
||||||
|
|
||||||
|
// check the offset value integrity
|
||||||
|
if (validateHeaderOffsetSegment(pQInfo, pRuntimeEnv->vnodeFileInfo.headerFilePath, pMeterObj->vnode, buf - TSDB_FILE_HEADER_LEN,
|
||||||
|
getCompHeaderSegSize(pCfg)) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
SCompInfo *compInfo = (SCompInfo *)(data + compHeader->compInfoOffset);
|
SCompInfo *compInfo = (SCompInfo *)(data + compHeader->compInfoOffset);
|
||||||
#else
|
#else
|
||||||
lseek(fd, compHeader->compInfoOffset, SEEK_SET);
|
SCompHeader *compHeader = (SCompHeader *)(buf + sizeof(SCompHeader) * pMeterObj->sid);
|
||||||
|
lseek(pVnodeFileInfo->headerFd, compHeader->compInfoOffset, SEEK_SET);
|
||||||
|
|
||||||
SCompInfo CompInfo = {0};
|
SCompInfo CompInfo = {0};
|
||||||
SCompInfo *compInfo = &CompInfo;
|
SCompInfo *compInfo = &CompInfo;
|
||||||
read(fd, compInfo, sizeof(SCompInfo));
|
read(pVnodeFileInfo->headerFd, compInfo, sizeof(SCompInfo));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// check compblock info integrity
|
// check compblock info integrity
|
||||||
|
@ -542,19 +558,19 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
|
|
||||||
memset(pQuery->pBlock, 0, (size_t)pQuery->blockBufferSize);
|
memset(pQuery->pBlock, 0, (size_t)pQuery->blockBufferSize);
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
memcpy(pQuery->pBlock, (char *)compInfo + sizeof(SCompInfo), (size_t)compBlockSize);
|
memcpy(pQuery->pBlock, (char *)compInfo + sizeof(SCompInfo), (size_t)compBlockSize);
|
||||||
TSCKSUM checksum = *(TSCKSUM *)((char *)compInfo + sizeof(SCompInfo) + compBlockSize);
|
TSCKSUM checksum = *(TSCKSUM *)((char *)compInfo + sizeof(SCompInfo) + compBlockSize);
|
||||||
#else
|
#else
|
||||||
TSCKSUM checksum;
|
TSCKSUM checksum;
|
||||||
read(fd, pQuery->pBlock, compBlockSize);
|
read(pVnodeFileInfo->headerFd, pQuery->pBlock, compBlockSize);
|
||||||
read(fd, &checksum, sizeof(TSCKSUM));
|
read(pVnodeFileInfo->headerFd, &checksum, sizeof(TSCKSUM));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// check comp block integrity
|
// check comp block integrity
|
||||||
if (validateCompBlockSegment(pQInfo, pRuntimeEnv->vnodeFileInfo.headerFilePath, compInfo, (char *)pQuery->pBlock,
|
if (validateCompBlockSegment(pQInfo, pRuntimeEnv->vnodeFileInfo.headerFilePath, compInfo, (char *)pQuery->pBlock,
|
||||||
pMeterObj->vnode, checksum) < 0) {
|
pMeterObj->vnode, checksum) < 0) {
|
||||||
return -1;
|
return -1; //TODO free resource in error process
|
||||||
}
|
}
|
||||||
|
|
||||||
pQuery->pFields = (SField **)((char *)pQuery->pBlock + compBlockSize);
|
pQuery->pFields = (SField **)((char *)pQuery->pBlock + compBlockSize);
|
||||||
|
@ -568,6 +584,7 @@ static int vnodeGetCompBlockInfo(SMeterObj *pMeterObj, SQueryRuntimeEnv *pRuntim
|
||||||
pSummary->totalCompInfoSize += compBlockSize;
|
pSummary->totalCompInfoSize += compBlockSize;
|
||||||
pSummary->loadCompInfoUs += (et - st);
|
pSummary->loadCompInfoUs += (et - st);
|
||||||
|
|
||||||
|
free(buf);
|
||||||
return pQuery->numOfBlocks;
|
return pQuery->numOfBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue