aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/include
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-04-26 10:12:03 +0200
committerGitHub Enterprise <[email protected]>2024-04-26 10:12:03 +0200
commitef1b4234c851131cf5a6d249684c14c5c27d2878 (patch)
treeafd972c077b2585c2dc336b79eb1d31d02372295 /src/zencore/include
parentfix oplog import during gcv2 (#62) (diff)
downloadzen-ef1b4234c851131cf5a6d249684c14c5c27d2878.tar.xz
zen-ef1b4234c851131cf5a6d249684c14c5c27d2878.zip
use direct file access for large file hash (#63)
- Improvement: Refactor `IoHash::HashBuffer` and `BLAKE3::HashBuffer` to not use memory mapped files. Performs better and saves ~10% of oplog export time on CI
Diffstat (limited to 'src/zencore/include')
-rw-r--r--src/zencore/include/zencore/blake3.h2
-rw-r--r--src/zencore/include/zencore/filesystem.h5
-rw-r--r--src/zencore/include/zencore/iobuffer.h2
-rw-r--r--src/zencore/include/zencore/iohash.h1
-rw-r--r--src/zencore/include/zencore/sharedbuffer.h5
5 files changed, 10 insertions, 5 deletions
diff --git a/src/zencore/include/zencore/blake3.h b/src/zencore/include/zencore/blake3.h
index b31b710a7..86d050e1a 100644
--- a/src/zencore/include/zencore/blake3.h
+++ b/src/zencore/include/zencore/blake3.h
@@ -11,6 +11,7 @@
namespace zen {
class CompositeBuffer;
+class IoBuffer;
class StringBuilderBase;
/**
@@ -23,6 +24,7 @@ struct BLAKE3
inline auto operator<=>(const BLAKE3& Rhs) const = default;
static BLAKE3 HashBuffer(const CompositeBuffer& Buffer);
+ static BLAKE3 HashBuffer(const IoBuffer& Buffer);
static BLAKE3 HashMemory(const void* Data, size_t ByteCount);
static BLAKE3 FromHexString(const char* String);
const char* ToHexString(char* OutString /* 40 characters + NUL terminator */) const;
diff --git a/src/zencore/include/zencore/filesystem.h b/src/zencore/include/zencore/filesystem.h
index 233941479..0aab6a4ae 100644
--- a/src/zencore/include/zencore/filesystem.h
+++ b/src/zencore/include/zencore/filesystem.h
@@ -78,6 +78,11 @@ ZENCORE_API void WriteFile(std::filesystem::path Path, const IoBuffer* const* Da
ZENCORE_API void WriteFile(std::filesystem::path Path, IoBuffer Data);
ZENCORE_API void WriteFile(std::filesystem::path Path, CompositeBuffer Data);
ZENCORE_API bool MoveToFile(std::filesystem::path Path, IoBuffer Data);
+ZENCORE_API void ScanFile(void* NativeHandle,
+ uint64_t Offset,
+ uint64_t Size,
+ uint64_t ChunkSize,
+ std::function<void(const void* Data, size_t Size)>&& ProcessFunc);
struct CopyFileOptions
{
diff --git a/src/zencore/include/zencore/iobuffer.h b/src/zencore/include/zencore/iobuffer.h
index dcf1b4db8..759a9b25e 100644
--- a/src/zencore/include/zencore/iobuffer.h
+++ b/src/zencore/include/zencore/iobuffer.h
@@ -442,8 +442,6 @@ public:
inline static IoBuffer MakeCloneFromMemory(MemoryView Memory) { return MakeCloneFromMemory(Memory.GetData(), Memory.GetSize()); }
};
-IoHash HashBuffer(IoBuffer& Buffer);
-
void iobuffer_forcelink();
} // namespace zen
diff --git a/src/zencore/include/zencore/iohash.h b/src/zencore/include/zencore/iohash.h
index 79ed8ea1c..c70e98e47 100644
--- a/src/zencore/include/zencore/iohash.h
+++ b/src/zencore/include/zencore/iohash.h
@@ -48,6 +48,7 @@ struct IoHash
static IoHash HashBuffer(const void* data, size_t byteCount);
static IoHash HashBuffer(MemoryView Data) { return HashBuffer(Data.GetData(), Data.GetSize()); }
static IoHash HashBuffer(const CompositeBuffer& Buffer);
+ static IoHash HashBuffer(const IoBuffer& Buffer);
static IoHash FromHexString(const char* string);
static IoHash FromHexString(const std::string_view string);
const char* ToHexString(char* outString /* 40 characters + NUL terminator */) const;
diff --git a/src/zencore/include/zencore/sharedbuffer.h b/src/zencore/include/zencore/sharedbuffer.h
index e31da27ec..9d77a2814 100644
--- a/src/zencore/include/zencore/sharedbuffer.h
+++ b/src/zencore/include/zencore/sharedbuffer.h
@@ -114,12 +114,11 @@ public:
[[nodiscard]] bool IsOwned() const { return !m_Buffer || m_Buffer->IsOwned(); }
[[nodiscard]] inline bool IsNull() const { return !m_Buffer; }
inline void Reset() { m_Buffer = nullptr; }
- inline bool IsFileReference() const
+ inline bool GetFileReference(IoBufferFileReference& OutRef) const
{
if (const IoBufferExtendedCore* Core = m_Buffer->ExtendedCore())
{
- IoBufferFileReference _;
- return Core->GetFileReference(_);
+ return Core->GetFileReference(OutRef);
}
else
{