MySQL  8.0.17
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
const void * item_get_key(const hash_item *item)
Definition: default_engine.c:718
Definition: slabs.h:31
Definition: items.h:8
Definition: assoc.h:4
SERVER_HANDLE_V1 server
Definition: default_engine.h:111
Definition: default_engine.h:52
void * handle
Definition: engine_loader.c:19
rel_time_t oldest_live
Definition: default_engine.h:55
pthread_mutex_t lock
Definition: default_engine.h:93
static SERVER_HANDLE_V1 * get_server_api(void)
Callback the engines may call to get the public server interface.
Definition: memcached.c:6871
uint64_t visited
Definition: default_engine.h:86
struct engine_scrubber scrubber
Definition: default_engine.h:131
Definition: default_engine.h:98
pthread_mutex_t lock
Definition: default_engine.h:84
time_t stopped
Definition: default_engine.h:89
uint64_t item_get_cas(const hash_item *item)
Definition: default_engine.c:701
bool initialized
Is the engine initalized or not.
Definition: default_engine.h:117
void item_set_cas(ENGINE_HANDLE *handle, const void *cookie, item *item, uint64_t val)
Definition: default_engine.c:709
uint64_t reclaimed
Definition: default_engine.h:77
GET_SERVER_API get_server_api
Definition: default_engine.h:112
Statistic information collected by the default engine.
Definition: default_engine.h:74
uint64_t curr_items
Definition: default_engine.h:79
size_t chunk_size
Definition: default_engine.h:60
time_t started
Definition: default_engine.h:88
char vbucket_infos[NUM_VBUCKETS]
Definition: default_engine.h:140
engine_info engine_info
Definition: default_engine.h:135
ENGINE_HANDLE_V1 engine
Definition: default_engine.h:110
size_t maxbytes
Definition: default_engine.h:57
pthread_mutex_t cache_lock
The cache layer (item_* and assoc_*) is currently protected by this single mutex. ...
Definition: default_engine.h:127
union default_engine::@12 info
int state
Definition: default_engine.h:99
#define NUM_VBUCKETS
Definition: default_engine.h:102
Definition: default_engine.h:92
bool evict_to_free
Definition: default_engine.h:56
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
const void ** clients
Definition: default_engine.h:95
bool use_cas
Definition: default_engine.h:53
uint64_t cleaned
Definition: default_engine.h:87
bool ignore_vbucket
Definition: default_engine.h:62
float factor
Definition: default_engine.h:59
Definition of the private instance data used by the default engine.
Definition: default_engine.h:109
Global stats.
Definition: mysqlslap.cc:228
uint64_t total_items
Definition: default_engine.h:80
size_t verbose
Definition: default_engine.h:54
size_t item_size_max
Definition: default_engine.h:61
bool vb0
Definition: default_engine.h:63
Definition: default_engine.h:83
uint64_t evictions
Definition: default_engine.h:76
bool preallocate
Definition: default_engine.h:58
size_t size
Definition: default_engine.h:94
char buffer[sizeof(engine_info)+(sizeof(feature_info) *LAST_REGISTERED_ENGINE_FEATURE)]
Definition: default_engine.h:137
uint64_t curr_bytes
Definition: default_engine.h:78
uint8_t item_get_clsid(const hash_item *item)
Definition: default_engine.c:733
pthread_mutex_t lock
Definition: default_engine.h:75
char * item_get_data(const hash_item *item)
Definition: default_engine.c:728
Definition: items.h:34
bool running
Definition: default_engine.h:85