| 879 | } |
| 880 | |
| 881 | void AdmissionController::PoolStats::ReleaseQuery( |
| 882 | int64_t peak_mem_consumption, bool is_trivial, const std::string& user) { |
| 883 | // Update stats tracking the number of running and admitted queries. |
| 884 | agg_num_running_ -= 1; |
| 885 | metrics_.agg_num_running->Increment(-1L); |
| 886 | |
| 887 | local_stats_.num_admitted_running -= 1; |
| 888 | metrics_.local_num_admitted_running->Increment(-1L); |
| 889 | |
| 890 | metrics_.total_released->Increment(1L); |
| 891 | DCHECK_GE(local_stats_.num_admitted_running, 0); |
| 892 | DCHECK_GE(agg_num_running_, 0); |
| 893 | if (is_trivial) { |
| 894 | --local_trivial_running_; |
| 895 | DCHECK_GE(local_trivial_running_, 0); |
| 896 | } |
| 897 | |
| 898 | if (!user.empty()) { |
| 899 | // Non-empty user name means user quotas are being used. |
| 900 | DecrementPerUser(user); |
| 901 | } |
| 902 | |
| 903 | // Update the 'peak_mem_histogram' based on the given peak memory consumption of the |
| 904 | // query, if provided. |
| 905 | if (peak_mem_consumption != -1) { |
| 906 | int64_t histogram_bucket = |
| 907 | BitUtil::RoundUp(peak_mem_consumption, HISTOGRAM_BIN_SIZE) / HISTOGRAM_BIN_SIZE; |
| 908 | histogram_bucket = |
| 909 | std::max(std::min(histogram_bucket, HISTOGRAM_NUM_OF_BINS), 1L) - 1; |
| 910 | peak_mem_histogram_[histogram_bucket] = ++(peak_mem_histogram_[histogram_bucket]); |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | void AdmissionController::PoolStats::ReleaseMem(int64_t mem_to_release) { |
| 915 | // Update stats tracking memory admitted. |