168957214STrond Norbye/*
268957214STrond Norbye * Copyright (c) <2008>, Sun Microsystems, Inc.
368957214STrond Norbye * All rights reserved.
468957214STrond Norbye *
568957214STrond Norbye * Redistribution and use in source and binary forms, with or without
668957214STrond Norbye * modification, are permitted provided that the following conditions are met:
768957214STrond Norbye *     * Redistributions of source code must retain the above copyright
868957214STrond Norbye *       notice, this list of conditions and the following disclaimer.
968957214STrond Norbye *     * Redistributions in binary form must reproduce the above copyright
1068957214STrond Norbye *       notice, this list of conditions and the following disclaimer in the
1168957214STrond Norbye *       documentation and/or other materials provided with the distribution.
1268957214STrond Norbye *     * Neither the name of the  nor the
1368957214STrond Norbye *       names of its contributors may be used to endorse or promote products
1468957214STrond Norbye *       derived from this software without specific prior written permission.
1568957214STrond Norbye *
1668957214STrond Norbye * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY
1768957214STrond Norbye * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1868957214STrond Norbye * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1968957214STrond Norbye * DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY
2068957214STrond Norbye * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2168957214STrond Norbye * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2268957214STrond Norbye * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2368957214STrond Norbye * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2468957214STrond Norbye * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25f46e5e0fSMatt Ingenthron * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2668957214STrond Norbye */
2768957214STrond Norbyeprovider memcached {
2868957214STrond Norbye   /**
29f46e5e0fSMatt Ingenthron    * Fired when a connection object is allocated from the connection pool.
3068957214STrond Norbye    * @param connid the connection id
3168957214STrond Norbye    */
3268957214STrond Norbye   probe conn__allocate(int connid);
3368957214STrond Norbye
3468957214STrond Norbye   /**
35f46e5e0fSMatt Ingenthron    * Fired when a connection object is released back to the connection pool.
3668957214STrond Norbye    * @param connid the connection id
3768957214STrond Norbye    */
3868957214STrond Norbye   probe conn__release(int connid);
3968957214STrond Norbye
4068957214STrond Norbye   /**
41f46e5e0fSMatt Ingenthron    * Fired when a new connection object is created (there are no more
42f46e5e0fSMatt Ingenthron    * connection objects in the connection pool).
4368957214STrond Norbye    * @param ptr pointer to the connection object
4468957214STrond Norbye    */
4568957214STrond Norbye   probe conn__create(void *ptr);
4668957214STrond Norbye
4768957214STrond Norbye   /**
48f46e5e0fSMatt Ingenthron    * Fired when a connection object is destroyed ("released back to
49f46e5e0fSMatt Ingenthron    * the memory subsystem").
5068957214STrond Norbye    * @param ptr pointer to the connection object
5168957214STrond Norbye    */
5268957214STrond Norbye   probe conn__destroy(void *ptr);
5368957214STrond Norbye
5468957214STrond Norbye   /**
5568957214STrond Norbye    * Fired when a connection is dispatched from the "main thread" to a
5668957214STrond Norbye    * worker thread.
5768957214STrond Norbye    * @param connid the connection id
5868957214STrond Norbye    * @param threadid the thread id
5968957214STrond Norbye    */
6068957214STrond Norbye   probe conn__dispatch(int connid, int threadid);
6168957214STrond Norbye
6268957214STrond Norbye   /**
63f46e5e0fSMatt Ingenthron    * Allocate memory from the slab allocator.
6468957214STrond Norbye    * @param size the requested size
6568957214STrond Norbye    * @param slabclass the allocation will be fulfilled in this class
6668957214STrond Norbye    * @param slabsize the size of each item in this class
6768957214STrond Norbye    * @param ptr pointer to allocated memory
6868957214STrond Norbye    */
6968957214STrond Norbye   probe slabs__allocate(int size, int slabclass, int slabsize, void* ptr);
7068957214STrond Norbye
7168957214STrond Norbye   /**
72f46e5e0fSMatt Ingenthron    * Failed to allocate memory (out of memory).
7368957214STrond Norbye    * @param size the requested size
7468957214STrond Norbye    * @param slabclass the class that failed to fulfill the request
7568957214STrond Norbye    */
7668957214STrond Norbye   probe slabs__allocate__failed(int size, int slabclass);
7768957214STrond Norbye
7868957214STrond Norbye   /**
79f46e5e0fSMatt Ingenthron    * Fired when a slab class attempts to allocate more space.
8068957214STrond Norbye    * @param slabclass class that needs more memory
8168957214STrond Norbye    */
8268957214STrond Norbye   probe slabs__slabclass__allocate(int slabclass);
8368957214STrond Norbye
8468957214STrond Norbye   /**
85f46e5e0fSMatt Ingenthron    * Failed to allocate memory (out of memory).
8668957214STrond Norbye    * @param slabclass the class that failed grab more memory
8768957214STrond Norbye    */
8868957214STrond Norbye   probe slabs__slabclass__allocate__failed(int slabclass);
8968957214STrond Norbye
9068957214STrond Norbye   /**
91f46e5e0fSMatt Ingenthron    * Release memory.
9268957214STrond Norbye    * @param size the size of the memory
9368957214STrond Norbye    * @param slabclass the class the memory belongs to
9468957214STrond Norbye    * @param ptr pointer to the memory to release
9568957214STrond Norbye    */
9668957214STrond Norbye   probe slabs__free(int size, int slabclass, void* ptr);
9768957214STrond Norbye
9868957214STrond Norbye   /**
9968957214STrond Norbye    * Fired when the when we have searched the hash table for a named key.
10068957214STrond Norbye    * These two elements provide an insight in how well the hash function
10168957214STrond Norbye    * functions. Long traversals are a sign of a less optimal function,
10268957214STrond Norbye    * wasting cpu capacity.
10368957214STrond Norbye    *
10468957214STrond Norbye    * @param key the key searched for
105f46e5e0fSMatt Ingenthron    * @param keylen length of the key
10668957214STrond Norbye    * @param depth the depth in the list of hash table
10768957214STrond Norbye    */
10880ec0955STrond Norbye   probe assoc__find(const char *key, int keylen, int depth);
10968957214STrond Norbye
11068957214STrond Norbye   /**
11168957214STrond Norbye    * Fired when a new item has been inserted.
11268957214STrond Norbye    * @param key the key just inserted
113f46e5e0fSMatt Ingenthron    * @param keylen length of the key
114f46e5e0fSMatt Ingenthron    * @param nokeys the total number of keys currently stored,
11568957214STrond Norbye    *               including the key for which insert was called.
11668957214STrond Norbye    */
11780ec0955STrond Norbye   probe assoc__insert(const char *key, int keylen, int nokeys);
11868957214STrond Norbye
11968957214STrond Norbye   /**
12068957214STrond Norbye    * Fired when a new item has been removed.
12168957214STrond Norbye    * @param key the key just deleted
122f46e5e0fSMatt Ingenthron    * @param keylen length of the key
123f46e5e0fSMatt Ingenthron    * @param nokeys the total number of keys currently stored,
12468957214STrond Norbye    *               excluding the key for which delete was called.
12568957214STrond Norbye    */
12680ec0955STrond Norbye   probe assoc__delete(const char *key, int keylen, int nokeys);
12768957214STrond Norbye
12868957214STrond Norbye   /**
129f46e5e0fSMatt Ingenthron    * Fired when an item is linked into the cache.
13068957214STrond Norbye    * @param key the items key
131f46e5e0fSMatt Ingenthron    * @param keylen length of the key
13268957214STrond Norbye    * @param size the size of the data
13368957214STrond Norbye    */
13480ec0955STrond Norbye   probe item__link(const char *key, int keylen, int size);
13568957214STrond Norbye
13668957214STrond Norbye   /**
137f46e5e0fSMatt Ingenthron    * Fired when an item is deleted.
13868957214STrond Norbye    * @param key the items key
139f46e5e0fSMatt Ingenthron    * @param keylen length of the key
14068957214STrond Norbye    * @param size the size of the data
14168957214STrond Norbye    */
14280ec0955STrond Norbye   probe item__unlink(const char *key, int keylen, int size);
14368957214STrond Norbye
14468957214STrond Norbye   /**
145f46e5e0fSMatt Ingenthron    * Fired when the refcount for an item is reduced.
14668957214STrond Norbye    * @param key the items key
147f46e5e0fSMatt Ingenthron    * @param keylen length of the key
14868957214STrond Norbye    * @param size the size of the data
14968957214STrond Norbye    */
15080ec0955STrond Norbye   probe item__remove(const char *key, int keylen, int size);
15168957214STrond Norbye
15268957214STrond Norbye   /**
153f46e5e0fSMatt Ingenthron    * Fired when the "last refenced" time is updated.
15468957214STrond Norbye    * @param key the items key
155f46e5e0fSMatt Ingenthron    * @param keylen length of the key
15668957214STrond Norbye    * @param size the size of the data
15768957214STrond Norbye    */
15880ec0955STrond Norbye   probe item__update(const char *key, int keylen, int size);
15968957214STrond Norbye
16068957214STrond Norbye   /**
161f46e5e0fSMatt Ingenthron    * Fired when an item is replaced with another item.
16268957214STrond Norbye    * @param oldkey the key of the item to replace
16380ec0955STrond Norbye    * @param oldkeylen the length of the old key
16468957214STrond Norbye    * @param oldsize the size of the old item
16568957214STrond Norbye    * @param newkey the key of the new item
16680ec0955STrond Norbye    * @param newkeylen the length of the new key
16768957214STrond Norbye    * @param newsize the size of the new item
16868957214STrond Norbye    */
16980ec0955STrond Norbye   probe item__replace(const char *oldkey, int oldkeylen, int oldsize,
17080ec0955STrond Norbye                       const char *newkey, int newkeylen, int newsize);
17168957214STrond Norbye
17268957214STrond Norbye   /**
173f46e5e0fSMatt Ingenthron    * Fired when the processing of a command starts.
17468957214STrond Norbye    * @param connid the connection id
17568957214STrond Norbye    * @param request the incomming request
17668957214STrond Norbye    * @param size the size of the request
17768957214STrond Norbye    */
17868957214STrond Norbye   probe process__command__start(int connid, const void *request, int size);
17968957214STrond Norbye
18068957214STrond Norbye   /**
181f46e5e0fSMatt Ingenthron    * Fired when the processing of a command is done.
18268957214STrond Norbye    * @param connid the connection id
18368957214STrond Norbye    * @param respnse the response to send back to the client
18468957214STrond Norbye    * @param size the size of the response
18568957214STrond Norbye    */
18668957214STrond Norbye   probe process__command__end(int connid, const void *response, int size);
18768957214STrond Norbye
18868957214STrond Norbye   /**
18968957214STrond Norbye    * Fired for a get-command
19068957214STrond Norbye    * @param connid connection id
19168957214STrond Norbye    * @param key requested key
192f46e5e0fSMatt Ingenthron    * @param keylen length of the key
193f46e5e0fSMatt Ingenthron    * @param size size of the key's data (or signed int -1 if not found)
19468957214STrond Norbye    * @param casid the casid for the item
19568957214STrond Norbye    */
19680ec0955STrond Norbye   probe command__get(int connid, const char *key, int keylen, int size, int64_t casid);
19768957214STrond Norbye
19868957214STrond Norbye   /**
199f46e5e0fSMatt Ingenthron    * Fired for an add-command.
20068957214STrond Norbye    * @param connid connection id
20168957214STrond Norbye    * @param key requested key
202f46e5e0fSMatt Ingenthron    * @param keylen length of the key
203f46e5e0fSMatt Ingenthron    * @param size the new size of the key's data (or signed int -1 if
204f46e5e0fSMatt Ingenthron    *             not found)
20580ec0955STrond Norbye    * @param casid the casid for the item
20668957214STrond Norbye    */
20780ec0955STrond Norbye   probe command__add(int connid, const char *key, int keylen, int size, int64_t casid);
20868957214STrond Norbye
20968957214STrond Norbye   /**
210f46e5e0fSMatt Ingenthron    * Fired for a set-command.
21168957214STrond Norbye    * @param connid connection id
21268957214STrond Norbye    * @param key requested key
213f46e5e0fSMatt Ingenthron    * @param keylen length of the key
214f46e5e0fSMatt Ingenthron    * @param size the new size of the key's data (or signed int -1 if
215f46e5e0fSMatt Ingenthron    *             not found)
21680ec0955STrond Norbye    * @param casid the casid for the item
21768957214STrond Norbye    */
21880ec0955STrond Norbye   probe command__set(int connid, const char *key, int keylen, int size, int64_t casid);
21968957214STrond Norbye
22068957214STrond Norbye   /**
221f46e5e0fSMatt Ingenthron    * Fired for a replace-command.
22268957214STrond Norbye    * @param connid connection id
22368957214STrond Norbye    * @param key requested key
224f46e5e0fSMatt Ingenthron    * @param keylen length of the key
225f46e5e0fSMatt Ingenthron    * @param size the new size of the key's data (or signed int -1 if
226f46e5e0fSMatt Ingenthron    *             not found)
22780ec0955STrond Norbye    * @param casid the casid for the item
22868957214STrond Norbye    */
22980ec0955STrond Norbye   probe command__replace(int connid, const char *key, int keylen, int size, int64_t casid);
23068957214STrond Norbye
23168957214STrond Norbye   /**
232f46e5e0fSMatt Ingenthron    * Fired for a prepend-command.
23368957214STrond Norbye    * @param connid connection id
23468957214STrond Norbye    * @param key requested key
235f46e5e0fSMatt Ingenthron    * @param keylen length of the key
236f46e5e0fSMatt Ingenthron    * @param size the new size of the key's data (or signed int -1 if
237f46e5e0fSMatt Ingenthron    *             not found)
23880ec0955STrond Norbye    * @param casid the casid for the item
23968957214STrond Norbye    */
24080ec0955STrond Norbye   probe command__prepend(int connid, const char *key, int keylen, int size, int64_t casid);
24168957214STrond Norbye
24268957214STrond Norbye   /**
243f46e5e0fSMatt Ingenthron    * Fired for an append-command.
24468957214STrond Norbye    * @param connid connection id
24568957214STrond Norbye    * @param key requested key
246f46e5e0fSMatt Ingenthron    * @param keylen length of the key
247f46e5e0fSMatt Ingenthron    * @param size the new size of the key's data (or signed int -1 if
248f46e5e0fSMatt Ingenthron    *             not found)
24980ec0955STrond Norbye    * @param casid the casid for the item
25068957214STrond Norbye    */
25180ec0955STrond Norbye   probe command__append(int connid, const char *key, int keylen, int size, int64_t casid);
25268957214STrond Norbye
25368957214STrond Norbye   /**
254f46e5e0fSMatt Ingenthron    * Fired for a cas-command.
25568957214STrond Norbye    * @param connid connection id
25668957214STrond Norbye    * @param key requested key
257f46e5e0fSMatt Ingenthron    * @param keylen length of the key
258f46e5e0fSMatt Ingenthron    * @param size size of the key's data (or signed int -1 if not found)
25968957214STrond Norbye    * @param casid the cas id requested
26068957214STrond Norbye    */
26180ec0955STrond Norbye   probe command__cas(int connid, const char *key, int keylen, int size, int64_t casid);
26268957214STrond Norbye
26368957214STrond Norbye   /**
264f46e5e0fSMatt Ingenthron    * Fired for an incr command.
26568957214STrond Norbye    * @param connid connection id
26668957214STrond Norbye    * @param key the requested key
267f46e5e0fSMatt Ingenthron    * @param keylen length of the key
26868957214STrond Norbye    * @param val the new value
26968957214STrond Norbye    */
27080ec0955STrond Norbye   probe command__incr(int connid, const char *key, int keylen, int64_t val);
27168957214STrond Norbye
27268957214STrond Norbye   /**
273f46e5e0fSMatt Ingenthron    * Fired for a decr command.
27468957214STrond Norbye    * @param connid connection id
27568957214STrond Norbye    * @param key the requested key
276f46e5e0fSMatt Ingenthron    * @param keylen length of the key
27768957214STrond Norbye    * @param val the new value
27868957214STrond Norbye    */
27980ec0955STrond Norbye   probe command__decr(int connid, const char *key, int keylen, int64_t val);
28068957214STrond Norbye
28168957214STrond Norbye   /**
282f46e5e0fSMatt Ingenthron    * Fired for a delete command.
28368957214STrond Norbye    * @param connid connection id
28468957214STrond Norbye    * @param key the requested key
285f46e5e0fSMatt Ingenthron    * @param keylen length of the key
28668957214STrond Norbye    */
28780ec0955STrond Norbye   probe command__delete(int connid, const char *key, int keylen);
28868957214STrond Norbye
28968957214STrond Norbye};
29068957214STrond Norbye
29168957214STrond Norbye#pragma D attributes Unstable/Unstable/Common provider memcached provider
29268957214STrond Norbye#pragma D attributes Private/Private/Common provider memcached module
29368957214STrond Norbye#pragma D attributes Private/Private/Common provider memcached function
29468957214STrond Norbye#pragma D attributes Unstable/Unstable/Common provider memcached name
29568957214STrond Norbye#pragma D attributes Unstable/Unstable/Common provider memcached args
296