mirror of
https://github.com/apache/impala.git
synced 2025-12-30 12:02:10 -05:00
This is the following squashed patches that were reverted.
I will fix the known issues with some follow-on patches.
======================================================================
IMPALA-4835: Part 1: simplify I/O mgr mem mgmt and cancellation
In preparation for switching the I/O mgr to the buffer pool, this
removes and cleans up a lot of code so that the switchover patch starts
from a cleaner slate.
* Remove the free buffer cache (which will be replaced by buffer pool's
own caching).
* Make memory limit exceeded error checking synchronous (in anticipation
of having to propagate buffer pool errors synchronously).
* Simplify error propagation - remove the (ineffectual) code that
enqueued BufferDescriptors containing error statuses.
* Document locking scheme better in a few places, make it part of the
function signature when it seemed reasonable.
* Move ReturnBuffer() to ScanRange, because it is intrinsically
connected with the lifecycle of a scan range.
* Separate external ReturnBuffer() and internal CleanUpBuffer()
interfaces - previously callers of ReturnBuffer() were fudging
the num_buffers_in_reader accounting to make the external interface work.
* Eliminate redundant state in ScanRange: 'eosr_returned_' and
'is_cancelled_'.
* Clarify the logic around calling Close() for the last
BufferDescriptor.
-> There appeared to be an implicit assumption that buffers would be
freed in the order they were returned from the scan range, so that
the "eos" buffer was returned last. Instead just count the number
of outstanding buffers to detect the last one.
-> Touching the is_cancelled_ field without holding a lock was hard to
reason about - violated locking rules and it was unclear that it
was race-free.
* Remove DiskIoMgr::Read() to simplify the interface. It is trivial to
inline at the callsites.
This will probably regress performance somewhat because of the cache
removal, so my plan is to merge it around the same time as switching
the I/O mgr to allocate from the buffer pool. I'm keeping the patches
separate to make reviewing easier.
Testing:
* Ran exhaustive tests
* Ran the disk-io-mgr-stress-test overnight
======================================================================
IMPALA-4835: Part 2: Allocate scan range buffers upfront
This change is a step towards reserving memory for buffers from the
buffer pool and constraining per-scanner memory requirements. This
change restructures the DiskIoMgr code so that each ScanRange operates
with a fixed set of buffers that are allocated upfront and recycled as
the I/O mgr works through the ScanRange.
One major change is that ScanRanges get blocked when a buffer is not
available and get unblocked when a client returns a buffer via
ReturnBuffer(). I was able to remove the logic to maintain the
blocked_ranges_ list by instead adding a separate set with all ranges
that are active.
There is also some miscellaneous cleanup included - e.g. reducing the
amount of code devoted to maintaining counters and metrics.
One tricky part of the existing code was the it called
IssueInitialRanges() with empty lists of files and depended on
DiskIoMgr::AddScanRanges() to not check for cancellation in that case.
See IMPALA-6564/IMPALA-6588. I changed the logic to not try to issue
ranges for empty lists of files.
I plan to merge this along with the actual buffer pool switch, but
separated it out to allow review of the DiskIoMgr changes separate from
other aspects of the buffer pool switchover.
Testing:
* Ran core and exhaustive tests.
======================================================================
IMPALA-4835: Part 3: switch I/O buffers to buffer pool
This is the final patch to switch the Disk I/O manager to allocate all
buffer from the buffer pool and to reserve the buffers required for
a query upfront.
* The planner reserves enough memory to run a single scanner per
scan node.
* The multi-threaded scan node must increase reservation before
spinning up more threads.
* The scanner implementations must be careful to stay within their
assigned reservation.
The row-oriented scanners were most straightforward, since they only
have a single scan range active at a time. A single I/O buffer is
sufficient to scan the whole file but more I/O buffers can improve I/O
throughput.
Parquet is more complex because it issues a scan range per column and
the sizes of the columns on disk are not known during planning. To
deal with this, the reservation in the frontend is based on a
heuristic involving the file size and # columns. The Parquet scanner
can then divvy up reservation to columns based on the size of column
data on disk.
I adjusted how the 'mem_limit' is divided between buffer pool and non
buffer pool memory for low mem_limits to account for the increase in
buffer pool memory.
Testing:
* Added more planner tests to cover reservation calcs for scan node.
* Test scanners for all file formats with the reservation denial debug
action, to test behaviour when the scanners hit reservation limits.
* Updated memory and buffer pool limits for tests.
* Added unit tests for dividing reservation between columns in parquet,
since the algorithm is non-trivial.
Perf:
I ran TPC-H and targeted perf locally comparing with master. Both
showed small improvements of a few percent and no regressions of
note. Cluster perf tests showed no significant change.
Change-Id: I3ef471dc0746f0ab93b572c34024fc7343161f00
Reviewed-on: http://gerrit.cloudera.org:8080/9679
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Tim Armstrong <tarmstrong@cloudera.com>
234 lines
6.2 KiB
Plaintext
234 lines
6.2 KiB
Plaintext
====
|
|
---- QUERY
|
|
# Set an option explicitly; the test infrastructure should clear it before the next test.
|
|
# The next test tests that buffer_pool_limit is unset ("").
|
|
set buffer_pool_limit=7;
|
|
====
|
|
---- QUERY
|
|
set all;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'ABORT_ON_ERROR','0','REGULAR'
|
|
'ALLOW_UNSUPPORTED_FORMATS','0','DEPRECATED'
|
|
'BATCH_SIZE','0','DEVELOPMENT'
|
|
'BUFFER_POOL_LIMIT','','ADVANCED'
|
|
'DEBUG_ACTION','','DEVELOPMENT'
|
|
'DISABLE_CODEGEN','0','REGULAR'
|
|
'DISABLE_OUTERMOST_TOPN','0','DEVELOPMENT'
|
|
'EXPLAIN_LEVEL','STANDARD','REGULAR'
|
|
'HBASE_CACHE_BLOCKS','0','ADVANCED'
|
|
'HBASE_CACHING','0','ADVANCED'
|
|
'MAX_ERRORS','100','ADVANCED'
|
|
'MAX_SCAN_RANGE_LENGTH','0','DEVELOPMENT'
|
|
'MEM_LIMIT','0','REGULAR'
|
|
'NUM_NODES','0','DEVELOPMENT'
|
|
'NUM_SCANNER_THREADS','0','REGULAR'
|
|
'COMPRESSION_CODEC','','REGULAR'
|
|
'PARQUET_FILE_SIZE','0','ADVANCED'
|
|
'REQUEST_POOL','','REGULAR'
|
|
'SYNC_DDL','0','REGULAR'
|
|
---- TYPES
|
|
STRING, STRING, STRING
|
|
====
|
|
---- QUERY
|
|
set explain_level=3;
|
|
set all;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'ABORT_ON_ERROR','0','REGULAR'
|
|
'ALLOW_UNSUPPORTED_FORMATS','0','DEPRECATED'
|
|
'BATCH_SIZE','0','DEVELOPMENT'
|
|
'BUFFER_POOL_LIMIT','','ADVANCED'
|
|
'DEBUG_ACTION','','DEVELOPMENT'
|
|
'DISABLE_CODEGEN','0','REGULAR'
|
|
'DISABLE_OUTERMOST_TOPN','0','DEVELOPMENT'
|
|
'EXPLAIN_LEVEL','VERBOSE','REGULAR'
|
|
'HBASE_CACHE_BLOCKS','0','ADVANCED'
|
|
'HBASE_CACHING','0','ADVANCED'
|
|
'MAX_ERRORS','100','ADVANCED'
|
|
'MAX_SCAN_RANGE_LENGTH','0','DEVELOPMENT'
|
|
'MEM_LIMIT','0','REGULAR'
|
|
'NUM_NODES','0','DEVELOPMENT'
|
|
'NUM_SCANNER_THREADS','0','REGULAR'
|
|
'COMPRESSION_CODEC','','REGULAR'
|
|
'PARQUET_FILE_SIZE','0','ADVANCED'
|
|
'REQUEST_POOL','','REGULAR'
|
|
'SYNC_DDL','0','REGULAR'
|
|
---- TYPES
|
|
STRING, STRING, STRING
|
|
====
|
|
---- QUERY
|
|
set explain_level='0';
|
|
set all;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'ABORT_ON_ERROR','0','REGULAR'
|
|
'ALLOW_UNSUPPORTED_FORMATS','0','DEPRECATED'
|
|
'BATCH_SIZE','0','DEVELOPMENT'
|
|
'BUFFER_POOL_LIMIT','','ADVANCED'
|
|
'DEBUG_ACTION','','DEVELOPMENT'
|
|
'DISABLE_CODEGEN','0','REGULAR'
|
|
'DISABLE_OUTERMOST_TOPN','0','DEVELOPMENT'
|
|
'EXPLAIN_LEVEL','MINIMAL','REGULAR'
|
|
'HBASE_CACHE_BLOCKS','0','ADVANCED'
|
|
'HBASE_CACHING','0','ADVANCED'
|
|
'MAX_ERRORS','100','ADVANCED'
|
|
'MAX_SCAN_RANGE_LENGTH','0','DEVELOPMENT'
|
|
'MEM_LIMIT','0','REGULAR'
|
|
'NUM_NODES','0','DEVELOPMENT'
|
|
'NUM_SCANNER_THREADS','0','REGULAR'
|
|
'COMPRESSION_CODEC','','REGULAR'
|
|
'PARQUET_FILE_SIZE','0','ADVANCED'
|
|
'REQUEST_POOL','','REGULAR'
|
|
'SYNC_DDL','0','REGULAR'
|
|
---- TYPES
|
|
STRING, STRING, STRING
|
|
====
|
|
---- QUERY
|
|
set parquet_file_size='2g'
|
|
---- CATCH
|
|
The PARQUET_FILE_SIZE query option must be less than 2GB.
|
|
====
|
|
---- QUERY
|
|
set foo=bar
|
|
---- CATCH
|
|
Invalid query option: foo
|
|
====
|
|
---- QUERY
|
|
set parquet_compression_codec=bar
|
|
---- CATCH
|
|
Invalid compression codec: bar
|
|
====
|
|
---- QUERY
|
|
# Test that SET actually does change the mem_limit.
|
|
# First, show mem_limit is not hit.
|
|
select 1
|
|
---- RESULTS
|
|
1
|
|
====
|
|
---- QUERY
|
|
# Set mem_limit really small so that queries will fail.
|
|
set mem_limit=1;
|
|
select count(string_col) from functional.alltypestiny
|
|
---- CATCH
|
|
Rejected query from pool default-pool: minimum memory reservation
|
|
====
|
|
---- QUERY
|
|
# Set mem_limit back to unlimited and query should succeed again.
|
|
set mem_limit=0;
|
|
select count(string_col) from functional.alltypestiny
|
|
---- RESULTS
|
|
8
|
|
---- TYPES
|
|
BIGINT
|
|
====
|
|
---- QUERY
|
|
# IMPALA-3334: 'optimize_partition_key_scans' is a boolean query option
|
|
set explain_level=0;
|
|
set optimize_partition_key_scans=true;
|
|
explain select min(month), max(year), ndv(day) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'01:AGGREGATE [FINALIZE]'
|
|
'00:UNION'
|
|
' constant-operands=11'
|
|
====
|
|
---- QUERY
|
|
set explain_level=0;
|
|
set optimize_partition_key_scans=1;
|
|
explain select min(month), max(year), ndv(day) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'01:AGGREGATE [FINALIZE]'
|
|
'00:UNION'
|
|
' constant-operands=11'
|
|
====
|
|
---- QUERY
|
|
set explain_level=0;
|
|
set optimize_partition_key_scans=false;
|
|
explain select min(month), max(year), ndv(day) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'03:AGGREGATE [FINALIZE]'
|
|
'02:EXCHANGE [UNPARTITIONED]'
|
|
'01:AGGREGATE'
|
|
'00:SCAN HDFS [functional.alltypesagg]'
|
|
====
|
|
---- QUERY
|
|
set explain_level=0;
|
|
set optimize_partition_key_scans=0;
|
|
explain select min(month), max(year), ndv(day) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'03:AGGREGATE [FINALIZE]'
|
|
'02:EXCHANGE [UNPARTITIONED]'
|
|
'01:AGGREGATE'
|
|
'00:SCAN HDFS [functional.alltypesagg]'
|
|
====
|
|
---- QUERY
|
|
set explain_level=0;
|
|
set disable_streaming_preaggregations=false;
|
|
explain select count(distinct double_col) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'06:AGGREGATE [FINALIZE]'
|
|
'05:EXCHANGE [UNPARTITIONED]'
|
|
'02:AGGREGATE'
|
|
'04:AGGREGATE'
|
|
'03:EXCHANGE [HASH(double_col)]'
|
|
'01:AGGREGATE [STREAMING]'
|
|
'00:SCAN HDFS [functional.alltypesagg]'
|
|
====
|
|
---- QUERY
|
|
set explain_level=0;
|
|
set disable_streaming_preaggregations=0;
|
|
explain select count(distinct double_col) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'06:AGGREGATE [FINALIZE]'
|
|
'05:EXCHANGE [UNPARTITIONED]'
|
|
'02:AGGREGATE'
|
|
'04:AGGREGATE'
|
|
'03:EXCHANGE [HASH(double_col)]'
|
|
'01:AGGREGATE [STREAMING]'
|
|
'00:SCAN HDFS [functional.alltypesagg]'
|
|
====
|
|
---- QUERY
|
|
set explain_level=0;
|
|
set disable_streaming_preaggregations=true;
|
|
explain select count(distinct double_col) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'06:AGGREGATE [FINALIZE]'
|
|
'05:EXCHANGE [UNPARTITIONED]'
|
|
'02:AGGREGATE'
|
|
'04:AGGREGATE'
|
|
'03:EXCHANGE [HASH(double_col)]'
|
|
'01:AGGREGATE'
|
|
'00:SCAN HDFS [functional.alltypesagg]'
|
|
====
|
|
---- QUERY
|
|
set explain_level=0;
|
|
set disable_streaming_preaggregations=1;
|
|
explain select count(distinct double_col) from functional.alltypesagg;
|
|
---- RESULTS: VERIFY_IS_SUBSET
|
|
'06:AGGREGATE [FINALIZE]'
|
|
'05:EXCHANGE [UNPARTITIONED]'
|
|
'02:AGGREGATE'
|
|
'04:AGGREGATE'
|
|
'03:EXCHANGE [HASH(double_col)]'
|
|
'01:AGGREGATE'
|
|
'00:SCAN HDFS [functional.alltypesagg]'
|
|
====
|
|
---- QUERY
|
|
set max_row_size=-1;
|
|
---- CATCH
|
|
Invalid max row size of -1. Valid sizes are in [1, 1099511627776]
|
|
====
|
|
---- QUERY
|
|
set max_row_size=0;
|
|
---- CATCH
|
|
Invalid max row size of 0. Valid sizes are in [1, 1099511627776]
|
|
====
|
|
---- QUERY
|
|
# Setting some removed query options should be a no-op.
|
|
set DEFAULT_ORDER_BY_LIMIT="foo";
|
|
set ABORT_ON_DEFAULT_LIMIT_EXCEEDED = "foo";
|
|
set V_CPU_CORES = "foo";
|
|
set RESERVATION_REQUEST_TIMEOUT = "foo";
|
|
set RM_INITIAL_MEM = "foo";
|
|
set SCAN_NODE_CODEGEN_THRESHOLD = "foo";
|
|
set max_io_buffers="foo";
|
|
---- RESULTS
|
|
====
|