prometheus-client-mmap 0.20.3-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +253 -0
  3. data/ext/fast_mmaped_file/extconf.rb +30 -0
  4. data/ext/fast_mmaped_file/fast_mmaped_file.c +122 -0
  5. data/ext/fast_mmaped_file/file_format.c +5 -0
  6. data/ext/fast_mmaped_file/file_format.h +11 -0
  7. data/ext/fast_mmaped_file/file_parsing.c +195 -0
  8. data/ext/fast_mmaped_file/file_parsing.h +27 -0
  9. data/ext/fast_mmaped_file/file_reading.c +102 -0
  10. data/ext/fast_mmaped_file/file_reading.h +30 -0
  11. data/ext/fast_mmaped_file/globals.h +14 -0
  12. data/ext/fast_mmaped_file/mmap.c +427 -0
  13. data/ext/fast_mmaped_file/mmap.h +61 -0
  14. data/ext/fast_mmaped_file/rendering.c +199 -0
  15. data/ext/fast_mmaped_file/rendering.h +8 -0
  16. data/ext/fast_mmaped_file/utils.c +56 -0
  17. data/ext/fast_mmaped_file/utils.h +22 -0
  18. data/ext/fast_mmaped_file/value_access.c +242 -0
  19. data/ext/fast_mmaped_file/value_access.h +15 -0
  20. data/ext/fast_mmaped_file_rs/.cargo/config.toml +23 -0
  21. data/ext/fast_mmaped_file_rs/Cargo.lock +790 -0
  22. data/ext/fast_mmaped_file_rs/Cargo.toml +30 -0
  23. data/ext/fast_mmaped_file_rs/README.md +52 -0
  24. data/ext/fast_mmaped_file_rs/extconf.rb +30 -0
  25. data/ext/fast_mmaped_file_rs/src/error.rs +174 -0
  26. data/ext/fast_mmaped_file_rs/src/file_entry.rs +579 -0
  27. data/ext/fast_mmaped_file_rs/src/file_info.rs +190 -0
  28. data/ext/fast_mmaped_file_rs/src/lib.rs +79 -0
  29. data/ext/fast_mmaped_file_rs/src/macros.rs +14 -0
  30. data/ext/fast_mmaped_file_rs/src/map.rs +492 -0
  31. data/ext/fast_mmaped_file_rs/src/mmap.rs +151 -0
  32. data/ext/fast_mmaped_file_rs/src/parser.rs +346 -0
  33. data/ext/fast_mmaped_file_rs/src/raw_entry.rs +473 -0
  34. data/ext/fast_mmaped_file_rs/src/testhelper.rs +222 -0
  35. data/ext/fast_mmaped_file_rs/src/util.rs +121 -0
  36. data/lib/2.7/fast_mmaped_file.so +0 -0
  37. data/lib/2.7/fast_mmaped_file_rs.so +0 -0
  38. data/lib/3.0/fast_mmaped_file.so +0 -0
  39. data/lib/3.0/fast_mmaped_file_rs.so +0 -0
  40. data/lib/3.1/fast_mmaped_file.so +0 -0
  41. data/lib/3.1/fast_mmaped_file_rs.so +0 -0
  42. data/lib/3.2/fast_mmaped_file.so +0 -0
  43. data/lib/3.2/fast_mmaped_file_rs.so +0 -0
  44. data/lib/prometheus/client/configuration.rb +23 -0
  45. data/lib/prometheus/client/counter.rb +27 -0
  46. data/lib/prometheus/client/formats/text.rb +118 -0
  47. data/lib/prometheus/client/gauge.rb +40 -0
  48. data/lib/prometheus/client/helper/entry_parser.rb +132 -0
  49. data/lib/prometheus/client/helper/file_locker.rb +50 -0
  50. data/lib/prometheus/client/helper/json_parser.rb +23 -0
  51. data/lib/prometheus/client/helper/metrics_processing.rb +45 -0
  52. data/lib/prometheus/client/helper/metrics_representation.rb +51 -0
  53. data/lib/prometheus/client/helper/mmaped_file.rb +64 -0
  54. data/lib/prometheus/client/helper/plain_file.rb +29 -0
  55. data/lib/prometheus/client/histogram.rb +80 -0
  56. data/lib/prometheus/client/label_set_validator.rb +86 -0
  57. data/lib/prometheus/client/metric.rb +80 -0
  58. data/lib/prometheus/client/mmaped_dict.rb +79 -0
  59. data/lib/prometheus/client/mmaped_value.rb +154 -0
  60. data/lib/prometheus/client/page_size.rb +17 -0
  61. data/lib/prometheus/client/push.rb +203 -0
  62. data/lib/prometheus/client/rack/collector.rb +88 -0
  63. data/lib/prometheus/client/rack/exporter.rb +96 -0
  64. data/lib/prometheus/client/registry.rb +65 -0
  65. data/lib/prometheus/client/simple_value.rb +31 -0
  66. data/lib/prometheus/client/summary.rb +69 -0
  67. data/lib/prometheus/client/support/unicorn.rb +35 -0
  68. data/lib/prometheus/client/uses_value_type.rb +20 -0
  69. data/lib/prometheus/client/version.rb +5 -0
  70. data/lib/prometheus/client.rb +58 -0
  71. data/lib/prometheus.rb +3 -0
  72. data/vendor/c/hashmap/.gitignore +52 -0
  73. data/vendor/c/hashmap/LICENSE +21 -0
  74. data/vendor/c/hashmap/README.md +90 -0
  75. data/vendor/c/hashmap/_config.yml +1 -0
  76. data/vendor/c/hashmap/src/hashmap.c +692 -0
  77. data/vendor/c/hashmap/src/hashmap.h +267 -0
  78. data/vendor/c/hashmap/test/Makefile +22 -0
  79. data/vendor/c/hashmap/test/hashmap_test.c +608 -0
  80. data/vendor/c/jsmn/.travis.yml +4 -0
  81. data/vendor/c/jsmn/LICENSE +20 -0
  82. data/vendor/c/jsmn/Makefile +41 -0
  83. data/vendor/c/jsmn/README.md +168 -0
  84. data/vendor/c/jsmn/example/jsondump.c +126 -0
  85. data/vendor/c/jsmn/example/simple.c +76 -0
  86. data/vendor/c/jsmn/jsmn.c +314 -0
  87. data/vendor/c/jsmn/jsmn.h +76 -0
  88. data/vendor/c/jsmn/library.json +16 -0
  89. data/vendor/c/jsmn/test/test.h +27 -0
  90. data/vendor/c/jsmn/test/tests.c +407 -0
  91. data/vendor/c/jsmn/test/testutil.h +94 -0
  92. metadata +243 -0
