aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-11-18 14:42:57 +0100
committerStefan Boberg <[email protected]>2021-11-18 14:43:08 +0100
commit4e90f777861faba2b17ceed6250bdb2493ebcefa (patch)
treeeb8bb583f2a98a21e4306e4c8e3929054c1d64b7
parentmerge from main (diff)
downloadzen-4e90f777861faba2b17ceed6250bdb2493ebcefa.tar.xz
zen-4e90f777861faba2b17ceed6250bdb2493ebcefa.zip
Fixed up some merge fallout
-rw-r--r--zenserver/cache/structuredcache.h1
-rw-r--r--zenserver/cache/structuredcachestore.cpp64
-rw-r--r--zenserver/cache/structuredcachestore.h85
3 files changed, 31 insertions, 119 deletions
diff --git a/zenserver/cache/structuredcache.h b/zenserver/cache/structuredcache.h
index a0215aa6e..9ee7da99b 100644
--- a/zenserver/cache/structuredcache.h
+++ b/zenserver/cache/structuredcache.h
@@ -18,6 +18,7 @@ namespace zen {
class CasStore;
class CidStore;
+class CbObjectView;
class ScrubContext;
class UpstreamCache;
class ZenCacheStore;
diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp
index 5cce7f325..44226457c 100644
--- a/zenserver/cache/structuredcachestore.cpp
+++ b/zenserver/cache/structuredcachestore.cpp
@@ -347,52 +347,44 @@ ZenCacheMemoryLayer::CacheBucket::Put(const IoHash& HashKey, const ZenCacheValue
//////////////////////////////////////////////////////////////////////////
-inline DiskLocation::DiskLocation() = default;
+#pragma pack(push)
+#pragma pack(1)
-inline DiskLocation::DiskLocation(uint64_t Offset, uint64_t ValueSize, uint32_t IndexSize, uint64_t Flags)
-: OffsetAndFlags(CombineOffsetAndFlags(Offset, Flags))
-, LowerSize(ValueSize & 0xFFFFffff)
-, IndexDataSize(IndexSize)
+struct DiskLocation
{
-}
+ inline DiskLocation() = default;
-inline uint64_t
-DiskLocation::CombineOffsetAndFlags(uint64_t Offset, uint64_t Flags)
-{
- return Offset | Flags;
-}
+ inline DiskLocation(uint64_t Offset, uint64_t ValueSize, uint32_t IndexSize, uint64_t Flags)
+ : OffsetAndFlags(CombineOffsetAndFlags(Offset, Flags))
+ , LowerSize(ValueSize & 0xFFFFffff)
+ , IndexDataSize(IndexSize)
+ {
+ }
-inline uint64_t
-DiskLocation::Offset() const
-{
- return OffsetAndFlags & kOffsetMask;
-}
+ static const uint64_t kOffsetMask = 0x0000'ffFF'ffFF'ffFFull;
+ static const uint64_t kSizeMask = 0x00FF'0000'0000'0000ull;
+ static const uint64_t kFlagsMask = 0xff00'0000'0000'0000ull;
+ static const uint64_t kStandaloneFile = 0x8000'0000'0000'0000ull;
+ static const uint64_t kStructured = 0x4000'0000'0000'0000ull;
+ static const uint64_t kTombStone = 0x2000'0000'0000'0000ull;
-inline uint64_t
-DiskLocation::Size() const
-{
- return LowerSize;
-}
+ static uint64_t CombineOffsetAndFlags(uint64_t Offset, uint64_t Flags) { return Offset | Flags; }
-inline uint64_t
-DiskLocation::IsFlagSet(uint64_t Flag) const
-{
- return OffsetAndFlags & Flag;
-}
+ inline uint64_t Offset() const { return OffsetAndFlags & kOffsetMask; }
+ inline uint64_t Size() const { return LowerSize; }
+ inline uint64_t IsFlagSet(uint64_t Flag) const { return OffsetAndFlags & Flag; }
+ inline ZenContentType GetContentType() const
+ {
+ ZenContentType ContentType = ZenContentType::kBinary;
-inline ZenContentType
-DiskLocation::GetContentType() const
-{
- ZenContentType ContentType = ZenContentType::kBinary;
+ if (IsFlagSet(DiskLocation::kStructured))
+ {
+ ContentType = ZenContentType::kCbObject;
+ }
- if (IsFlagSet(DiskLocation::kStructured))
- {
- ContentType = ZenContentType::kCbObject;
+ return ContentType;
}
- return ContentType;
-}
-
private:
uint64_t OffsetAndFlags = 0;
uint32_t LowerSize = 0;
diff --git a/zenserver/cache/structuredcachestore.h b/zenserver/cache/structuredcachestore.h
index 3040640f8..5627a314f 100644
--- a/zenserver/cache/structuredcachestore.h
+++ b/zenserver/cache/structuredcachestore.h
@@ -9,6 +9,7 @@
#include <zencore/uid.h>
#include <zenstore/basicfile.h>
#include <zenstore/cas.h>
+#include <zenstore/caslog.h>
#include <zenstore/gc.h>
ZEN_THIRD_PARTY_INCLUDES_START
@@ -104,42 +105,6 @@ private:
Configuration m_Configuration;
};
-#pragma pack(push)
-#pragma pack(1)
-
-struct DiskLocation
-{
- static const uint64_t kOffsetMask = 0x0000'ffFF'ffFF'ffFFull;
- static const uint64_t kSizeMask = 0x00FF'0000'0000'0000ull;
- static const uint64_t kFlagsMask = 0xff00'0000'0000'0000ull;
- static const uint64_t kStandaloneFile = 0x8000'0000'0000'0000ull;
- static const uint64_t kStructured = 0x4000'0000'0000'0000ull;
- static const uint64_t kTombStone = 0x2000'0000'0000'0000ull;
-
- DiskLocation();
- DiskLocation(uint64_t Offset, uint64_t ValueSize, uint32_t IndexSize, uint64_t Flags);
- static uint64_t CombineOffsetAndFlags(uint64_t Offset, uint64_t Flags);
- uint64_t Offset() const;
- uint64_t Size() const;
- uint64_t IsFlagSet(uint64_t Flag) const;
- ZenContentType GetContentType() const;
-
-private:
- uint64_t OffsetAndFlags = 0;
- uint32_t LowerSize = 0;
- uint32_t IndexDataSize = 0;
-};
-
-struct DiskIndexEntry
-{
- IoHash Key;
- DiskLocation Location;
-};
-
-#pragma pack(pop)
-
-static_assert(sizeof(DiskIndexEntry) == 36);
-
class ZenCacheDiskLayer
{
public:
@@ -159,53 +124,7 @@ private:
/** A cache bucket manages a single directory containing
metadata and data for that bucket
*/
- struct CacheBucket
- {
- CacheBucket();
- ~CacheBucket();
-
- void OpenOrCreate(std::filesystem::path BucketDir, bool AllowCreate = true);
- static bool Delete(std::filesystem::path BucketDir);
-
- bool Get(const IoHash& HashKey, ZenCacheValue& OutValue);
- void Put(const IoHash& HashKey, const ZenCacheValue& Value);
- void Drop();
- void Flush();
- void Scrub(ScrubContext& Ctx);
- void GarbageCollect(GcContext& GcCtx);
-
- inline bool IsOk() const { return m_IsOk; }
-
- private:
- std::filesystem::path m_BucketDir;
- Oid m_BucketId;
- bool m_IsOk = false;
- uint64_t m_LargeObjectThreshold = 64 * 1024;
-
- // These files are used to manage storage of small objects for this bucket
-
- BasicFile m_SobsFile;
- TCasLogFile<DiskIndexEntry> m_SlogFile;
-
- RwLock m_IndexLock;
- tsl::robin_map<IoHash, DiskLocation, IoHash::Hasher> m_Index;
- uint64_t m_WriteCursor = 0;
-
- void BuildPath(WideStringBuilderBase& Path, const IoHash& HashKey);
- void PutStandaloneCacheValue(const IoHash& HashKey, const ZenCacheValue& Value);
- bool GetStandaloneCacheValue(const DiskLocation& Loc, const IoHash& HashKey, ZenCacheValue& OutValue);
- bool GetInlineCacheValue(const DiskLocation& Loc, ZenCacheValue& OutValue);
-
- // These locks are here to avoid contention on file creation, therefore it's sufficient
- // that we take the same lock for the same hash
- //
- // These locks are small and should really be spaced out so they don't share cache lines,
- // but we don't currently access them at particularly high frequency so it should not be
- // an issue in practice
-
- RwLock m_ShardedLocks[256];
- inline RwLock& LockForHash(const IoHash& Hash) { return m_ShardedLocks[Hash.Hash[19]]; }
- };
+ struct CacheBucket;
std::filesystem::path m_RootDir;
RwLock m_Lock;