Skip to content

fix: keep duplicate archive metadata consistent with first content - #1159

Open
helly25 wants to merge 1 commit into
mainfrom
perf/first-archive-member-metadata-20261109
Open

helly25 wants to merge 1 commit into
mainfrom
perf/first-archive-member-metadata-20261109

Conversation

@helly25

@helly25 helly25 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Keep an archive member's metadata consistent with its contents when multiple stored entries normalize to the same path. Previously, a one-byte first entry followed by an eleven-byte duplicate was listed as eleven bytes while reading back the first entry's one byte.

AG;DR

The archive index now retains the first explicit stored header for a normalized member name, matching the existing content-reader selection. A synthesized ancestor remains replaceable by its first explicit stored header. Later duplicates do not replace its type, size, mode, link target or other indexed metadata.

Implementation and scope:

  • Add a guard to the existing map insertion; preserve ancestor creation, direct-child counts, unique listings, synthetic inode allocation sequence and immutable read-source behavior. No new cache, allocation, lock or user option.
  • Express the existing negative-size-to-zero clamp with std::max to keep the indexing function within the existing cognitive-complexity limit. Negative/unknown size semantics remain unchanged.
  • Add one dedicated cc_test with six ASCII regression cases covering first file size/content/metadata observations, file versus directory collisions in both orders, symlink versus file collisions, first symlink target, and synthesized-parent replacement followed by a duplicate.
  • Document reader duplicate selection in the archive guide and changelog, and track this completed correctness prerequisite under O19b4a. Packing collision and archive-rewrite policies are unchanged.

Evidence and validation:

  • Reproduced the mismatch in actual main and perf: prepare streamed archive member names once #1158 native binaries before changing the index; all six new tests fail against exact main base 81f5d87315bf0cb49751ed9f0d3d75cf50a81946 on Mac, with production sources unchanged.
  • Exact normally signed commit 10aa4309c7fd1f6ebe27ce0630ca3475362cfbe5 passes all 346 configured release targets on this Mac and drogon Linux. Bazel reuse is limited to unchanged declared inputs; eleven affected suites were also freshly executed on each host.
  • Eleven affected suites freshly pass ASan and TSan on both hosts and MSan on Linux. The Ubuntu 26 development host uses the already documented test-only LLVM 23 LLD selection with the existing LLVM 22 MSan compiler and matching instrumented libc++; production build configuration is unchanged.
  • Both actual changed translation units pass scoped clang-tidy on both hosts. The compile commands come from the configured Bazel actions. Normal signed commit and push hooks pass.
  • Source hashes remain unchanged through qualification, and the signed source bundle was independently verified on Linux. These checks are scoped to their recorded revision, not another PR's status.

This is a correctness prerequisite discovered while investigating validated TAR payload locators: a locator must not pair the first member's bytes with a later duplicate's size. The locator optimization and its performance evaluation remain separate open work; no speedup is claimed for this fix.

Base: main 81f5d87315bf0cb49751ed9f0d3d75cf50a81946 after #1158. The resulting main Test/Benchmarks workflows are running with no observed failed jobs; this PR receives its own current-head Test workflow 42693049145, which is now running.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Benchmark preview

Advisory: changes over 15% are warnings, not merge failures. Positive reference-adjusted change means slower; negative means faster.

linux

Performance overview

No compatible comparison exceeds the 15% slowdown threshold. Advisory only.

Merged baseline: 91437fe; run 42669097757, attempt 2; mean of fastest 7/9 runs.

Compatible comparisons: 360/360; unavailable: 0.

Population Comparisons Typical change Faster Within threshold Slower
All matched cases 360 -0.8% 2 358 0

Largest regressions:

Task Tree Workers Files Reference Change
fuzzy-discovery-itm deep 3 1,000 find+fzf +10.1%
content-needle deep 3 200 rg +9.0%
files broad 3 10,000 rg +8.7%
content-absent_marker deep 3 100 rg +7.0%
content-absent_marker broad 3 200 rg +6.9%

Typical change is an equal-weight geometric mean of reference-adjusted XFF/main factors. Negative is faster; positive is slower. These correlated cases are not a significance test.

Interactive preview | CI run

Tested merge 292293b2ed; PR #1159 head 10aa4309c7.

macos

Performance overview

No compatible merged baseline comparisons are available; regression status is unknown. Advisory only.

Merged baseline: unavailable.

Compatible comparisons: 0/360; unavailable: 360.

Population Comparisons Typical change Faster Within threshold Slower
All matched cases 0 n/a 0 0 0

Typical change is an equal-weight geometric mean of reference-adjusted XFF/main factors. Negative is faster; positive is slower. These correlated cases are not a significance test.

Interactive preview | CI run

Tested merge 292293b2ed; PR #1159 head 10aa4309c7.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant