wiredtiger - hazard pointers
http://www.drdobbs.com/lock-free-data-structures-with-hazard-po/184401890
memory deallocation lock-free
session.h
/*
* WT_HAZARD --
* A hazard pointer.
*/
struct __wt_hazard {
WT_PAGE *page; /* Page address */
#ifdef HAVE_DIAGNOSTIC
const char *file; /* File/line where hazard acquired */
int line;
#endif
}; struct WT_COMPILER_TYPE_ALIGN(WT_CACHE_LINE_ALIGNMENT) __wt_session_impl {
// 略...
/*
* Hazard pointers.
*
* Use the non-NULL state of the hazard field to know if the session has
* previously been initialized.
*/
#define WT_SESSION_FIRST_USE(s) \
((s)->hazard == NULL) /* The number of hazard pointers grows dynamically. */
#define WT_HAZARD_INCR 10
uint32_t hazard_size; /* Allocated slots in hazard array. */
uint32_t nhazard; /* Count of active hazard pointers */
WT_HAZARD *hazard; /* Hazard pointer array */
};
support/hazard.c
__wt_hazard_set()
/__wt_hazard_clear()
btree.i
在__wt_page_hazard_check前, cas保证WT_REF为 WT_REF_LOCKED(btmem.h, struct __wt_ref)
__wt_page_hazard_check(WT_SESSION_IMPL *session, WT_PAGE *page)
{
WT_CONNECTION_IMPL *conn;
WT_HAZARD *hp;
WT_SESSION_IMPL *s;
uint32_t i, hazard_size, session_cnt; conn = S2C(session); /*
* No lock is required because the session array is fixed size, but it
* may contain inactive entries. We must review any active session
* that might contain a hazard pointer, so insert a barrier before
* reading the active session count. That way, no matter what sessions
* come or go, we'll check the slots for all of the sessions that could
* have been active when we started our check.
*/
WT_ORDERED_READ(session_cnt, conn->session_cnt);
for (s = conn->sessions, i = ; i < session_cnt; ++s, ++i) {
if (!s->active)
continue;
WT_ORDERED_READ(hazard_size, s->hazard_size);
for (hp = s->hazard; hp < s->hazard + hazard_size; ++hp)
if (hp->page == page)
return (hp);
}
return (NULL);
}
wiredtiger - hazard pointers的更多相关文章
- 关于Hazard Pointers的话题
关于Hazard Pointers的话题, 起源于这个文章: 实现无锁的栈与队列(4) http://www.cnblogs.com/catch/p/3176636.html 其实他的系列文章(3)之 ...
- 风险指针(Hazard Pointer) 内存空间共享模型
WiredTiger是一种高性能的开源存储引擎,现已在MongoDB中作为内模式应用.WiredTiger支持行存储.列存储两种存储模式,采用LSM Tree方式进行索引记录 WiredTiger支持 ...
- lock free数据结构内存回收技术-hazard pointer
lock free数据结构一般来说拥有比基于lock实现的数据结构更高的性能,但是其实现比基于lock的实现更为复杂,需要处理的难题包括预防ABA问题,内存如何重用和回收等.通常,最简单最有效的处理A ...
- [转载]锁无关的数据结构与Hazard指针——操纵有限的资源
Lock-Free Data Structures with Hazard Pointers 锁无关的数据结构与Hazard指针----操纵有限的资源 By Andrei Alexandrescu a ...
- MongoDB新存储引擎WiredTiger实现(事务篇)
导语:计算机硬件在飞速发展,数据规模在急速膨胀,但是数据库仍然使用是十年以前的架构体系,WiredTiger 尝试打破这一切,充分利用多核与大内存时代,开发一种真正满足未来大数据管理所需的数据库.本文 ...
- Leetcode 笔记 117 - Populating Next Right Pointers in Each Node II
题目链接:Populating Next Right Pointers in Each Node II | LeetCode OJ Follow up for problem "Popula ...
- Leetcode 笔记 116 - Populating Next Right Pointers in Each Node
题目链接:Populating Next Right Pointers in Each Node | LeetCode OJ Given a binary tree struct TreeLinkNo ...
- MongoDB 存储引擎:WiredTiger和In-Memory
存储引擎(Storage Engine)是MongoDB的核心组件,负责管理数据如何存储在硬盘(Disk)和内存(Memory)上.从MongoDB 3.2 版本开始,MongoDB 支持多数据存储引 ...
- [LeetCode] Populating Next Right Pointers in Each Node II 每个节点的右向指针之二
Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tre ...
随机推荐
- power
http://software.intel.com/en-us/articles/power-efficiency-analysis-and-sw-development-recommendation ...
- 重装系统分区时,发现一个叫LVM的东西,找出来和大家分享
LVM是 Logical Volume Manager(逻辑卷管理)的简写,它是Linux环境下对磁盘分区进行管理的一种机制,它由Heinz Mauelshagen在Linux 2.4内核上实现,目前 ...
- springMVC操作mongoDB增删改查
下面是mongoDb简单的增删改查(新闻类) 附:query.addCriteria(Criteria.where("modelId").ne("").ne(n ...
- 【Tree 2】树形结构数据呈现的非递归算法(循环)实现
一.基本概况 上一篇博客介绍到用递归实现树结构数据的查找,那么这篇博客,我就结合自己对于树的理解,然后用一种非递归的方式进行树结构数据的处理.首先,改造数据库表设计,加入度的概念: 首先,layer的 ...
- Qlikview 的服务器
服务器管理 1 , Create a job 1.1 转到 Documents 分页 1.2 从左边目录搜索到 需要执行Job的qvw报表,如 "getting start.qvw" ...
- C# 數據事務操作
public sealed class SQLFunc { #region Methods #region OpenConnection /// <summary>指定包含連接字串的字串 ...
- jenkins+findbugs
1) Jenkins安装findbugs插件 具体安装步骤:在主页面进入系统管理 选择插件管理 在过滤器中找出要安装的插件,并进行安装(Static Analysis Utilities.findb ...
- 关于CacheLookup一个有趣的问题
今天写一个与其他系统进行物料同步的接口,通过COM Business Connector调用Axapta3.0的方法将数据插入到物料表中,中间发生异常,事务回滚,再次调用的时候提示刚刚发生异常的物料已 ...
- bash脚本编程之二 条件判断and 逻辑运算
1.条件测试结构 1) if/then结构: 判断命令列表的退出码是否为0,0为成功. 如果if和then在条件判断的同一行上的话, 必须使用分号来结束if表达式: if和then都是关键字. 关键字 ...
- Unity协程(Coroutine)管理类——TaskManager工具分享
博客分类: Unity3D插件学习,工具分享 源码分析 Unity协程(Coroutine)管理类——TaskManager工具分享 By D.S.Qiu 尊重他人的劳动,支持原创,转载请注明出处 ...