seaweedfs/weed/query/engine
Chris Lu d48e1e1659
mount: improve read throughput with parallel chunk fetching (#7569)
* mount: improve read throughput with parallel chunk fetching

This addresses issue #7504 where a single weed mount FUSE instance
does not fully utilize node network bandwidth when reading large files.

Changes:
- Add -concurrentReaders mount option (default: 16) to control the
  maximum number of parallel chunk fetches during read operations
- Implement parallel section reading in ChunkGroup.ReadDataAt() using
  errgroup for better throughput when reading across multiple sections
- Enhance ReaderCache with MaybeCacheMany() to prefetch multiple chunks
  ahead in parallel during sequential reads (now prefetches 4 chunks)
- Increase ReaderCache limit dynamically based on concurrentReaders
  to support higher read parallelism

The bottleneck was that chunks were being read sequentially even when
they reside on different volume servers. By introducing parallel chunk
fetching, a single mount instance can now better saturate available
network bandwidth.

Fixes: #7504

* fmt

* Address review comments: make prefetch configurable, improve error handling

Changes:
1. Add DefaultPrefetchCount constant (4) to reader_at.go
2. Add GetPrefetchCount() method to ChunkGroup that derives prefetch count
   from concurrentReaders (1/4 ratio, min 1, max 8)
3. Pass prefetch count through NewChunkReaderAtFromClient
4. Fix error handling in readDataAtParallel to prioritize errgroup error
5. Update all callers to use DefaultPrefetchCount constant

For mount operations, prefetch scales with -concurrentReaders:
- concurrentReaders=16 (default) -> prefetch=4
- concurrentReaders=32 -> prefetch=8 (capped)
- concurrentReaders=4 -> prefetch=1

For non-mount paths (WebDAV, query engine, MQ), uses DefaultPrefetchCount.

* fmt

* Refactor: use variadic parameter instead of new function name

Use NewChunkGroup with optional concurrentReaders parameter instead of
creating a separate NewChunkGroupWithConcurrency function.

This maintains backward compatibility - existing callers without the
parameter get the default of 16 concurrent readers.

* Use explicit concurrentReaders parameter instead of variadic

* Refactor: use MaybeCache with count parameter instead of new MaybeCacheMany function

* Address nitpick review comments

- Add upper bound (128) on concurrentReaders to prevent excessive goroutine fan-out
- Cap readerCacheLimit at 256 accordingly
- Fix SetChunks: use Lock() instead of RLock() since we are writing to group.sections
2025-11-29 10:06:11 -08:00
..
aggregations.go Fix sql bugs (#7219) 2025-09-10 11:04:42 -07:00
alias_timestamp_integration_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
arithmetic_functions_test.go Migrate from deprecated azure-storage-blob-go to modern Azure SDK (#7310) 2025-10-08 23:12:03 -07:00
arithmetic_functions.go Migrate from deprecated azure-storage-blob-go to modern Azure SDK (#7310) 2025-10-08 23:12:03 -07:00
arithmetic_only_execution_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
arithmetic_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
arithmetic_with_functions_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
broker_client.go Clean up logs and deprecated functions (#7339) 2025-10-17 22:11:50 -07:00
catalog_no_schema_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
catalog.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
cockroach_parser_success_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
cockroach_parser.go Switch to seaweedfs/cockroachdb-parser directly 2025-10-21 11:43:22 -07:00
complete_sql_fixes_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
comprehensive_sql_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
data_conversion.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
datetime_functions_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
datetime_functions.go Migrate from deprecated azure-storage-blob-go to modern Azure SDK (#7310) 2025-10-08 23:12:03 -07:00
describe.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
engine_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
engine.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
errors.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
execution_plan_fast_path_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
fast_path_fix_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
fast_path_predicate_validation_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
function_helpers.go Fix date string parsing bug for the SQL Engine. (#7446) 2025-11-06 12:07:29 -08:00
hybrid_message_scanner.go mount: improve read throughput with parallel chunk fetching (#7569) 2025-11-29 10:06:11 -08:00
hybrid_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
mock_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
mocks_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
noschema_error_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
offset_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
parquet_scanner.go mount: improve read throughput with parallel chunk fetching (#7569) 2025-11-29 10:06:11 -08:00
parsing_debug_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
partition_path_fix_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
postgresql_only_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
query_parsing_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
real_namespace_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
real_world_where_clause_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
schema_parsing_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
select_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
sql_alias_support_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
sql_feature_diagnostic_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
sql_filtering_limit_offset_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
sql_types.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
string_concatenation_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
string_functions_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
string_functions.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
string_literal_function_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
system_columns.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
test_sample_data_test.go Message Queue: Add sql querying (#7185) 2025-09-09 01:01:03 -07:00
timestamp_integration_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
timestamp_query_fixes_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
types.go Fix sql bugs (#7219) 2025-09-10 11:04:42 -07:00
where_clause_debug_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00
where_validation_test.go Add Kafka Gateway (#7231) 2025-10-13 18:05:17 -07:00