Coverage Report

Created: 2024-09-08 07:17

/src/rocksdb/util/ribbon_config.cc
Line
Count
Source (jump to first uncovered line)
1
//  Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2
//  This source code is licensed under both the GPLv2 (found in the
3
//  COPYING file in the root directory) and Apache 2.0 License
4
//  (found in the LICENSE.Apache file in the root directory).
5
6
#include "util/ribbon_config.h"
7
8
namespace ROCKSDB_NAMESPACE::ribbon::detail {
9
10
// Each instantiation of this struct is sufficiently unique for configuration
11
// purposes, and is only instantiated for settings where we support the
12
// configuration API. An application might only reference one instantiation,
13
// meaning the rest could be pruned at link time.
14
template <ConstructionFailureChance kCfc, uint64_t kCoeffBits, bool kUseSmash>
15
struct BandingConfigHelperData {
16
  static constexpr size_t kKnownSize = 18U;
17
18
  // Because of complexity in the data, for smaller numbers of slots
19
  // (powers of two up to 2^17), we record known numbers that can be added
20
  // with kCfc chance of construction failure and settings in template
21
  // parameters. Zero means "unsupported (too small) number of slots".
22
  // (GetNumToAdd below will use interpolation for numbers of slots
23
  // between powers of two; double rather than integer values here make
24
  // that more accurate.)
25
  static const std::array<double, kKnownSize> kKnownToAddByPow2;
26
27
  // For sufficiently large number of slots, doubling the number of
28
  // slots will increase the expected overhead (slots over number added)
29
  // by approximately this constant.
30
  // (This is roughly constant regardless of ConstructionFailureChance and
31
  // smash setting.)
32
  // (Would be a constant if we had partial template specialization for
33
  // static const members.)
34
0
  static inline double GetFactorPerPow2() {
35
0
    if (kCoeffBits == 128U) {
36
0
      return 0.0038;
37
0
    } else {
38
0
      assert(kCoeffBits == 64U);
39
0
      return 0.0083;
40
0
    }
41
0
  }
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false>::GetFactorPerPow2()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true>::GetFactorPerPow2()
42
43
  // Overhead factor for 2^(kKnownSize-1) slots
44
  // (Would be a constant if we had partial template specialization for
45
  // static const members.)
46
0
  static inline double GetFinalKnownFactor() {
47
0
    return 1.0 * (uint32_t{1} << (kKnownSize - 1)) /
48
0
           kKnownToAddByPow2[kKnownSize - 1];
49
0
  }
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false>::GetFinalKnownFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true>::GetFinalKnownFactor()
50
51
  // GetFinalKnownFactor() - (kKnownSize-1) * GetFactorPerPow2()
52
  // (Would be a constant if we had partial template specialization for
53
  // static const members.)
54
0
  static inline double GetBaseFactor() {
55
0
    return GetFinalKnownFactor() - (kKnownSize - 1) * GetFactorPerPow2();
56
0
  }
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false>::GetBaseFactor()
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true>::GetBaseFactor()
57
58
  // Get overhead factor (slots over number to add) for sufficiently large
59
  // number of slots (by log base 2)
60
0
  static inline double GetFactorForLarge(double log2_num_slots) {
61
0
    return GetBaseFactor() + log2_num_slots * GetFactorPerPow2();
62
0
  }
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false>::GetFactorForLarge(double)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true>::GetFactorForLarge(double)
63
64
  // For a given power of two number of slots (specified by whole number
65
  // log base 2), implements GetNumToAdd for such limited case, returning
66
  // double for better interpolation in GetNumToAdd and GetNumSlots.
67
0
  static inline double GetNumToAddForPow2(uint32_t log2_num_slots) {
68
0
    assert(log2_num_slots <= 32);  // help clang-analyze
69
0
    if (log2_num_slots < kKnownSize) {
70
0
      return kKnownToAddByPow2[log2_num_slots];
71
0
    } else {
72
0
      return 1.0 * (uint64_t{1} << log2_num_slots) /
73
0
             GetFactorForLarge(1.0 * log2_num_slots);
74
0
    }
75
0
  }
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false>::GetNumToAddForPow2(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelperData<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true>::GetNumToAddForPow2(unsigned int)
76
};
77
78
// Based on data from FindOccupancy in ribbon_test
79
template <>
80
const std::array<double, 18>
81
    BandingConfigHelperData<kOneIn2, 128U, false>::kKnownToAddByPow2{{
82
        0,
83
        0,
84
        0,
85
        0,
86
        0,
87
        0,
88
        0,
89
        0,  // unsupported
90
        252.984,
91
        506.109,
92
        1013.71,
93
        2029.47,
94
        4060.43,
95
        8115.63,
96
        16202.2,
97
        32305.1,
98
        64383.5,
99
        128274,
100
    }};
101
102
template <>
103
const std::array<double, 18>
104
    BandingConfigHelperData<kOneIn2, 128U, /*smash*/ true>::kKnownToAddByPow2{{
105
        0,
106
        0,
107
        0,
108
        0,
109
        0,
110
        0,
111
        0,  // unsupported
112
        126.274,
113
        254.279,
114
        510.27,
115
        1022.24,
116
        2046.02,
117
        4091.99,
118
        8154.98,
119
        16244.3,
120
        32349.7,
121
        64426.6,
122
        128307,
123
    }};
124
125
template <>
126
const std::array<double, 18>
127
    BandingConfigHelperData<kOneIn2, 64U, false>::kKnownToAddByPow2{{
128
        0,
129
        0,
130
        0,
131
        0,
132
        0,
133
        0,
134
        0,  // unsupported
135
        124.94,
136
        249.968,
137
        501.234,
138
        1004.06,
139
        2006.15,
140
        3997.89,
141
        7946.99,
142
        15778.4,
143
        31306.9,
144
        62115.3,
145
        123284,
146
    }};
147
148
template <>
149
const std::array<double, 18>
150
    BandingConfigHelperData<kOneIn2, 64U, /*smash*/ true>::kKnownToAddByPow2{{
151
        0,
152
        0,
153
        0,
154
        0,
155
        0,
156
        0,  // unsupported
157
        62.2683,
158
        126.259,
159
        254.268,
160
        509.975,
161
        1019.98,
162
        2026.16,
163
        4019.75,
164
        7969.8,
165
        15798.2,
166
        31330.3,
167
        62134.2,
168
        123255,
169
    }};
170
171
template <>
172
const std::array<double, 18>
173
    BandingConfigHelperData<kOneIn20, 128U, false>::kKnownToAddByPow2{{
174
        0,
175
        0,
176
        0,
177
        0,
178
        0,
179
        0,
180
        0,
181
        0,  // unsupported
182
        248.851,
183
        499.532,
184
        1001.26,
185
        2003.97,
186
        4005.59,
187
        8000.39,
188
        15966.6,
189
        31828.1,
190
        63447.3,
191
        126506,
192
    }};
193
194
template <>
195
const std::array<double, 18>
196
    BandingConfigHelperData<kOneIn20, 128U, /*smash*/ true>::kKnownToAddByPow2{{
197
        0,
198
        0,
199
        0,
200
        0,
201
        0,
202
        0,
203
        0,  // unsupported
204
        122.637,
205
        250.651,
206
        506.625,
207
        1018.54,
208
        2036.43,
209
        4041.6,
210
        8039.25,
211
        16005,
212
        31869.6,
213
        63492.8,
214
        126537,
215
    }};
216
217
template <>
218
const std::array<double, 18>
219
    BandingConfigHelperData<kOneIn20, 64U, false>::kKnownToAddByPow2{{
220
        0,
221
        0,
222
        0,
223
        0,
224
        0,
225
        0,
226
        0,  // unsupported
227
        120.659,
228
        243.346,
229
        488.168,
230
        976.373,
231
        1948.86,
232
        3875.85,
233
        7704.97,
234
        15312.4,
235
        30395.1,
236
        60321.8,
237
        119813,
238
    }};
239
240
template <>
241
const std::array<double, 18>
242
    BandingConfigHelperData<kOneIn20, 64U, /*smash*/ true>::kKnownToAddByPow2{{
243
        0,
244
        0,
245
        0,
246
        0,
247
        0,
248
        0,  // unsupported
249
        58.6016,
250
        122.619,
251
        250.641,
252
        503.595,
253
        994.165,
254
        1967.36,
255
        3898.17,
256
        7727.21,
257
        15331.5,
258
        30405.8,
259
        60376.2,
260
        119836,
261
    }};
262
263
template <>
264
const std::array<double, 18>
265
    BandingConfigHelperData<kOneIn1000, 128U, false>::kKnownToAddByPow2{{
266
        0,
267
        0,
268
        0,
269
        0,
270
        0,
271
        0,
272
        0,
273
        0,  // unsupported
274
        242.61,
275
        491.887,
276
        983.603,
277
        1968.21,
278
        3926.98,
279
        7833.99,
280
        15629,
281
        31199.9,
282
        62307.8,
283
        123870,
284
    }};
285
286
template <>
287
const std::array<double, 18> BandingConfigHelperData<
288
    kOneIn1000, 128U, /*smash*/ true>::kKnownToAddByPow2{{
289
    0,
290
    0,
291
    0,
292
    0,
293
    0,
294
    0,
295
    0,  // unsupported
296
    117.19,
297
    245.105,
298
    500.748,
299
    1010.67,
300
    1993.4,
301
    3950.01,
302
    7863.31,
303
    15652,
304
    31262.1,
305
    62462.8,
306
    124095,
307
}};
308
309
template <>
310
const std::array<double, 18>
311
    BandingConfigHelperData<kOneIn1000, 64U, false>::kKnownToAddByPow2{{
312
        0,
313
        0,
314
        0,
315
        0,
316
        0,
317
        0,
318
        0,  // unsupported
319
        114,
320
        234.8,
321
        471.498,
322
        940.165,
323
        1874,
324
        3721.5,
325
        7387.5,
326
        14592,
327
        29160,
328
        57745,
329
        115082,
330
    }};
331
332
template <>
333
const std::array<double, 18>
334
    BandingConfigHelperData<kOneIn1000, 64U, /*smash*/ true>::kKnownToAddByPow2{
335
        {
336
            0,
337
            0,
338
            0,
339
            0,
340
            0,
341
            0,  // unsupported
342
            53.0434,
343
            117,
344
            245.312,
345
            483.571,
346
            950.251,
347
            1878,
348
            3736.34,
349
            7387.97,
350
            14618,
351
            29142.9,
352
            57838.8,
353
            114932,
354
        }};
355
356
// We hide these implementation details from the .h file with explicit
357
// instantiations below these partial specializations.
358
359
template <ConstructionFailureChance kCfc, uint64_t kCoeffBits, bool kUseSmash,
360
          bool kHomogeneous>
361
uint32_t BandingConfigHelper1MaybeSupported<
362
    kCfc, kCoeffBits, kUseSmash, kHomogeneous,
363
0
    true /* kIsSupported */>::GetNumToAdd(uint32_t num_slots) {
364
0
  using Data = detail::BandingConfigHelperData<kCfc, kCoeffBits, kUseSmash>;
365
0
  if (num_slots == 0) {
366
0
    return 0;
367
0
  }
368
0
  uint32_t num_to_add;
369
0
  double log2_num_slots = std::log(num_slots) * 1.4426950409;
370
0
  uint32_t floor_log2 = static_cast<uint32_t>(log2_num_slots);
371
0
  if (floor_log2 + 1 < Data::kKnownSize) {
372
0
    double ceil_portion = 1.0 * num_slots / (uint32_t{1} << floor_log2) - 1.0;
373
    // Must be a supported number of slots
374
0
    assert(Data::kKnownToAddByPow2[floor_log2] > 0.0);
375
    // Weighted average of two nearest known data points
376
0
    num_to_add = static_cast<uint32_t>(
377
0
        ceil_portion * Data::kKnownToAddByPow2[floor_log2 + 1] +
378
0
        (1.0 - ceil_portion) * Data::kKnownToAddByPow2[floor_log2]);
379
0
  } else {
380
    // Use formula for large values
381
0
    double factor = Data::GetFactorForLarge(log2_num_slots);
382
0
    assert(factor >= 1.0);
383
0
    num_to_add = static_cast<uint32_t>(num_slots / factor);
384
0
  }
385
0
  if (kHomogeneous) {
386
    // Even when standard filter construction would succeed, we might
387
    // have loaded things up too much for Homogeneous filter. (Complete
388
    // explanation not known but observed empirically.) This seems to
389
    // correct for that, mostly affecting small filter configurations.
390
0
    if (num_to_add >= 8) {
391
0
      num_to_add -= 8;
392
0
    } else {
393
0
      assert(false);
394
0
    }
395
0
  }
396
0
  return num_to_add;
397
0
}
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true, false, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false, true, true>::GetNumToAdd(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true, true, true>::GetNumToAdd(unsigned int)
398
399
template <ConstructionFailureChance kCfc, uint64_t kCoeffBits, bool kUseSmash,
400
          bool kHomogeneous>
401
uint32_t BandingConfigHelper1MaybeSupported<
402
    kCfc, kCoeffBits, kUseSmash, kHomogeneous,
403
0
    true /* kIsSupported */>::GetNumSlots(uint32_t num_to_add) {
404
0
  using Data = detail::BandingConfigHelperData<kCfc, kCoeffBits, kUseSmash>;
405
406
0
  if (num_to_add == 0) {
407
0
    return 0;
408
0
  }
409
0
  if (kHomogeneous) {
410
    // Reverse of above in GetNumToAdd
411
0
    num_to_add += 8;
412
0
  }
413
0
  double log2_num_to_add = std::log(num_to_add) * 1.4426950409;
414
0
  uint32_t approx_log2_slots = static_cast<uint32_t>(log2_num_to_add + 0.5);
415
0
  assert(approx_log2_slots <= 32);  // help clang-analyze
416
417
0
  double lower_num_to_add = Data::GetNumToAddForPow2(approx_log2_slots);
418
0
  double upper_num_to_add;
419
0
  if (approx_log2_slots == 0 || lower_num_to_add == /* unsupported */ 0) {
420
    // Return minimum non-zero slots in standard implementation
421
0
    return kUseSmash ? kCoeffBits : 2 * kCoeffBits;
422
0
  } else if (num_to_add < lower_num_to_add) {
423
0
    upper_num_to_add = lower_num_to_add;
424
0
    --approx_log2_slots;
425
0
    lower_num_to_add = Data::GetNumToAddForPow2(approx_log2_slots);
426
0
  } else {
427
0
    upper_num_to_add = Data::GetNumToAddForPow2(approx_log2_slots + 1);
428
0
  }
429
430
0
  assert(num_to_add >= lower_num_to_add);
431
0
  assert(num_to_add < upper_num_to_add);
432
433
0
  double upper_portion =
434
0
      (num_to_add - lower_num_to_add) / (upper_num_to_add - lower_num_to_add);
435
436
0
  double lower_num_slots = 1.0 * (uint64_t{1} << approx_log2_slots);
437
438
  // Interpolation, round up
439
0
  return static_cast<uint32_t>(upper_portion * lower_num_slots +
440
0
                               lower_num_slots + 0.999999999);
441
0
}
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, false, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 128ul, true, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, false, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)0, 64ul, true, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, false, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 128ul, true, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, false, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)1, 64ul, true, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, false, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 128ul, true, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true, false, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, false, true, true>::GetNumSlots(unsigned int)
Unexecuted instantiation: rocksdb::ribbon::detail::BandingConfigHelper1MaybeSupported<(rocksdb::ribbon::ConstructionFailureChance)2, 64ul, true, true, true>::GetNumSlots(unsigned int)
442
443
// These explicit instantiations enable us to hide most of the
444
// implementation details from the .h file. (The .h file currently
445
// needs to determine whether settings are "supported" or not.)
446
447
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 128U, /*sm*/ false,
448
                                                   /*hm*/ false, /*sup*/ true>;
449
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 128U, /*sm*/ true,
450
                                                   /*hm*/ false, /*sup*/ true>;
451
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 128U, /*sm*/ false,
452
                                                   /*hm*/ true, /*sup*/ true>;
453
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 128U, /*sm*/ true,
454
                                                   /*hm*/ true, /*sup*/ true>;
455
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 64U, /*sm*/ false,
456
                                                   /*hm*/ false, /*sup*/ true>;
457
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 64U, /*sm*/ true,
458
                                                   /*hm*/ false, /*sup*/ true>;
459
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 64U, /*sm*/ false,
460
                                                   /*hm*/ true, /*sup*/ true>;
461
template struct BandingConfigHelper1MaybeSupported<kOneIn2, 64U, /*sm*/ true,
462
                                                   /*hm*/ true, /*sup*/ true>;
463
464
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 128U, /*sm*/ false,
465
                                                   /*hm*/ false, /*sup*/ true>;
466
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 128U, /*sm*/ true,
467
                                                   /*hm*/ false, /*sup*/ true>;
468
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 128U, /*sm*/ false,
469
                                                   /*hm*/ true, /*sup*/ true>;
470
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 128U, /*sm*/ true,
471
                                                   /*hm*/ true, /*sup*/ true>;
472
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 64U, /*sm*/ false,
473
                                                   /*hm*/ false, /*sup*/ true>;
474
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 64U, /*sm*/ true,
475
                                                   /*hm*/ false, /*sup*/ true>;
476
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 64U, /*sm*/ false,
477
                                                   /*hm*/ true, /*sup*/ true>;
478
template struct BandingConfigHelper1MaybeSupported<kOneIn20, 64U, /*sm*/ true,
479
                                                   /*hm*/ true, /*sup*/ true>;
480
481
template struct BandingConfigHelper1MaybeSupported<
482
    kOneIn1000, 128U, /*sm*/ false, /*hm*/ false, /*sup*/ true>;
483
template struct BandingConfigHelper1MaybeSupported<
484
    kOneIn1000, 128U, /*sm*/ true, /*hm*/ false, /*sup*/ true>;
485
template struct BandingConfigHelper1MaybeSupported<
486
    kOneIn1000, 128U, /*sm*/ false, /*hm*/ true, /*sup*/ true>;
487
template struct BandingConfigHelper1MaybeSupported<
488
    kOneIn1000, 128U, /*sm*/ true, /*hm*/ true, /*sup*/ true>;
489
template struct BandingConfigHelper1MaybeSupported<
490
    kOneIn1000, 64U, /*sm*/ false, /*hm*/ false, /*sup*/ true>;
491
template struct BandingConfigHelper1MaybeSupported<kOneIn1000, 64U, /*sm*/ true,
492
                                                   /*hm*/ false, /*sup*/ true>;
493
template struct BandingConfigHelper1MaybeSupported<
494
    kOneIn1000, 64U, /*sm*/ false, /*hm*/ true, /*sup*/ true>;
495
template struct BandingConfigHelper1MaybeSupported<kOneIn1000, 64U, /*sm*/ true,
496
                                                   /*hm*/ true, /*sup*/ true>;
497
498
}  // namespace ROCKSDB_NAMESPACE::ribbon::detail