@@ -0,0 +1,267 @@
1
+ /*
2
+ * Copyright (c) 2016-2017 David Leeds <davidesleeds@gmail.com>
3
+ *
4
+ * Hashmap is free software; you can redistribute it and/or modify
5
+ * it under the terms of the MIT license. See LICENSE for details.
6
+ */
7
+
8
+ #ifndef __HASHMAP_H__
9
+ #define __HASHMAP_H__
10
+
11
+ #include <stddef.h>
12
+
13
+ /*
14
+ * Define HASHMAP_METRICS to compile in performance analysis
15
+ * functions for use in assessing hash function performance.
16
+ */
17
+ /* #define HASHMAP_METRICS */
18
+
19
+ /*
20
+ * Define HASHMAP_NOASSERT to compile out all assertions used internally.
21
+ */
22
+ /* #define HASHMAP_NOASSERT */
23
+
24
+ /*
25
+ * Macros to declare type-specific versions of hashmap_*() functions to
26
+ * allow compile-time type checking and avoid the need for type casting.
27
+ */
28
+ #define HASHMAP_FUNCS_DECLARE(name, key_type, data_type) \
29
+ data_type *name##_hashmap_put(struct hashmap *map, key_type *key, \
30
+ data_type *data); \
31
+ data_type *name##_hashmap_get(const struct hashmap *map, \
32
+ key_type *key); \
33
+ data_type *name##_hashmap_remove(struct hashmap *map, \
34
+ key_type *key); \
35
+ key_type *name##_hashmap_iter_get_key( \
36
+ const struct hashmap_iter *iter); \
37
+ data_type *name##_hashmap_iter_get_data( \
38
+ const struct hashmap_iter *iter); \
39
+ void name##_hashmap_iter_set_data(const struct hashmap_iter *iter, \
40
+ data_type *data); \
41
+ int name##_hashmap_foreach(const struct hashmap *map, \
42
+ int (*func)(key_type *, data_type *, void *), void *arg);
43
+
44
+ #define HASHMAP_FUNCS_CREATE(name, key_type, data_type) \
45
+ data_type *name##_hashmap_put(struct hashmap *map, key_type *key, \
46
+ data_type *data) \
47
+ { \
48
+ return (data_type *)hashmap_put(map, (const void *)key, \
49
+ (void *)data); \
50
+ } \
51
+ data_type *name##_hashmap_get(const struct hashmap *map, \
52
+ key_type *key) \
53
+ { \
54
+ return (data_type *)hashmap_get(map, (const void *)key); \
55
+ } \
56
+ data_type *name##_hashmap_remove(struct hashmap *map, \
57
+ key_type *key) \
58
+ { \
59
+ return (data_type *)hashmap_remove(map, (const void *)key); \
60
+ } \
61
+ key_type *name##_hashmap_iter_get_key( \
62
+ const struct hashmap_iter *iter) \
63
+ { \
64
+ return (key_type *)hashmap_iter_get_key(iter); \
65
+ } \
66
+ data_type *name##_hashmap_iter_get_data( \
67
+ const struct hashmap_iter *iter) \
68
+ { \
69
+ return (data_type *)hashmap_iter_get_data(iter); \
70
+ } \
71
+ void name##_hashmap_iter_set_data(const struct hashmap_iter *iter, \
72
+ data_type *data) \
73
+ { \
74
+ hashmap_iter_set_data(iter, (void *)data); \
75
+ } \
76
+ struct __##name##_hashmap_foreach_state { \
77
+ int (*func)(key_type *, data_type *, void *); \
78
+ void *arg; \
79
+ }; \
80
+ static inline int __##name##_hashmap_foreach_callback(const void *key, \
81
+ void *data, void *arg) \
82
+ { \
83
+ struct __##name##_hashmap_foreach_state *s = \
84
+ (struct __##name##_hashmap_foreach_state *)arg; \
85
+ return s->func((key_type *)key, (data_type *)data, s->arg); \
86
+ } \
87
+ int name##_hashmap_foreach(const struct hashmap *map, \
88
+ int (*func)(key_type *, data_type *, void *), void *arg) \
89
+ { \
90
+ struct __##name##_hashmap_foreach_state s = { func, arg }; \
91
+ return hashmap_foreach(map, \
92
+ __##name##_hashmap_foreach_callback, &s); \
93
+ }
94
+
95
+
96
+ struct hashmap_iter;
97
+ struct hashmap_entry;
98
+
99
+ /*
100
+ * The hashmap state structure.
101
+ */
102
+ struct hashmap {
103
+ size_t table_size_init;
104
+ size_t table_size;
105
+ size_t num_entries;
106
+ struct hashmap_entry *table;
107
+ size_t (*hash)(const void *);
108
+ int (*key_compare)(const void *, const void *);
109
+ void *(*key_alloc)(const void *);
110
+ void (*key_free)(void *);
111
+ };
112
+
113
+ /*
114
+ * Initialize an empty hashmap. A hash function and a key comparator are
115
+ * required.
116
+ *
117
+ * hash_func should return an even distribution of numbers between 0
118
+ * and SIZE_MAX varying on the key provided.
119
+ *
120
+ * key_compare_func should return 0 if the keys match, and non-zero otherwise.
121
+ *
122
+ * initial_size is optional, and may be set to the max number of entries
123
+ * expected to be put in the hash table. This is used as a hint to
124
+ * pre-allocate the hash table to the minimum size to avoid gratuitous rehashes.
125
+ * If initial_size 0, a default size will be used.
126
+ *
127
+ * Returns 0 on success and -errno on failure.
128
+ */
129
+ int hashmap_init(struct hashmap *map, size_t (*hash_func)(const void *),
130
+ int (*key_compare_func)(const void *, const void *),
131
+ size_t initial_size);
132
+
133
+ /*
134
+ * Free the hashmap and all associated memory.
135
+ */
136
+ void hashmap_destroy(struct hashmap *map);
137
+
138
+ /*
139
+ * Enable internal memory allocation and management of hash keys.
140
+ */
141
+ void hashmap_set_key_alloc_funcs(struct hashmap *map,
142
+ void *(*key_alloc_func)(const void *),
143
+ void (*key_free_func)(void *));
144
+
145
+ /*
146
+ * Add an entry to the hashmap. If an entry with a matching key already
147
+ * exists and has a data pointer associated with it, the existing data
148
+ * pointer is returned, instead of assigning the new value. Compare
149
+ * the return value with the data passed in to determine if a new entry was
150
+ * created. Returns NULL if memory allocation failed.
151
+ */
152
+ void *hashmap_put(struct hashmap *map, const void *key, void *data);
153
+
154
+ /*
155
+ * Return the data pointer, or NULL if no entry exists.
156
+ */
157
+ void *hashmap_get(const struct hashmap *map, const void *key);
158
+
159
+ /*
160
+ * Remove an entry with the specified key from the map.
161
+ * Returns the data pointer, or NULL, if no entry was found.
162
+ */
163
+ void *hashmap_remove(struct hashmap *map, const void *key);
164
+
165
+ /*
166
+ * Remove all entries.
167
+ */
168
+ void hashmap_clear(struct hashmap *map);
169
+
170
+ /*
171
+ * Remove all entries and reset the hash table to its initial size.
172
+ */
173
+ void hashmap_reset(struct hashmap *map);
174
+
175
+ /*
176
+ * Return the number of entries in the hash map.
177
+ */
178
+ size_t hashmap_size(const struct hashmap *map);
179
+
180
+ /*
181
+ * Get a new hashmap iterator. The iterator is an opaque
182
+ * pointer that may be used with hashmap_iter_*() functions.
183
+ * Hashmap iterators are INVALID after a put or remove operation is performed.
184
+ * hashmap_iter_remove() allows safe removal during iteration.
185
+ */
186
+ struct hashmap_iter *hashmap_iter(const struct hashmap *map);
187
+
188
+ /*
189
+ * Return an iterator to the next hashmap entry. Returns NULL if there are
190
+ * no more entries.
191
+ */
192
+ struct hashmap_iter *hashmap_iter_next(const struct hashmap *map,
193
+ const struct hashmap_iter *iter);
194
+
195
+ /*
196
+ * Remove the hashmap entry pointed to by this iterator and returns an
197
+ * iterator to the next entry. Returns NULL if there are no more entries.
198
+ */
199
+ struct hashmap_iter *hashmap_iter_remove(struct hashmap *map,
200
+ const struct hashmap_iter *iter);
201
+
202
+ /*
203
+ * Return the key of the entry pointed to by the iterator.
204
+ */
205
+ const void *hashmap_iter_get_key(const struct hashmap_iter *iter);
206
+
207
+ /*
208
+ * Return the data of the entry pointed to by the iterator.
209
+ */
210
+ void *hashmap_iter_get_data(const struct hashmap_iter *iter);
211
+
212
+ /*
213
+ * Set the data pointer of the entry pointed to by the iterator.
214
+ */
215
+ void hashmap_iter_set_data(const struct hashmap_iter *iter, void *data);
216
+
217
+ /*
218
+ * Invoke func for each entry in the hashmap. Unlike the hashmap_iter_*()
219
+ * interface, this function supports calls to hashmap_remove() during iteration.
220
+ * However, it is an error to put or remove an entry other than the current one,
221
+ * and doing so will immediately halt iteration and return an error.
222
+ * Iteration is stopped if func returns non-zero. Returns func's return
223
+ * value if it is < 0, otherwise, 0.
224
+ */
225
+ int hashmap_foreach(const struct hashmap *map,
226
+ int (*func)(const void *, void *, void *), void *arg);
227
+
228
+ /*
229
+ * Default hash function for string keys.
230
+ * This is an implementation of the well-documented Jenkins one-at-a-time
231
+ * hash function.
232
+ */
233
+ size_t hashmap_hash_string(const void *key);
234
+
235
+ /*
236
+ * Default key comparator function for string keys.
237
+ */
238
+ int hashmap_compare_string(const void *a, const void *b);
239
+
240
+ /*
241
+ * Default key allocation function for string keys. Use free() for the
242
+ * key_free_func.
243
+ */
244
+ void *hashmap_alloc_key_string(const void *key);
245
+
246
+
247
+ #ifdef HASHMAP_METRICS
248
+ /*
249
+ * Return the load factor.
250
+ */
251
+ double hashmap_load_factor(const struct hashmap *map);
252
+
253
+ /*
254
+ * Return the average number of collisions per entry.
255
+ */
256
+ double hashmap_collisions_mean(const struct hashmap *map);
257
+
258
+ /*
259
+ * Return the variance between entry collisions. The higher the variance,
260
+ * the more likely the hash function is poor and is resulting in clustering.
261
+ */
262
+ double hashmap_collisions_variance(const struct hashmap *map);
263
+ #endif
264
+
265
+
266
+ #endif /* __HASHMAP_H__ */
267
+
@@ -0,0 +1,22 @@
1
+ TOP_DIR := $(CURDIR)/..
2
+ SRC_DIR := $(TOP_DIR)/src
3
+
4
+ TARGET_EXEC := hashmap_test
5
+
6
+ SOURCES := $(SRC_DIR)/hashmap.c hashmap_test.c
7
+
8
+ CFLAGS += -O0 -g -ggdb -Wall -Wunused -Werror -I$(SRC_DIR) -DHASHMAP_METRICS
9
+
10
+ OBJS := $(SOURCES:%.c=%.o)
11
+
12
+
13
+ test: $(TARGET_EXEC)
14
+
15
+ $(TARGET_EXEC): $(OBJS)
16
+ @echo EXEC $@ ; \
17
+ $(CC) -o $@ $(OBJS)
18
+
19
+ clean:
20
+ rm -f $(OBJS) $(TARGET_EXEC)
21
+
22
+ .PHONY: test clean