Files
mongo/include/cache.h
Michael Cahill 7ebbbf1d52 Restructure the tree to ease merge.
refs #27

--HG--
branch : keith
rename : lint/fl => dist/lint/fl
rename : lint/lint.current => dist/lint/lint.current
rename : inc_posix/bitstring.h => include/bitstring.h
rename : inc_posix/btree.h => include/btree.h
rename : inc_posix/cache.h => include/cache.h
rename : inc_posix/debug.h => include/debug.h
rename : inc_posix/extern.h => include/extern.h
rename : inc_posix/fh.h => include/fh.h
rename : inc_posix/mem.h => include/mem.h
rename : inc_posix/misc.h => include/misc.h
rename : inc_posix/mutex.h => include/mutex.h
rename : inc_posix/queue.h => include/queue.h
rename : inc_posix/serial.h => include/serial.h
rename : inc_posix/stat.h => include/stat.h
rename : inc_posix/util.h => include/util.h
rename : inc_posix/walk.h => include/walk.h
rename : inc_posix/wiredtiger.in => include/wiredtiger.in
rename : inc_posix/wt_internal.in => include/wt_internal.in
rename : btree/bt_alloc.c => src/btree/bt_alloc.c
rename : btree/bt_bulk.c => src/btree/bt_bulk.c
rename : btree/bt_cache.c => src/btree/bt_cache.c
rename : btree/bt_close.c => src/btree/bt_close.c
rename : btree/bt_cmp.c => src/btree/bt_cmp.c
rename : btree/bt_debug.c => src/btree/bt_debug.c
rename : btree/bt_desc.c => src/btree/bt_desc.c
rename : btree/bt_discard.c => src/btree/bt_discard.c
rename : btree/bt_dump.c => src/btree/bt_dump.c
rename : btree/bt_evict.c => src/btree/bt_evict.c
rename : btree/bt_misc.c => src/btree/bt_misc.c
rename : btree/bt_open.c => src/btree/bt_open.c
rename : btree/bt_ovfl.c => src/btree/bt_ovfl.c
rename : btree/bt_page.c => src/btree/bt_page.c
rename : btree/bt_read.c => src/btree/bt_read.c
rename : btree/bt_reconcile.c => src/btree/bt_reconcile.c
rename : btree/bt_ret.c => src/btree/bt_ret.c
rename : btree/bt_rw.c => src/btree/bt_rw.c
rename : btree/bt_stat.c => src/btree/bt_stat.c
rename : btree/bt_sync.c => src/btree/bt_sync.c
rename : btree/bt_vrfy.c => src/btree/bt_vrfy.c
rename : btree/bt_walk.c => src/btree/bt_walk.c
rename : btree/c_drain.c => src/btree/c_drain.c
rename : btree/c_init.c => src/btree/c_init.c
rename : btree/c_page.c => src/btree/c_page.c
rename : btree/c_read.c => src/btree/c_read.c
rename : btree/col_get.c => src/btree/col_get.c
rename : btree/col_put.c => src/btree/col_put.c
rename : btree/col_srch.c => src/btree/col_srch.c
rename : btree/row_get.c => src/btree/row_get.c
rename : btree/row_put.c => src/btree/row_put.c
rename : btree/row_srch.c => src/btree/row_srch.c
rename : db/db_err.c => src/db/db_err.c
rename : db/db_getset.c => src/db/db_getset.c
rename : db/db_handle.c => src/db/db_handle.c
rename : db/db_huffman.c => src/db/db_huffman.c
rename : db/db_open.c => src/db/db_open.c
rename : db/db_stat.c => src/db/db_stat.c
rename : db/db_sync.c => src/db/db_sync.c
rename : env/env_err.c => src/env/env_err.c
rename : env/env_getset.c => src/env/env_getset.c
rename : env/env_global.c => src/env/env_global.c
rename : env/env_handle.c => src/env/env_handle.c
rename : env/env_init.c => src/env/env_init.c
rename : env/env_msg.c => src/env/env_msg.c
rename : env/env_open.c => src/env/env_open.c
rename : env/env_stat.c => src/env/env_stat.c
rename : env/env_sync.c => src/env/env_sync.c
rename : env/env_toc.c => src/env/env_toc.c
rename : env/env_workq.c => src/env/env_workq.c
rename : os_posix/os_abort.c => src/os_posix/os_abort.c
rename : os_posix/os_alloc.c => src/os_posix/os_alloc.c
rename : os_posix/os_filesize.c => src/os_posix/os_filesize.c
rename : os_posix/os_fsync.c => src/os_posix/os_fsync.c
rename : os_posix/os_mtx.c => src/os_posix/os_mtx.c
rename : os_posix/os_open.c => src/os_posix/os_open.c
rename : os_posix/os_rw.c => src/os_posix/os_rw.c
rename : os_posix/os_sleep.c => src/os_posix/os_sleep.c
rename : os_posix/os_thread.c => src/os_posix/os_thread.c
rename : os_posix/os_yield.c => src/os_posix/os_yield.c
rename : support/api.c => src/support/api.c
rename : support/cksum.c => src/support/cksum.c
rename : support/err.c => src/support/err.c
rename : support/hazard.c => src/support/hazard.c
rename : support/huffman.c => src/support/huffman.c
rename : support/pow.c => src/support/pow.c
rename : support/prime.c => src/support/prime.c
rename : support/progress.c => src/support/progress.c
rename : support/scratch.c => src/support/scratch.c
rename : support/serial.c => src/support/serial.c
rename : support/simple_setup.c => src/support/simple_setup.c
rename : support/stat.c => src/support/stat.c
rename : support/strerror.c => src/support/strerror.c
rename : support/version.c => src/support/version.c
rename : utilities/db_dump/util_dump.c => src/utilities/db_dump/util_dump.c
rename : utilities/db_load/util_load.c => src/utilities/db_load/util_load.c
rename : utilities/db_stat/util_stat.c => src/utilities/db_stat/util_stat.c
rename : utilities/db_verify/util_verify.c => src/utilities/db_verify/util_verify.c
2011-02-01 09:24:17 +11:00

