summaryrefslogtreecommitdiff
path: root/src/conn/conn_handle.c
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2013-10-17 11:37:45 -0400
committerKeith Bostic <keith@wiredtiger.com>2013-10-17 11:43:50 -0400
commit1903f5137dd4d0954f786e9718b20538dfbe7760 (patch)
treeb97e3d6ab554dbcef3f12a53bf06738ad17c9d45 /src/conn/conn_handle.c
parent2d9512cf832694e165ee27cf6a66c89f985590e0 (diff)
downloadmongo-1903f5137dd4d0954f786e9718b20538dfbe7760.tar.gz
Replace the per-btree handle spinlock with an array of 256 spinlocks in
the connection structure. When a page is first modified, the sequentially next spinlock is assigned to the page, and then the page uses that spinlock to serialize its modifications. Reference #721.
Diffstat (limited to 'src/conn/conn_handle.c')
-rw-r--r--src/conn/conn_handle.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/conn/conn_handle.c b/src/conn/conn_handle.c
index 3cef3f3ddd7..fda8d0a7fcf 100644
--- a/src/conn/conn_handle.c
+++ b/src/conn/conn_handle.c
@@ -15,6 +15,7 @@ int
__wt_connection_init(WT_CONNECTION_IMPL *conn)
{
WT_SESSION_IMPL *session;
+ u_int i;
session = conn->default_session;
@@ -40,6 +41,11 @@ __wt_connection_init(WT_CONNECTION_IMPL *conn)
WT_RET(__wt_spin_init(session, &conn->fh_lock, "file list"));
WT_RET(__wt_spin_init(session, &conn->hot_backup_lock, "hot backup"));
WT_RET(__wt_spin_init(session, &conn->schema_lock, "schema"));
+ for (i = 0; i < WT_PAGE_LOCKS(conn); ++i) {
+ WT_RET(__wt_calloc_def(session, 1, &conn->page_lock[i]));
+ WT_RET(
+ __wt_spin_init(session, conn->page_lock[i], "btree page"));
+ }
/*
* Block manager.
@@ -62,6 +68,7 @@ __wt_connection_destroy(WT_CONNECTION_IMPL *conn)
{
WT_DECL_RET;
WT_SESSION_IMPL *session;
+ u_int i;
/* Check there's something to destroy. */
if (conn == NULL)
@@ -94,6 +101,10 @@ __wt_connection_destroy(WT_CONNECTION_IMPL *conn)
__wt_spin_destroy(session, &conn->fh_lock);
__wt_spin_destroy(session, &conn->hot_backup_lock);
__wt_spin_destroy(session, &conn->schema_lock);
+ for (i = 0; i < WT_PAGE_LOCKS(conn); ++i) {
+ __wt_spin_destroy(session, conn->page_lock[i]);
+ __wt_free(session, conn->page_lock[i]);
+ }
/* Free allocated memory. */
__wt_free(session, conn->home);