Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions doc/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ not part of the repository.
| measured | release / ref | commit | pack time | pack peak RSS | unpack time | unpack peak RSS |
|---|---|---|---|---|---|---|
| 2026-11-22 | v1.1.1 | `603993d` | 3.557 s | 851.6 MiB | 4.442 s | 768.8 MiB |
| 2026-11-22 | main | `0bdcdc5` | 3.537 s | 926.6 MiB | 4.343 s | 781.0 MiB |

A second, pack-only run on the same machine measured main at 3.632 s / 890.4 MiB
(v1.1.1: 3.559 s / 857.8 MiB). Pack peak RSS is therefore roughly 4-9% above
v1.1.1 across runs while wall time stays flat. This drift is tracked in #93 and
is likely related to the metadata compression buffers added after v1.1.1; treat
the v1.1.1 -> main memory row as a known open item, not a finished comparison.
| 2026-11-22 | main (pre-#93) | `0bdcdc5` | 3.537 s | 926.6 MiB | 4.343 s | 781.0 MiB |
| 2026-11-22 | main (post-#93) | `afdeb6b` | 3.61-3.74 s | 852-878 MiB | - | - |

A second pack-only run measured the pre-#93 main at 3.632 s / 890.4 MiB
(v1.1.1: 3.559 s / 857.8 MiB). #93 traced the ~4-9% pack-RSS drift to redundant
metadata copies during packing and fixed it in `afdeb6b`. After the fix, pack
peak RSS measured 852-878 MiB across three 10-run comparisons (v1.1.1 baseline:
838-854 MiB). The allocation reduction is visible in the code, but this
machine's run-to-run RSS noise is around +/-20 MiB; replace the post-#93 row
with the next release measurement.

## Updating

Expand Down
24 changes: 16 additions & 8 deletions src/core/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,22 +784,29 @@ namespace ctar
}
metadata_checksum_ = XXH64(meta_buffer.data(), meta_buffer.size(), kHashSeed);

std::string stored_meta = meta_buffer;
// The uncompressed bytes are written directly when metadata compression is
// disabled or does not shrink. The compression destination is raw memory:
// zero-filling a std::string of the worst-case size committed ~29 MiB of
// metadata to RSS even though the compressed output was only ~7 MiB (#93).
std::unique_ptr<char[]> compressed_meta;
const char* stored_metadata = meta_buffer.data();
uint64_t stored_metadata_size = meta_buffer.size();
if (compress_metadata)
{
stored_meta.assign(static_cast<size_t>(max_metadata_size), '\0');
const uint64_t compressed_size = compress::Compress(metadata_type, meta_buffer.data(), stored_meta.data(),
compressed_meta = std::make_unique_for_overwrite<char[]>(static_cast<size_t>(max_metadata_size));
const uint64_t compressed_size = compress::Compress(metadata_type, meta_buffer.data(), compressed_meta.get(),
raw_meta_size, compression_param);
if (compressed_size > 0 && compressed_size < raw_meta_size)
{
stored_meta.resize(static_cast<size_t>(compressed_size));
stored_metadata = compressed_meta.get();
stored_metadata_size = compressed_size;
metadata_compressed_size_ = compressed_size;
metadata_compressed_type_ = static_cast<uint64_t>(metadata_type);
}
else
{
// Compression did not help; keep the uncompressed bytes.
stored_meta = meta_buffer;
// Compression did not help; write the uncompressed bytes.
compressed_meta.reset();
}
}

Expand Down Expand Up @@ -838,9 +845,10 @@ namespace ctar
fs::remove(output_pack_file);
return status;
}
if (!stored_meta.empty())
if (stored_metadata_size > 0)
{
status = write_file->RandomWrite(static_cast<off_t>(metadata_offset), stored_meta.size(), stored_meta.data());
status = write_file->RandomWrite(static_cast<off_t>(metadata_offset),
static_cast<size_t>(stored_metadata_size), stored_metadata);
if (!status)
{
fs::remove(output_pack_file);
Expand Down
Loading