124 lines
3.8 KiB
C

/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2008-2011 WiredTiger, Inc.
* All rights reserved.
*
* $Id$
*/
#if defined(__cplusplus)
extern "C" {
#endif
struct __wt_evict_list; typedef struct __wt_evict_list WT_EVICT_LIST;
struct __wt_read_req; typedef struct __wt_read_req WT_READ_REQ;
/*
* WT_EVICT_LIST --
* Encapsulation of an eviction choice.
*/
struct __wt_evict_list {
WT_REF *ref; /* WT_REF structure */
IDB *idb; /* Underlying file object */
};
/*
* WT_READ_REQ --
* Encapsulation of a read request.
*/
struct __wt_read_req {
WT_TOC *toc; /* Requesting thread */
WT_PAGE *parent; /* Parent */
WT_REF *ref; /* Address */
WT_OFF *off; /* Bytes */
int dsk_verify; /* Verify the disk image */
};
#define WT_READ_REQ_ISEMPTY(r) \
((r)->toc == NULL)
#define WT_READ_REQ_SET(r, _toc, _parent, _ref, _off, _dsk_verify) do { \
(r)->ref = _ref; \
(r)->parent = _parent; \
(r)->off = _off; \
(r)->dsk_verify = _dsk_verify; \
WT_MEMORY_FLUSH; /* Flush before turning entry on */ \
(r)->toc = _toc; \
WT_MEMORY_FLUSH; /* Turn entry on */ \
} while (0)
#define WT_READ_REQ_CLR(r) do { \
(r)->toc = NULL; \
WT_MEMORY_FLUSH; /* Turn entry off */ \
} while (0)
/*
* WiredTiger cache structure.
*/
struct __wt_cache {
/*
* The Db.sync method and cache eviction server both want to reconcile
* pages, and there are two problems: first, reconciliation updates
* parent pages, which means the Db.sync method and the cache eviction
* server might update the same parent page at the same time. Second,
* the Db.sync method and cache eviction server may attempt to reconcile
* the same page at the same time which implies serialization anyway.
* We could probably handle that, but for now, I'm going to make page
* reconciliation single-threaded.
*/
WT_MTX *mtx_reconcile; /* Single-thread page reconciliation */
/*
* The cache thread sets/clears the evict_sleeping flag when blocked
* on the mtx_evict mutex. The workQ thread uses the evict_sleeping
* flag to wake the cache eviction thread as necessary.
*/
WT_MTX *mtx_evict; /* Cache eviction server mutex */
u_int volatile evict_sleeping; /* Sleeping */
/*
* The I/O thread sets/clears the io_sleeping flag when blocked on the
* mtx_io mutex. The cache thread uses the io_sleeping flag to wake
* the I/O thread as necessary.
*/
WT_MTX *mtx_read; /* Cache read server mutex */
u_int volatile read_sleeping; /* Sleeping */
u_int volatile read_lockout; /* No reading until memory drains */
WT_READ_REQ read_request[40]; /* Read requests:
slot available if toc is NULL */
uint32_t read_gen; /* Page read generation (LRU) */
/*
* Different threads read/write pages to/from the cache, so we cannot
* know precisely how much memory is in use at any specific time.
* However, even though the values don't have to be exact, they can't
* be garbage -- we track what comes in and what goes out and calculate
* the difference as needed.
*/
#define WT_CACHE_PAGE_IN(c, bytes) do { \
++(c)->stat_pages_in; \
(c)->stat_bytes_in += bytes; \
} while (0)
#define WT_CACHE_PAGE_OUT(c, bytes) do { \
++(c)->stat_pages_out; \
(c)->stat_bytes_out += bytes; \
} while (0)
uint64_t stat_pages_in;
uint64_t stat_bytes_in;
uint64_t stat_pages_out;
uint64_t stat_bytes_out;
WT_EVICT_LIST *evict; /* Pages being tracked for eviction */
uint32_t evict_elem; /* Number of elements in the array */
uint32_t evict_len; /* Bytes in the array */
WT_PAGE **hazard; /* Copy of the hazard references */
uint32_t hazard_elem; /* Number of entries in the list */
uint32_t hazard_len; /* Bytes in the list */
WT_STATS *stats; /* Cache statistics */
};
#if defined(__cplusplus)
}
#endif