log: show reindex progress in ImportBlocks #33353

pull l0rinc wants to merge 1 commits into bitcoin:master from l0rinc:l0rinc/show-reindex-progress changing 1 files +8 −7
  1. l0rinc commented at 7:08 pm on September 9, 2025: contributor

    Summary

    When triggering a reindex, users have no indication of progress.

    Fix

    This patch precomputes the total number of block files so progress can be shown. Instead of only displaying which block file is being processed, it now shows the percent complete.

    Reproducer + expected results

    0cmake -B build -DCMAKE_BUILD_TYPE=Release && make -C build -j && ./build/bin/bitcoind -datadir=demo -reindex
    

    Before, the block files were shown one-by-one, there’s no way to see how much work is left:

    0Reindexing block file blk00000.dat...
    1Loaded 119920 blocks from external file in 1228ms
    2Reindexing block file blk00001.dat...
    3Loaded 10671 blocks from external file in 284ms
    4Reindexing block file blk00002.dat...
    5Loaded 5459 blocks from external file in 263ms
    6Reindexing block file blk00003.dat...
    7Loaded 5595 blocks from external file in 267ms
    

    After the change we add a percentage:

    0Reindexing block file blk00000.dat (0% complete)...
    1Loaded 119920 blocks from external file in 1255ms
    2Reindexing block file blk00001.dat (1% complete)...
    3Loaded 10671 blocks from external file in 303ms
    4Reindexing block file blk00002.dat (2% complete)...
    5Loaded 5459 blocks from external file in 278ms
    6Reindexing block file blk00003.dat (3% complete)...
    7Loaded 5595 blocks from external file in 285ms
    
  2. DrahtBot commented at 7:08 pm on September 9, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33353.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  3. l0rinc renamed this:
    logs: show reindex progress in `ImportBlocks`
    log: show reindex progress in `ImportBlocks`
    on Sep 9, 2025
  4. DrahtBot added the label Utils/log/libs on Sep 9, 2025
  5. logs: show reindex progress in `ImportBlocks`
    ### Summary
    
    When triggering a reindex, users had no indication of how many files remained or how far along the process was.
    
    ### Fix
    
    This patch prefetches the target file block file count to be able to show progress information.
    Instead of just displaying which block file is being processed, it now indicates how many files remain.
    
    ### Reproducer + expected results
    
    Running
    ```bash
    cmake -B build && make -C build -DCMAKE_BUILD_TYPE=Release && ./build/bin/bitcoind -datadir=demo -reindex
    ```
    Shows the block files one-by-one currently, there's no way to see how much work is left:
    ```
    Reindexing block file blk00000.dat...
    Loaded 119920 blocks from external file in 1228ms
    Reindexing block file blk00001.dat...
    Loaded 10671 blocks from external file in 284ms
    Reindexing block file blk00002.dat...
    Loaded 5459 blocks from external file in 263ms
    Reindexing block file blk00003.dat...
    Loaded 5595 blocks from external file in 267ms
    ```
    
    After the change:
    ```
    Reindexing block file blk00000.dat (0% complete)...
    Loaded 119920 blocks from external file in 1255ms
    Reindexing block file blk00001.dat (1% complete)...
    Loaded 10671 blocks from external file in 303ms
    Reindexing block file blk00002.dat (2% complete)...
    Loaded 5459 blocks from external file in 278ms
    Reindexing block file blk00003.dat (3% complete)...
    Loaded 5595 blocks from external file in 285ms
    ```
    d7de5b109f
  6. l0rinc force-pushed on Sep 9, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-09-12 12:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me