more work

This commit is contained in:
Hongze Cheng 2021-12-11 17:28:31 +08:00
parent dcc672d056
commit ae18e4c390
5 changed files with 24 additions and 7 deletions

View File

@ -10,7 +10,7 @@ set(CMAKE_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CONTRIB_DIR "${CMAKE_SOURCE_DIR}/contrib")
include(${CMAKE_SUPPORT_DIR}/cmake.options)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -gdwarf-2 -msse4.2 -mfma")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -gdwarf-2 -msse4.2 -mfma -g3")
# contrib
add_subdirectory(contrib)

View File

@ -28,6 +28,7 @@ typedef struct SVBufPool SVBufPool;
int vnodeOpenBufPool(SVnode *pVnode);
void vnodeCloseBufPool(SVnode *pVnode);
void *vnodeMalloc(SVnode *pVnode, uint64_t size);
bool vnodeBufPoolIsFull(SVnode *pVnode);
#ifdef __cplusplus
}

View File

@ -22,7 +22,7 @@
extern "C" {
#endif
bool vnodeShouldCommit(SVnode *pVnode);
#define vnodeShouldCommit vnodeBufPoolIsFull
int vnodeAsyncCommit(SVnode *pVnode);
#ifdef __cplusplus

View File

@ -148,6 +148,24 @@ void *vnodeMalloc(SVnode *pVnode, uint64_t size) {
return vBufPoolMalloc(pvma, size);
}
bool vnodeBufPoolIsFull(SVnode *pVnode) {
SVBufPool * pBufPool = pVnode->pBufPool;
SVMemAllocator *pvma;
if (pBufPool->inuse == NULL) return false;
pvma = (SVMemAllocator *)(pBufPool->inuse->data);
if (pvma->type == E_V_HEAP_ALLOCATOR) {
ASSERT(0);
} else {
SVArenaNode *pNode = pvma->vaa.inuse;
bool ret =
(pNode != &(pvma->vaa.node)) || ((pNode->size - POINTER_DISTANCE(pNode->ptr, pNode->data)) <= pvma->vaa.lsize);
return ret;
}
}
/* ------------------------ STATIC METHODS ------------------------ */
static void vArenaAllocatorInit(SVArenaAllocator *pvaa, uint64_t capacity, uint64_t ssize, uint64_t lsize) { /* TODO */
pvaa->ssize = ssize;
@ -171,8 +189,8 @@ static SListNode *vBufPoolNewNode(uint64_t capacity, EVMemAllocatorT type) {
SListNode * pNode;
SVMemAllocator *pvma;
uint64_t msize;
uint64_t ssize = 0; // TODO
uint64_t lsize = 0; // TODO
uint64_t ssize = 4096; // TODO
uint64_t lsize = 1024; // TODO
msize = sizeof(SListNode) + sizeof(SVMemAllocator);
if (type == E_V_ARENA_ALLOCATOR) {

View File

@ -18,8 +18,6 @@
static int vnodeStartCommit(SVnode *pVnode);
static int vnodeEndCommit(SVnode *pVnode);
bool vnodeShouldCommit(SVnode *pVnode) { return false; }
int vnodeAsyncCommit(SVnode *pVnode) {
#if 0
if (vnodeStartCommit(pVnode) < 0) {