| 914 | // TODO: make this a configurable memory pool option. |
| 915 | constexpr int32_t kGrowthQuantum = 8 << 20; |
| 916 | const auto reservationToAdd = bits::roundUp(increment, kGrowthQuantum); |
| 917 | try { |
| 918 | reserve(reservationToAdd, true); |
| 919 | } catch (const std::exception& e) { |
| 920 | LOG(INFO) << "maybeReserve failed, reason is:" << e.what(); |
| 921 | if (aborted()) { |
| 922 | // NOTE: we shall throw to stop the query execution if the root memory |
| 923 | // pool has been aborted. It is also unsafe to proceed as the memory |
| 924 | // abort code path might have already freed up the memory resource of |
| 925 | // this operator while it is under memory arbitration. |
| 926 | std::rethrow_exception(std::current_exception()); |
| 927 | } |
| 928 | return false; |
| 929 | } |
| 930 | return true; |
| 931 | } |
| 932 | |
| 933 | void MemoryPoolImpl::reserve(uint64_t size, bool reserveOnly) { |
| 934 | DETECT_HUGE_RESERVE(size); |
| 935 | if (FOLLY_LIKELY(trackUsage_)) { |
| 936 | if (FOLLY_LIKELY(threadSafe_)) { |
| 937 | reserveThreadSafe(size, reserveOnly); |
| 938 | } else { |
| 939 | reserveNonThreadSafe(size, reserveOnly); |
| 940 | } |