上一页 1 ··· 3 4 5 6 7
摘要: BDB中 内存池是用一个 hash table来管理 buffers. 这个hash table的大小首先是和 内存池的大小成正比. 其次, bdb code会经常遍历hash chain, 它的长度 不能太大. 计算公式为: cache 大小/region数目 = 每个region的大小 buck 阅读全文
posted @ 2016-02-26 22:43 brayden 阅读(471) 评论(0) 推荐(0) 编辑
摘要: 一个典型的 buddy system. 代码在env/env_alloc.c 数据结构: ALLOC_LAYOUT: 管理整块内存(即bdb的某个region)的 数据结构. 放于此内存 开头位置. SH_TAILQ_HEAD(__addrq) addrq; // address queue. 按地 阅读全文
posted @ 2016-02-26 17:44 brayden 阅读(692) 评论(0) 推荐(0) 编辑
摘要: 下面的代码保证了BDB 的write ahead logging机制. 在写database page之前, 确保此page buffer对应的log lsn已经 sync到 disk上. //src/mp/mp_bh.c, __memp_pgwrite() /* * If the page is 阅读全文
posted @ 2016-02-26 14:11 brayden 阅读(370) 评论(0) 推荐(0) 编辑
摘要: 我们产品的code 用了sqlite的源码: // lang/sql/sqlite/src/hash.h, lang/sql/sqlite/src/hash.c: struct HashElem { ... const char *pKey; void *sqlite3HashInsert(Hash 阅读全文
posted @ 2016-02-25 13:21 brayden 阅读(250) 评论(0) 推荐(0) 编辑
摘要: class Engine { Engine(...) throws Exception { // do some locking // do other things that could throw exception } void close() { // do unlocking } } pu 阅读全文
posted @ 2016-02-25 12:27 brayden 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 修复一个产品bug, 最终定位是memcpy使用的问题. 下面的示例代码: #define N 16 int main() { int arr[N], i; for (i = 0; i < N; i++) arr[i] = i; printf("before memcpy:\n"); prt(arr 阅读全文
posted @ 2016-02-25 11:21 brayden 阅读(216) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7