forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track RAM usage in temptable shared block
Summary: When decreasing temptable_max_ram system variable, I am not seeing decrease in memory when running workloads. create_tmp_table is still taking significant amount of memory in temptable APIs. This is because temptable_max_ram limit does not apply to shared block. The shared block is a TLS variable. In multithreaded environment, this takes a significant amount of memory (>150 MB). The shared block is unconditionally allocated from RAM. Also the shared_block is never deallocated once allocated in a thread. The fix introduces a system variable temptable_track_shared_block_ram. When enabled, the shared block memory allocation is also tracked. This tracking enables shared block to be allocated from mmap files in case the total allocated memory by temptable exceeds temptable_max_ram. Also with the fix, shared_block is deallocated after all the chunks are destroyed. This allows us to reclaim memory space more proactively. With this fix, I am seeing savings of >150 MB in our workloads. Reviewed By: yizhang82 Differential Revision: D27520132
- Loading branch information
Showing
10 changed files
with
221 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
mysql-test/suite/sys_vars/r/temptable_track_shared_block_ram_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
select @@global.temptable_track_shared_block_ram; | ||
@@global.temptable_track_shared_block_ram | ||
1 | ||
select @@session.temptable_track_shared_block_ram; | ||
ERROR HY000: Variable 'temptable_track_shared_block_ram' is a GLOBAL variable | ||
show global variables like 'temptable_track_shared_block_ram'; | ||
Variable_name Value | ||
temptable_track_shared_block_ram ON | ||
show session variables like 'temptable_track_shared_block_ram'; | ||
Variable_name Value | ||
temptable_track_shared_block_ram ON | ||
select * from performance_schema.global_variables where variable_name='temptable_track_shared_block_ram'; | ||
VARIABLE_NAME VARIABLE_VALUE | ||
temptable_track_shared_block_ram ON | ||
select * from performance_schema.session_variables where variable_name='temptable_track_shared_block_ram'; | ||
VARIABLE_NAME VARIABLE_VALUE | ||
temptable_track_shared_block_ram ON | ||
set global temptable_track_shared_block_ram=1; | ||
ERROR HY000: Variable 'temptable_track_shared_block_ram' is a read only variable | ||
set session temptable_track_shared_block_ram=1; | ||
ERROR HY000: Variable 'temptable_track_shared_block_ram' is a read only variable |
21 changes: 21 additions & 0 deletions
21
mysql-test/suite/sys_vars/t/temptable_track_shared_block_ram_basic.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# only global | ||
# | ||
--source include/have_log_bin.inc | ||
select @@global.temptable_track_shared_block_ram; | ||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
select @@session.temptable_track_shared_block_ram; | ||
show global variables like 'temptable_track_shared_block_ram'; | ||
show session variables like 'temptable_track_shared_block_ram'; | ||
--disable_warnings | ||
select * from performance_schema.global_variables where variable_name='temptable_track_shared_block_ram'; | ||
select * from performance_schema.session_variables where variable_name='temptable_track_shared_block_ram'; | ||
--enable_warnings | ||
|
||
# | ||
# show that it's read-only | ||
# | ||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
set global temptable_track_shared_block_ram=1; | ||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
set session temptable_track_shared_block_ram=1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.