MySQL  8.0.19
Source Code Documentation
default_engine.h
Go to the documentation of this file.
1 /*
2  * Summary: Specification of the storage engine interface.
3  *
4  * Copy: See Copyright for the status of this software.
5  *
6  * Author: Trond Norbye <trond.norbye@sun.com>
7  */
8 #ifndef MEMCACHED_DEFAULT_ENGINE_H
9 #define MEMCACHED_DEFAULT_ENGINE_H
10 
11 #include "config.h"
12 
13 #include <pthread.h>
14 #include <stdbool.h>
15 
16 #include <memcached/engine.h>
17 #include <memcached/util.h>
18 #include <memcached/visibility.h>
19 
20 /* Slab sizing definitions. */
21 #define POWER_SMALLEST 1
22 #define POWER_LARGEST 200
23 #define CHUNK_ALIGN_BYTES 8
24 #define DONT_PREALLOC_SLABS
25 #define MAX_NUMBER_OF_SLAB_CLASSES (POWER_LARGEST + 1)
26 
27 /** How long an object can reasonably be assumed to be locked before
28  harvesting it on a low memory condition. */
29 #define TAIL_REPAIR_TIME (3 * 3600)
30 
31 
32 /* Forward decl */
33 struct default_engine;
34 
35 #include "trace.h"
36 #include "items.h"
37 #include "assoc.h"
38 #include "slabs.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44  /* Flags */
45 #define ITEM_WITH_CAS 1
46 
47 #define ITEM_LINKED (1<<8)
48 
49 /* temp */
50 #define ITEM_SLABBED (2<<8)
51 
52 struct config {
53  bool use_cas;
54  size_t verbose;
55  rel_time_t oldest_live;
57  size_t maxbytes;
59  float factor;
60  size_t chunk_size;
61  size_t item_size_max;
63  bool vb0;
64 };
65 
66 MEMCACHED_PUBLIC_API
67 ENGINE_ERROR_CODE create_instance(uint64_t interface,
68  GET_SERVER_API get_server_api,
69  ENGINE_HANDLE **handle);
70 
71 /**
72  * Statistic information collected by the default engine
73  */
74 struct engine_stats {
75  pthread_mutex_t lock;
76  uint64_t evictions;
77  uint64_t reclaimed;
78  uint64_t curr_bytes;
79  uint64_t curr_items;
80  uint64_t total_items;
81 };
82 
84  pthread_mutex_t lock;
85  bool running;
86  uint64_t visited;
87  uint64_t cleaned;
88  time_t started;
89  time_t stopped;
90 };
91 
93  pthread_mutex_t lock;
94  size_t size;
95  const void* *clients;
96 };
97 
98 struct vbucket_info {
99  int state : 2;
100 };
101 
102 #define NUM_VBUCKETS 65536
103 
104 /**
105  * Definition of the private instance data used by the default engine.
106  *
107  * This is currently "work in progress" so it is not as clean as it should be.
108  */
110  ENGINE_HANDLE_V1 engine;
111  SERVER_HANDLE_V1 server;
112  GET_SERVER_API get_server_api;
113 
114  /**
115  * Is the engine initalized or not
116  */
118 
119  struct assoc assoc;
120  struct slabs slabs;
121  struct items items;
122 
123  /**
124  * The cache layer (item_* and assoc_*) is currently protected by
125  * this single mutex
126  */
127  pthread_mutex_t cache_lock;
128 
129  struct config config;
133 
134  union {
136  char buffer[sizeof(engine_info) +
137  (sizeof(feature_info) * LAST_REGISTERED_ENGINE_FEATURE)];
138  } info;
139 
141 };
142 
143 char* item_get_data(const hash_item* item);
144 const void* item_get_key(const hash_item* item);
145 void item_set_cas(ENGINE_HANDLE *handle, const void *cookie,
146  item* item, uint64_t val);
147 uint64_t item_get_cas(const hash_item* item);
148 uint8_t item_get_clsid(const hash_item* item);
149 #endif
engine_scrubber::lock
pthread_mutex_t lock
Definition: default_engine.h:84
assoc
Definition: assoc.h:4
assoc.h
config::use_cas
bool use_cas
Definition: default_engine.h:53
config::factor
float factor
Definition: default_engine.h:59
engine_stats::curr_bytes
uint64_t curr_bytes
Definition: default_engine.h:78
engine_stats::evictions
uint64_t evictions
Definition: default_engine.h:76
engine_scrubber::visited
uint64_t visited
Definition: default_engine.h:86
engine_scrubber::running
bool running
Definition: default_engine.h:85
engine_stats::lock
pthread_mutex_t lock
Definition: default_engine.h:75
default_engine::cache_lock
pthread_mutex_t cache_lock
The cache layer (item_* and assoc_*) is currently protected by this single mutex.
Definition: default_engine.h:127
config
Definition: default_engine.h:52
config::vb0
bool vb0
Definition: default_engine.h:63
default_engine::scrubber
struct engine_scrubber scrubber
Definition: default_engine.h:131
default_engine
Definition of the private instance data used by the default engine.
Definition: default_engine.h:109
default_engine::initialized
bool initialized
Is the engine initalized or not.
Definition: default_engine.h:117
handle
void * handle
Definition: engine_loader.c:19
engine_stats::curr_items
uint64_t curr_items
Definition: default_engine.h:79
get_server_api
static SERVER_HANDLE_V1 * get_server_api(void)
Callback the engines may call to get the public server interface.
Definition: memcached.c:6871
config::ignore_vbucket
bool ignore_vbucket
Definition: default_engine.h:62
engine_scrubber
Definition: default_engine.h:83
item_get_clsid
uint8_t item_get_clsid(const hash_item *item)
Definition: default_engine.c:733
item_get_data
char * item_get_data(const hash_item *item)
Definition: default_engine.c:728
items.h
default_engine::info
union default_engine::@23 info
config::item_size_max
size_t item_size_max
Definition: default_engine.h:61
default_engine::engine
ENGINE_HANDLE_V1 engine
Definition: default_engine.h:110
engine_scrubber::stopped
time_t stopped
Definition: default_engine.h:89
slabs.h
config::verbose
size_t verbose
Definition: default_engine.h:54
tap_connections
Definition: default_engine.h:92
default_engine::vbucket_infos
char vbucket_infos[NUM_VBUCKETS]
Definition: default_engine.h:140
default_engine::get_server_api
GET_SERVER_API get_server_api
Definition: default_engine.h:112
engine_scrubber::started
time_t started
Definition: default_engine.h:88
engine_stats::reclaimed
uint64_t reclaimed
Definition: default_engine.h:77
default_engine::buffer
char buffer[sizeof(engine_info)+(sizeof(feature_info) *LAST_REGISTERED_ENGINE_FEATURE)]
Definition: default_engine.h:137
_hash_item
Definition: items.h:8
item_set_cas
void item_set_cas(ENGINE_HANDLE *handle, const void *cookie, item *item, uint64_t val)
Definition: default_engine.c:709
vbucket_info
Definition: default_engine.h:98
config::chunk_size
size_t chunk_size
Definition: default_engine.h:60
engine_scrubber::cleaned
uint64_t cleaned
Definition: default_engine.h:87
tap_connections::size
size_t size
Definition: default_engine.h:94
stats
Global stats.
Definition: mysqlslap.cc:232
config::oldest_live
rel_time_t oldest_live
Definition: default_engine.h:55
vbucket_info::state
int state
Definition: default_engine.h:99
default_engine::server
SERVER_HANDLE_V1 server
Definition: default_engine.h:111
config::evict_to_free
bool evict_to_free
Definition: default_engine.h:56
default_engine::engine_info
engine_info engine_info
Definition: default_engine.h:135
item_get_key
const void * item_get_key(const hash_item *item)
Definition: default_engine.c:718
config::preallocate
bool preallocate
Definition: default_engine.h:58
items
Definition: items.h:34
engine_stats
Statistic information collected by the default engine.
Definition: default_engine.h:74
tap_connections::clients
const void ** clients
Definition: default_engine.h:95
engine_stats::total_items
uint64_t total_items
Definition: default_engine.h:80
item_get_cas
uint64_t item_get_cas(const hash_item *item)
Definition: default_engine.c:701
config::maxbytes
size_t maxbytes
Definition: default_engine.h:57
create_instance
MEMCACHED_PUBLIC_API ENGINE_ERROR_CODE create_instance(uint64_t interface, GET_SERVER_API get_server_api, ENGINE_HANDLE **handle)
Create InnoDB Memcached Engine.
Definition: default_engine.c:154
slabs
Definition: slabs.h:31
tap_connections::lock
pthread_mutex_t lock
Definition: default_engine.h:93
NUM_VBUCKETS
#define NUM_VBUCKETS
Definition: default_engine.h:102