qt: Enhanced Traffic Graph Widget with Multi-timeframe Support and Data Persistence #866

pull rebroad wants to merge 4 commits into bitcoin-core:master from rebroad:trafficgraphwidget-rebased changing 13 files +688 −116
  1. rebroad commented at 11:00 pm on April 9, 2025: contributor

    This PR improves the network traffic graph widget in the Debug window to provide:

    1. Multiple time range options (from 5 minutes to 28 days)
    2. Data persistence between sessions
    3. Interactive visualization features including tooltips and logarithmic scaling

    Motivation

    The existing network traffic graph has limited utility with its fixed time range and lack of historical data preservation. This enhancement allows users to:

    • Analyze network traffic patterns over different timeframes
    • Preserve historical traffic data between session restarts
    • Interact with the graph to get specific data points
    • Better visualize varying traffic volumes with logarithmic scaling

    These improvements are valuable for:

    • Network debugging and troubleshooting
    • Understanding Bitcoin Core’s network behaviour
    • Monitoring traffic patterns for optimization
    • Research purposes

    Implementation

    The implementation preserves all existing functionality while adding new features:

    • Added a pre-configured timeframe selection (13 different timeframes)
    • Implemented traffic data serialization and deserialization
    • Enhanced the visualization with interactive features
    • Improved tooltip information with precise timestamps and traffic rates

    Supporting changes:

    • Added formatBytesps function for a prettier display of traffic rates
    • Added FormatISO8601Time for better time display
    • Added setTotalBytes functionality to restore network statistics properly

    Testing

    Tested on Linux with various network conditions. The new functionality can be exercised by:

    1. Using the slider (or arrow keys) to select different time ranges
    2. Restarting the application to verify data persistence
    3. Clicking on the graph to toggle between linear and logarithmic scales
    4. Hovering over data points to view detailed information

    Documentation

    The changes are mostly self-documenting through the UI and are constrained to the Qt interface without affecting core functionality.

    Compatibility

    This PR maintains compatibility with existing functionality. The data persistence file uses proper serialization versioning to allow for future format changes if needed.

  2. DrahtBot commented at 11:00 pm on April 9, 2025: contributor

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

    Reviews

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

    Conflicts

    No conflicts as of last run.

  3. DrahtBot added the label CI failed on Apr 9, 2025
  4. DrahtBot commented at 11:49 pm on April 9, 2025: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin-core/gui/runs/40286962281

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  5. rebroad force-pushed on Apr 10, 2025
  6. DrahtBot removed the label CI failed on Apr 10, 2025
  7. rebroad marked this as ready for review on Apr 10, 2025
  8. rebroad renamed this:
    qt: Improve TrafficGraphWidget functionality
    qt: Enhanced Traffic Graph Widget with Multi-timeframe Support and Data Persistence
    on Apr 11, 2025
  9. in src/qt/trafficgraphwidget.cpp:45 in 31b1ffc0ff outdated
    51+
    52+            // Restore the saved total bytes counts to the node if they exist
    53+            if (m_total_bytes_recv > 0 || m_total_bytes_sent > 0) {
    54+                model->node().setTotalBytesRecv(m_total_bytes_recv);
    55+                model->node().setTotalBytesSent(m_total_bytes_sent);
    56+            }
    


    luke-jr commented at 10:10 pm on April 14, 2025:

    The GUI should not be changing low-level internals.

    If for some reason the clientModel is changed, its data should be taken as authoritative, even if it contradicts the history so far (if that’s an issue, wipe the history).

    Alternatively, maybe the history should be stored with the node, and loaded into the GUI (or RPC, in another hypothetical PR).


    rebroad commented at 11:01 pm on April 15, 2025:
    The idea is that the data is not persistent - but yes, I see your point - it should probably not be something that only happens when the GUI is running, and should perhaps also happen in bitcoind also.
  10. in src/qt/forms/debugwindow.ui:698 in 31b1ffc0ff outdated
    702@@ -694,16 +703,6 @@
    703              </property>
    704             </widget>
    705            </item>
    706-           <item>
    707-            <widget class="QPushButton" name="btnClearTrafficGraph">
    


    luke-jr commented at 10:12 pm on April 14, 2025:

    If we’re deleting this, maybe there should be a way for the user to insert a reference line?

    For now, I’d move removal of anything to a separate PR.


    rebroad commented at 10:59 pm on April 15, 2025:
    The user can effectively remove the data by deleting the .dat file - is there any basis for being able to do this while the client is running?
  11. in src/qt/rpcconsole.cpp:581 in 31b1ffc0ff outdated
    575@@ -578,7 +576,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
    576     // based timer interface
    577     m_node.rpcSetTimerInterfaceIfUnset(rpcTimerInterface);
    578 
    579-    setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS);
    


    luke-jr commented at 10:12 pm on April 14, 2025:
    Why are we losing this default constant?

    rebroad commented at 10:57 pm on April 15, 2025:
    because it isn’t needed - on startup it “defaults” to the first non-full range
  12. in src/util/time.cpp:78 in 31b1ffc0ff outdated
    74@@ -75,6 +75,13 @@ void MockableSteadyClock::ClearMockTime()
    75 
    76 int64_t GetTime() { return GetTime<std::chrono::seconds>().count(); }
    77 
    78+int64_t GetTimeMillis()
    


    luke-jr commented at 10:14 pm on April 14, 2025:
    I doubt we’ll be restoring this. It was removed intentionally.

    rebroad commented at 10:56 pm on April 15, 2025:
    yes, I’m going to remove this, will push an update shortly
  13. luke-jr changes_requested
  14. luke-jr commented at 10:14 pm on April 14, 2025: member
    Merging it all together likes this makes review very annoying. It was better as separate PRs.
  15. rebroad commented at 11:02 pm on April 15, 2025: contributor

    Merging it all together likes this makes review very annoying. It was better as separate PRs.

    I vaguely remember people complaining that I was raising several PRs that could be combined when I first raised the PRs years ago…. I guess one cannot please everyone all of the time.

  16. rebroad requested review from luke-jr on Apr 15, 2025
  17. qt: Add formatBytesps function for bytes per second display
    Add a new GUI utility function to format bytes per second values with appropriate
    units (B/s, kB/s, MB/s, GB/s) and precision, ensuring consistent and readable
    display of network traffic rates in the traffic graph widget.
    b47170fc53
  18. net: Add setTotalBytes functionality for traffic data persistence
    Add functions to set total bytes sent/received counts to enable restoring
    traffic statistics between application sessions. This allows for continuous
    traffic monitoring even after application restarts, improving the usefulness
    of the traffic graph widget.
    1aff5eeb9b
  19. util: Add FormatISO8601Time function for time-only ISO format
    Adds a new utility function FormatISO8601Time that formats a Unix timestamp
    into an ISO 8601 time string (HH:MM:SSZ). This complements the existing
    FormatISO8601DateTime and FormatISO8601Date functions, providing a way to
    format just the time component of a timestamp.
    
    The function uses C++20 chrono features to handle time calculations and
    formatting, maintaining consistency with the existing ISO 8601 formatting
    functions.
    72bf0e9c17
  20. qt: Enhance TrafficGraphWidget with multi-timeframe support and data persistence
    This commit significantly improves the network traffic graph widget with:
    
    1. Multiple timeframe support - View traffic data across different time
       periods (5 minutes to 28 days) using an enhanced slider interface
    
    2. Traffic data persistence - Save and restore traffic information
       between sessions, preserving historical traffic patterns
    
    3. Interactive visualization features:
       - Logarithmic scale toggle (mouse click) for better visualization of
         varying traffic volumes
       - Interactive tooltips showing detailed traffic information at specific points
       - Yellow highlight indicators for selected data points
    
    4. Smooth transitions between different time ranges with animated scaling
    
    These improvements allow users to better monitor and analyze network
    traffic patterns over time, which is especially useful for debugging
    connectivity issues or understanding network behavior under different
    conditions.
    
    The implementation includes proper thread-safety considerations and
    handles edge cases like time jumps or missing data appropriately.
    ab7bbd062f
  21. rebroad force-pushed on Apr 16, 2025


rebroad DrahtBot luke-jr


luke-jr


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-04-18 18:20 UTC

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