Skip to content

impl(bigtable): change from time weighted average to instant count#16047

Merged
scotthart merged 3 commits intogoogleapis:mainfrom
scotthart:bigtable_dynamic_pool_impl_2
Mar 17, 2026
Merged

impl(bigtable): change from time weighted average to instant count#16047
scotthart merged 3 commits intogoogleapis:mainfrom
scotthart:bigtable_dynamic_pool_impl_2

Conversation

@scotthart
Copy link
Member

After further conversations with the Bigtable team, we're going to simplify the RPC use tracking to a simple average of the current RPCs per channel across all the channels. Additionally, pending added channels will be included in the calculations to regulate how often channels are added as opposed to a timer.

@scotthart scotthart requested a review from a team as a code owner March 17, 2026 15:25
@product-auto-label product-auto-label bot added the api: bigtable Issues related to the Bigtable API. label Mar 17, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the Bigtable channel management to simplify how RPC usage is measured and how the channel pool scales. By moving from a time-weighted average to an instant count for RPCs, the system gains a more immediate and straightforward understanding of channel load. Additionally, the channel pool's sizing logic now proactively considers channels that are currently being provisioned, leading to more responsive and efficient resource allocation.

Highlights

  • Simplified RPC Usage Tracking: The mechanism for tracking outstanding RPCs on Bigtable channels has been simplified from a time-weighted average to an instant count. This removes the complexity of time-based measurements and calculations.
  • Pending Channel Inclusion in Pool Sizing: The DynamicChannelPool now accounts for channels that are in the process of being added (num_pending_channels_) when making pool sizing decisions, providing a more accurate view of the channel pool's state.
  • Removed Pool Size Increase Cooldown: The pool_size_increase_cooldown_timer_ and its associated logic have been removed, as the new channel addition strategy no longer requires this specific cooldown mechanism.
Changelog
  • google/cloud/bigtable/internal/channel_usage.h
    • Removed std::chrono and std::deque includes.
    • Removed Clock type alias and clock_ member variable.
    • Removed the average_outstanding_rpcs() method and its associated Measurement struct and measurements_ deque.
    • Updated ChannelUsage constructors to reflect the removal of time-related dependencies.
  • google/cloud/bigtable/internal/channel_usage_test.cc
    • Removed the AverageOutstandingRpcs test case.
    • Removed FakeSteadyClock include and its usage in ChannelUsage constructor calls.
    • Updated ChannelUsage constructor calls to align with the simplified ChannelUsage class.
  • google/cloud/bigtable/internal/dynamic_channel_pool.h
    • Removed the pool_size_increase_cooldown_timer_ member and its cancellation logic.
    • Added num_pending_channels_ to track channels currently being added.
    • Modified AddChannels to increment num_pending_channels_ when new channels are initiated and decrement it upon successful creation.
    • Removed the SetSizeIncreaseCooldownTimer method.
  • google/cloud/bigtable/internal/dynamic_channel_pool_test.cc
    • Removed FakeSteadyClock include and its member variable from DynamicChannelPoolTest.
    • Removed the SetSizeIncreaseCooldownTimer method from DynamicChannelPoolTestWrapper.
    • Updated ChannelUsage constructor calls in tests to remove the fake_clock_impl_ argument.
Activity
  • The author, scotthart, created this pull request to implement changes discussed with the Bigtable team regarding RPC use tracking.
  • The changes simplify the RPC tracking from a time-weighted average to an instant count.
  • Pending channels are now included in calculations to regulate channel additions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The code changes simplify the ChannelUsage class by removing the average_outstanding_rpcs functionality, including its time-based tracking (clock_ and measurements_). This also removes related includes and test cases. In DynamicChannelPool, a num_pending_channels_ counter was introduced to track channels being added. However, a review comment highlights a bug where num_pending_channels_ is incorrectly decremented by the number of successfully created stubs (new_stubs.size()) instead of the number of requested channels (new_channel_ids.size()). This can lead to an inaccurate count if some channel creations fail, potentially preventing future channel additions.

@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.65%. Comparing base (48196b1) to head (321d68a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16047      +/-   ##
==========================================
- Coverage   92.66%   92.65%   -0.01%     
==========================================
  Files        2341     2341              
  Lines      215695   215646      -49     
==========================================
- Hits       199876   199815      -61     
- Misses      15819    15831      +12     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart scotthart enabled auto-merge (squash) March 17, 2026 19:04
@scotthart scotthart merged commit 043638c into googleapis:main Mar 17, 2026
53 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants