avantgardnerio commented on code in PR #22626: URL: https://github.com/apache/datafusion/pull/22626#discussion_r3343012364
########## datafusion/sqllogictest/src/accounting_pool.rs: ########## @@ -0,0 +1,174 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! [`AccountingMemoryPool`] bridges DataFusion's voluntary memory tracking +//! to the allocator-level bank in [`crate::accounting`]. +//! +//! It wraps any [`MemoryPool`] and re-tunes the current thread's bank +//! account whenever the pool's limit changes (via [`MemoryPool::try_resize`], +//! which `RuntimeEnvBuilder::with_memory_limit` triggers on `SET +//! datafusion.runtime.memory_limit = '…'`). +//! +//! Each retune sets the bank to `new_limit * HEADROOM_FACTOR`. A query +//! that allocates past that envelope panics with an `OverdraftPanic` — +//! the gap between DF's voluntary tracker and the allocator's reality +//! is the bug we're hunting. + +use crate::set_account_balance; +use datafusion::common::Result; +use datafusion::execution::memory_pool::{ + MemoryConsumer, MemoryLimit, MemoryPool, MemoryReservation, +}; +use std::fmt::{self, Display, Formatter}; +use std::sync::Arc; + +/// Headroom over the pool's declared limit. Anything past this is an +/// untracked allocation — by definition, since DF's pool didn't see it. +/// +/// 600% high, but that's what it takes to pass the SLT suite right now. Goal should be ~10% +const HEADROOM_FACTOR: f64 = 6.0; Review Comment: In the case above, I think we are missing a `try_grow()` [here](https://github.com/apache/datafusion/blob/c134a848289cc465b0c4c3dc8be076cc10e299db/datafusion/physical-plan/src/spill/mod.rs#L170-L191) ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
