summaryrefslogtreecommitdiff
path: root/src/include/cache.h
blob: 63a545e5dc341eaf2aa20c29059bd204f91d47c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*-
 * Copyright (c) 2008-2012 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

/*
 * WT_EVICT_LIST --
 *	Encapsulation of an eviction candidate.
 */
struct __wt_evict_list {
	WT_BTREE *btree;			/* File object */
	WT_PAGE	 *page;				/* Page */
};

/*
 * WT_EVICT_REQ --
 *	Encapsulation of a eviction request.
 */
struct __wt_evict_req {
	WT_SESSION_IMPL *session;		/* Requesting thread */
	WT_BTREE *btree;			/* Btree */
	WT_PAGE *page;                          /* Single page to flush */

#define	WT_EVICT_REQ_CLOSE      0x1		/* Discard pages */
#define	WT_EVICT_REQ_PAGE       0x2		/* Force out a page */
	uint32_t flags;
};

/*
 * WiredTiger cache structure.
 */
struct __wt_cache {
	/*
	 * Different threads read/write pages to/from the cache and create pages
	 * in 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.
	 */
	uint64_t bytes_read;		/* Bytes/pages read by read server */
	uint64_t pages_read;
	uint64_t bytes_inmem;		/* Bytes/pages created in memory */
	uint64_t bytes_evict;		/* Bytes/pages discarded by eviction */
	uint64_t pages_evict;

	/*
	 * Read information.
	 */
	uint32_t   read_gen;		/* Page read generation (LRU) */

	/*
	 * Eviction thread information.
	 */
	WT_CONDVAR *evict_cond;		/* Cache eviction server mutex */

	WT_SPINLOCK lru_lock;		/* Manage the eviction list. */

	WT_EVICT_LIST *evict;		/* Pages being tracked for eviction */
	WT_EVICT_LIST *evict_current;	/* Current page to be evicted */
	size_t   evict_allocated;	/* Bytes allocated */
	uint32_t evict_entries;		/* Total evict slots */

	u_int eviction_trigger;		/* Percent to trigger eviction. */
	u_int eviction_target;		/* Percent to end eviction. */

	WT_EVICT_REQ *evict_request;	/* Eviction requests:
					   slot available if session is NULL */
	uint32_t max_evict_request;	/* Size of the evict request array */
};