Skip to content

Commit c71b577

Browse files
committed
add global cost
1 parent e079428 commit c71b577

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

src/common/base/src/rangemap/range_merger.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ use std::ops::Range;
2323
/// Check overlap.
2424
fn overlaps(this: &Range<u64>, other: &Range<u64>, max_gap_size: u64, max_range_size: u64) -> bool {
2525
let this_len = this.end - this.start;
26-
let other_len = other.end - other.start;
27-
28-
if (this_len + other_len) >= max_range_size {
26+
if this_len >= max_range_size {
2927
false
3028
} else {
3129
let end_with_gap = this.end + max_gap_size;

src/query/settings/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ impl Settings {
183183
},
184184
// max_storage_io_requests_merge_gap
185185
SettingValue {
186-
default_value: UserSettingValue::UInt64(16 * 1024),
186+
default_value: UserSettingValue::UInt64(1024),
187187
user_setting: UserSetting::create(
188188
"max_storage_io_requests_merge_gap",
189-
UserSettingValue::UInt64(16 * 1024),
189+
UserSettingValue::UInt64(1024),
190190
),
191191
level: ScopeLevel::Session,
192-
desc: "The maximum gap bytes of adjusting to merge two IO requests. By default the value is 16KB",
192+
desc: "The maximum gap bytes of adjusting to merge two IO requests. By default the value is 1KB",
193193
possible_values: None,
194194
},
195195
// max_storage_io_requests_page_size

src/query/storages/fuse/src/io/read/block_reader.rs

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use std::sync::atomic::AtomicU64;
16+
use std::sync::Arc;
17+
1518
use common_arrow::parquet::metadata::SchemaDescriptor;
1619
use common_catalog::plan::Projection;
1720
use common_datavalues::DataSchemaRef;
@@ -21,6 +24,8 @@ use opendal::Operator;
2124
// TODO: make BlockReader as a trait.
2225
#[derive(Clone)]
2326
pub struct BlockReader {
27+
pub normal_all_cost: Arc<AtomicU64>,
28+
pub merge_all_cost: Arc<AtomicU64>,
2429
pub(crate) operator: Operator,
2530
pub(crate) projection: Projection,
2631
pub(crate) projected_schema: DataSchemaRef,

src/query/storages/fuse/src/io/read/block_reader_parquet.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use std::collections::hash_map::Entry;
1616
use std::collections::HashMap;
17+
use std::sync::atomic::Ordering;
1718
use std::sync::Arc;
1819
use std::time::SystemTime;
1920

@@ -72,6 +73,8 @@ impl BlockReader {
7273
let column_leaves = ColumnLeaves::new_from_schema(&arrow_schema);
7374

7475
Ok(Arc::new(BlockReader {
76+
normal_all_cost: Arc::new(0.into()),
77+
merge_all_cost: Arc::new(0.into()),
7578
operator,
7679
projection,
7780
projected_schema,
@@ -284,6 +287,7 @@ impl BlockReader {
284287
let indices = Self::build_projection_indices(&columns);
285288
let mut join_handlers = Vec::with_capacity(indices.len());
286289

290+
// Normal read.
287291
let mut ranges = vec![];
288292
let mut normal_read_bytes = 0u64;
289293
for (index, _) in indices {
@@ -301,7 +305,9 @@ impl BlockReader {
301305

302306
let now = SystemTime::now();
303307
let res = futures::future::try_join_all(join_handlers).await;
304-
let normal_cost = now.elapsed().unwrap().as_millis();
308+
let normal_cost = now.elapsed().unwrap().as_millis() as u64;
309+
self.normal_all_cost
310+
.fetch_add(normal_cost, Ordering::Release);
305311

306312
// Merge io requests.
307313
let max_gap_size = ctx.get_settings().get_max_storage_io_requests_merge_gap()?;
@@ -321,21 +327,24 @@ impl BlockReader {
321327
}
322328
let now = SystemTime::now();
323329
let _ = futures::future::try_join_all(merge_io_handlers).await;
324-
let merge_cost = now.elapsed().unwrap().as_millis();
330+
let merge_cost = now.elapsed().unwrap().as_millis() as u64;
331+
self.merge_all_cost.fetch_add(merge_cost, Ordering::Release);
325332

326333
info!(
327-
"async read norma partition={}, count={}, bytes={}, took:{} ms",
334+
"norma read partition={}, count={}, bytes={}, took:{} ms, all:{} ms",
328335
part.location,
329336
part.columns_meta.len(),
330337
normal_read_bytes,
331338
normal_cost,
339+
self.normal_all_cost.load(Ordering::Acquire),
332340
);
333341
info!(
334-
"async read merge partition={}, count={}, bytes={}, took:{} ms",
342+
"merge read partition={}, count={}, bytes={}, took:{} ms, all:{} ms",
335343
part.location,
336344
ranges.len(),
337345
merge_read_bytes,
338346
merge_cost,
347+
self.merge_all_cost.load(Ordering::Acquire)
339348
);
340349

341350
res

0 commit comments

Comments
 (0)