Merge pull request #18661 from taosdata/fix/liao_cov
enh(query): improve the performance and add some todo
This commit is contained in:
commit
241638de33
|
@ -19,7 +19,7 @@
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
#define MALLOC_ALIGN_BYTES 32
|
#define MALLOC_ALIGN_BYTES 256
|
||||||
|
|
||||||
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
|
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
|
||||||
ASSERT(pColumnInfoData != NULL);
|
ASSERT(pColumnInfoData != NULL);
|
||||||
|
@ -1191,7 +1191,6 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
||||||
int32_t oldLen = BitmapLen(existedRows);
|
int32_t oldLen = BitmapLen(existedRows);
|
||||||
pColumn->nullbitmap = tmp;
|
pColumn->nullbitmap = tmp;
|
||||||
memset(&pColumn->nullbitmap[oldLen], 0, BitmapLen(numOfRows) - oldLen);
|
memset(&pColumn->nullbitmap[oldLen], 0, BitmapLen(numOfRows) - oldLen);
|
||||||
|
|
||||||
ASSERT(pColumn->info.bytes);
|
ASSERT(pColumn->info.bytes);
|
||||||
|
|
||||||
// make sure the allocated memory is MALLOC_ALIGN_BYTES aligned
|
// make sure the allocated memory is MALLOC_ALIGN_BYTES aligned
|
||||||
|
@ -1207,6 +1206,12 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
pColumn->pData = tmp;
|
pColumn->pData = tmp;
|
||||||
|
|
||||||
|
// todo remove it soon
|
||||||
|
#if defined LINUX
|
||||||
|
ASSERT((((uint64_t)pColumn->pData) & (MALLOC_ALIGN_BYTES - 1)) == 0x0);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (clearPayload) {
|
if (clearPayload) {
|
||||||
memset(tmp + pColumn->info.bytes * existedRows, 0, pColumn->info.bytes * (numOfRows - existedRows));
|
memset(tmp + pColumn->info.bytes * existedRows, 0, pColumn->info.bytes * (numOfRows - existedRows));
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
|
||||||
void* pData = NULL;
|
void* pData = NULL;
|
||||||
pGroupResInfo->pRows = taosArrayInit(10, POINTER_BYTES);
|
pGroupResInfo->pRows = taosArrayInit(10, POINTER_BYTES);
|
||||||
|
|
||||||
|
// todo avoid repeated malloc memory
|
||||||
size_t keyLen = 0;
|
size_t keyLen = 0;
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) {
|
while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) {
|
||||||
|
|
|
@ -165,10 +165,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
||||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
colDataDestroy(out.columnData);
|
colInfoDataCleanup(out.columnData, out.numOfRows);
|
||||||
taosMemoryFreeClear(out.columnData);
|
|
||||||
out.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
|
||||||
|
|
||||||
cell = cell->pNext;
|
cell = cell->pNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,8 @@ void* taosMemoryMallocAlign(uint32_t alignment, int64_t size) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
#else
|
#else
|
||||||
#if defined(LINUX)
|
#if defined(LINUX)
|
||||||
return memalign(alignment, size);
|
void* p = memalign(alignment, size);
|
||||||
|
return p;
|
||||||
#else
|
#else
|
||||||
return taosMemoryMalloc(size);
|
return taosMemoryMalloc(size);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct SDiskbasedBuf {
|
||||||
TdFilePtr pFile;
|
TdFilePtr pFile;
|
||||||
int32_t allocateId; // allocated page id
|
int32_t allocateId; // allocated page id
|
||||||
char* path; // file path
|
char* path; // file path
|
||||||
|
char* prefix; // file name prefix
|
||||||
int32_t pageSize; // current used page size
|
int32_t pageSize; // current used page size
|
||||||
int32_t inMemPages; // numOfPages that are allocated in memory
|
int32_t inMemPages; // numOfPages that are allocated in memory
|
||||||
SList* freePgList; // free page list
|
SList* freePgList; // free page list
|
||||||
|
@ -48,6 +49,12 @@ struct SDiskbasedBuf {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t createDiskFile(SDiskbasedBuf* pBuf) {
|
static int32_t createDiskFile(SDiskbasedBuf* pBuf) {
|
||||||
|
if (pBuf->path == NULL) { // prepare the file name when needed it
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
taosGetTmpfilePath(pBuf->prefix, "paged-buf", path);
|
||||||
|
pBuf->path = taosMemoryStrDup(path);
|
||||||
|
}
|
||||||
|
|
||||||
pBuf->pFile =
|
pBuf->pFile =
|
||||||
taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
|
taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
|
||||||
if (pBuf->pFile == NULL) {
|
if (pBuf->pFile == NULL) {
|
||||||
|
@ -356,10 +363,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
|
||||||
|
|
||||||
pPBuf->assistBuf = taosMemoryMalloc(pPBuf->pageSize + 2); // EXTRA BYTES
|
pPBuf->assistBuf = taosMemoryMalloc(pPBuf->pageSize + 2); // EXTRA BYTES
|
||||||
pPBuf->all = taosHashInit(10, fn, true, false);
|
pPBuf->all = taosHashInit(10, fn, true, false);
|
||||||
|
pPBuf->prefix = (char*) dir;
|
||||||
char path[PATH_MAX] = {0};
|
|
||||||
taosGetTmpfilePath(dir, "paged-buf", path);
|
|
||||||
pPBuf->path = strdup(path);
|
|
||||||
|
|
||||||
pPBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
|
pPBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue