Skip to content

create --stats: populate bytes read/sent from store stats#9866

Merged
ThomasWaldmann merged 2 commits into
borgbackup:masterfrom
mr-raj12:create-stats-bytes-9405
Jul 7, 2026
Merged

create --stats: populate bytes read/sent from store stats#9866
ThomasWaldmann merged 2 commits into
borgbackup:masterfrom
mr-raj12:create-stats-bytes-9405

Conversation

@mr-raj12

@mr-raj12 mr-raj12 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

On borgstore-backed repositories, borg create --stats always printed "Bytes read/sent from remote: 0".

rx_bytes and tx_bytes only exist on the legacy RemoteRepository. A modern repository doesn't have them, so getattr(repository, "rx_bytes", 0) returned 0 every time.

Rather than pulling two numbers out of repository.store.stats, this now reports the full store stats dict: call counts and timings per operation, load/store volume and throughput, and cache hit/miss numbers. Each entry gets its own "Store : " line in --stats output, and the full dict is included under store_stats in --json.

The stats are sampled after the cache is closed, since Cache.close() writes the chunks index to the repo and that traffic should be counted too. The create epilog documents what the store stats mean.

fixes #9405

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

@mr-raj12 mr-raj12 force-pushed the create-stats-bytes-9405 branch from bbeda25 to 855478d Compare July 6, 2026 06:32
@ThomasWaldmann

Copy link
Copy Markdown
Member

I think the last pack should already get flushed before the archive pointer is created.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.12%. Comparing base (230f6ef) to head (54dede3).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9866      +/-   ##
==========================================
+ Coverage   85.09%   85.12%   +0.03%     
==========================================
  Files          93       93              
  Lines       15450    15478      +28     
  Branches     2335     2343       +8     
==========================================
+ Hits        13147    13176      +29     
+ Misses       1604     1600       -4     
- Partials      699      702       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

rx_bytes/tx_bytes only exist on the legacy RemoteRepository, so they always
read 0 for borgstore repositories. Sample repository.store.stats after the
cache is closed, rename the labels remote->repository, and add them to --json.

fixes borgbackup#9405
@mr-raj12 mr-raj12 force-pushed the create-stats-bytes-9405 branch from 855478d to fbd50c5 Compare July 6, 2026 07:23
@mr-raj12

mr-raj12 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I think the last pack should already get flushed before the archive pointer is created.

agreed!, the last pack is already flushed in Archives.create() before the pointer is written, so my comment was wrong on that. The real reason to sample after cache close is that Cache.close() writes the chunks index to the repo, and if we want that traffic counted too.
fixing comment and PR text.

@mr-raj12 mr-raj12 force-pushed the create-stats-bytes-9405 branch from fbd50c5 to b1cb09e Compare July 6, 2026 07:39
Comment thread src/borg/archiver/create_cmd.py Outdated
Replace the rx_bytes/tx_bytes summary with the complete store.stats
dict (call counts, timings, throughput, cache hit ratio) in --stats
and --json output.
@mr-raj12 mr-raj12 force-pushed the create-stats-bytes-9405 branch from b1cb09e to 54dede3 Compare July 6, 2026 18:08
@ThomasWaldmann ThomasWaldmann merged commit 9a920e0 into borgbackup:master Jul 7, 2026
19 checks passed
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.

borg2 create stats: missing bytes read/sent

2 participants