From 0691d7ff9ae7b1cb996581a85664eaed656f22ac Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 12 Oct 2022 10:40:50 +0800 Subject: [PATCH 1/4] enh: code optimization for insert_req statistics --- source/dnode/vnode/src/vnd/vnodeSvr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 2482ca1a5a..fe0403e763 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -819,11 +819,12 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq int32_t tsize, ret; SEncoder encoder = {0}; SArray *newTbUids = NULL; + SVStatis statis = {0}; terrno = TSDB_CODE_SUCCESS; pRsp->code = 0; pSubmitReq->version = version; - atomic_fetch_add_64(&pVnode->statis.nBatchInsert, 1); + statis.nBatchInsert = 1; #ifdef TD_DEBUG_PRINT_ROW vnodeDebugPrintSubmitMsg(pVnode, pReq, __func__); @@ -943,18 +944,21 @@ _exit: taosArrayDestroyEx(submitRsp.pArray, tFreeSSubmitBlkRsp); - atomic_fetch_add_64(&pVnode->statis.nInsert, submitRsp.numOfRows); - atomic_fetch_add_64(&pVnode->statis.nInsertSuccess, submitRsp.affectedRows); - // TODO: the partial success scenario and the error case // => If partial success, extract the success submitted rows and reconstruct a new submit msg, and push to level // 1/level 2. // TODO: refactor if ((terrno == TSDB_CODE_SUCCESS) && (pRsp->code == TSDB_CODE_SUCCESS)) { - atomic_fetch_add_64(&pVnode->statis.nBatchInsertSuccess, 1); + statis.nBatchInsertSuccess = 1; tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT); } + // N.B not strict as the following update steps is not atomic + atomic_add_fetch_64(&pVnode->statis.nInsert, submitRsp.numOfRows); + atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, submitRsp.affectedRows); + atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, statis.nBatchInsertSuccess); + atomic_add_fetch_64(&pVnode->statis.nBatchInsert, statis.nBatchInsert); + vDebug("vgId:%d, submit success, index:%" PRId64, pVnode->config.vgId, version); return 0; } From 0d50e5933b17dbb0c6977023ca97670ef7ac6ae0 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 12 Oct 2022 10:46:18 +0800 Subject: [PATCH 2/4] enh: code optimization for insert_req statistics --- source/dnode/vnode/src/vnd/vnodeSvr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index fe0403e763..d4dc7b49b0 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -956,8 +956,8 @@ _exit: // N.B not strict as the following update steps is not atomic atomic_add_fetch_64(&pVnode->statis.nInsert, submitRsp.numOfRows); atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, submitRsp.affectedRows); - atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, statis.nBatchInsertSuccess); atomic_add_fetch_64(&pVnode->statis.nBatchInsert, statis.nBatchInsert); + atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, statis.nBatchInsertSuccess); vDebug("vgId:%d, submit success, index:%" PRId64, pVnode->config.vgId, version); return 0; From 553394ca7fd507fd3701b51756fee273d5a4a7dd Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 12 Oct 2022 10:47:31 +0800 Subject: [PATCH 3/4] enh: code optimization for insert_req statistics --- source/dnode/vnode/src/vnd/vnodeSvr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d4dc7b49b0..bcc3fbd4d5 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -953,7 +953,7 @@ _exit: tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT); } - // N.B not strict as the following update steps is not atomic + // N.B. not strict as the following update steps is not atomic atomic_add_fetch_64(&pVnode->statis.nInsert, submitRsp.numOfRows); atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, submitRsp.affectedRows); atomic_add_fetch_64(&pVnode->statis.nBatchInsert, statis.nBatchInsert); From 488b4f31fd04dc6e358c5e7773a6161b2b9b3950 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 12 Oct 2022 10:51:18 +0800 Subject: [PATCH 4/4] enh: code optimization for insert_req statistics --- source/dnode/vnode/src/vnd/vnodeSvr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index bcc3fbd4d5..131327976f 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -953,7 +953,7 @@ _exit: tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT); } - // N.B. not strict as the following update steps is not atomic + // N.B. not strict as the following procedure is not atomic atomic_add_fetch_64(&pVnode->statis.nInsert, submitRsp.numOfRows); atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, submitRsp.affectedRows); atomic_add_fetch_64(&pVnode->statis.nBatchInsert, statis.nBatchInsert);