]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/util/compression_context_cache.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / util / compression_context_cache.h
CommitLineData
11fdf7f2
TL
1// Copyright (c) 2011-present, Facebook, Inc. 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// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
6// Use of this source code is governed by a BSD-style license that can be
7// found in the LICENSE file. See the AUTHORS file for names of contributors.
8//
9
10// Compression context cache allows to cache compression/uncompression contexts
11// This helps with Random Read latencies and reduces CPU utilization
12// Caching is implemented using CoreLocal facility. Compression/Uncompression
13// instances are cached on a per core basis using CoreLocalArray. A borrowed
14// instance is atomically replaced with a sentinel value for the time of being
15// used. If it turns out that another thread is already makes use of the
16// instance we still create one on the heap which is later is destroyed.
17
18#pragma once
19
20#include <stdint.h>
21
f67539c2
TL
22#include "rocksdb/rocksdb_namespace.h"
23
24namespace ROCKSDB_NAMESPACE {
11fdf7f2
TL
25class ZSTDUncompressCachedData;
26
27class CompressionContextCache {
28 public:
29 // Singleton
30 static CompressionContextCache* Instance();
31 static void InitSingleton();
32 CompressionContextCache(const CompressionContextCache&) = delete;
33 CompressionContextCache& operator=(const CompressionContextCache&) = delete;
34
35 ZSTDUncompressCachedData GetCachedZSTDUncompressData();
36 void ReturnCachedZSTDUncompressData(int64_t idx);
37
38 private:
39 // Singleton
40 CompressionContextCache();
41 ~CompressionContextCache();
42
43 class Rep;
44 Rep* rep_;
45};
46
f67539c2 47} // namespace ROCKSDB_NAMESPACE