summaryrefslogtreecommitdiff
path: root/bbq/include/bbq.h
diff options
context:
space:
mode:
authorliuyu <[email protected]>2024-07-01 05:20:37 -0400
committerliuyu <[email protected]>2024-07-01 05:20:37 -0400
commit075525658564b863fe6feec425b2fe878575e3c7 (patch)
tree926cffa25e3a1e8215839ddb45756a34d34adfbd /bbq/include/bbq.h
parent79f2c35744a3a805c2f7b0884cf72f310a7d2dd2 (diff)
bbq使用内存池(临时代码)
Diffstat (limited to 'bbq/include/bbq.h')
-rw-r--r--bbq/include/bbq.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/bbq/include/bbq.h b/bbq/include/bbq.h
index 9fbae2b..d752130 100644
--- a/bbq/include/bbq.h
+++ b/bbq/include/bbq.h
@@ -1,6 +1,6 @@
/*
* @Author: [email protected]
- * @LastEditTime: 2024-07-01 03:53:40
+ * @LastEditTime: 2024-07-01 09:18:56
* @Describe: bbq(Block-based Bounded Queue)头文件
* 参考:https://www.usenix.org/system/files/atc22-wang-jiawei.pdf
*/
@@ -11,6 +11,9 @@
#include <stdint.h>
#include <stdlib.h>
+#define TEST_PERF_1 // 去除多余原子操作
+#define TEST_PERF_MEM // 一次性分配所有内存
+
#ifndef __cplusplus
// C
#include <stdatomic.h>
@@ -65,8 +68,15 @@ struct bbq {
struct bbq_atomic64 n_enq;
struct bbq_atomic64 n_deq;
} stat;
-
struct bbq_block *blocks; // bn大小的数组
+
+#ifdef TEST_PERF_MEM
+ struct {
+ char *ptr; // 内存池起始地址
+ size_t off; // 已使用的偏移大小
+ size_t size; // 内存池总大小
+ } memory_pool;
+#endif
} __BBQ_CACHE_ALIGNED;
#define BBQ_F_DEFAULT 0x0