From d020b6522b2d962db67f8a66410e74d61cf3da24 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 17 Sep 2024 15:05:40 +0200 Subject: gc performance improvements (#160) * optimized ValidateCbUInt * optimized iohash comparision * replace unordered set/map with tsl/robin set/map in blockstore * increase max buffer size when writing cache bucket sidecar * only store meta data for files < 4Gb * faster ReadAttachmentsFromMetaData * remove memcpy call in BlockStoreDiskLocation * only write cache bucket state to disk if GC deleted anything --- src/zencore/compactbinaryvalidation.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/zencore/compactbinaryvalidation.cpp') diff --git a/src/zencore/compactbinaryvalidation.cpp b/src/zencore/compactbinaryvalidation.cpp index db830d250..82738e678 100644 --- a/src/zencore/compactbinaryvalidation.cpp +++ b/src/zencore/compactbinaryvalidation.cpp @@ -86,23 +86,24 @@ ValidateCbFieldType(MemoryView& View, CbValidateMode Mode, CbValidateError& Erro static uint64_t ValidateCbUInt(MemoryView& View, CbValidateMode Mode, CbValidateError& Error) { - if (View.GetSize() > 0 && View.GetSize() >= MeasureVarUInt(View.GetData())) + size_t ViewSize = View.GetSize(); + if (ViewSize > 0) { - uint32_t ValueByteCount; - const uint64_t Value = ReadVarUInt(View.GetData(), ValueByteCount); - if (EnumHasAnyFlags(Mode, CbValidateMode::Format) && ValueByteCount > MeasureVarUInt(Value)) + uint32_t ValueByteCount = MeasureVarUInt(View.GetData()); + if (ViewSize >= ValueByteCount) { - AddError(Error, CbValidateError::InvalidInteger); + const uint64_t Value = ReadMeasuredVarUInt(View.GetData(), ValueByteCount); + if (EnumHasAnyFlags(Mode, CbValidateMode::Format) && ValueByteCount != MeasureVarUInt(Value)) + { + AddError(Error, CbValidateError::InvalidInteger); + } + View += ValueByteCount; + return Value; } - View += ValueByteCount; - return Value; - } - else - { - AddError(Error, CbValidateError::OutOfBounds); - View.Reset(); - return 0; } + AddError(Error, CbValidateError::OutOfBounds); + View.Reset(); + return 0; } /** -- cgit v1.2.3