Commit bf71924a authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru Committed by Sergei Golubchik

cleanup: Make tempfile creation uniform with DISK_CHUNK_SIZE

Replace READ_RECORD_SIZE and DISK_BUFFER_SIZE (renamed to
DISK_CHUNK_SIZE) to be used across all open_cached_file calls.

Reviewer: Monty
parent df1aa55d
...@@ -346,8 +346,8 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort, ...@@ -346,8 +346,8 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort,
if (param.tmp_buffer.alloc(param.sort_length)) if (param.tmp_buffer.alloc(param.sort_length))
goto err; goto err;
if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX, if (open_cached_file(&buffpek_pointers, mysql_tmpdir, TEMP_PREFIX,
DISK_BUFFER_SIZE, MYF(MY_WME))) DISK_CHUNK_SIZE, MYF(MY_WME)))
goto err; goto err;
param.sort_form= table; param.sort_form= table;
...@@ -397,10 +397,10 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort, ...@@ -397,10 +397,10 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort,
sort->buffpek.length= maxbuffer; sort->buffpek.length= maxbuffer;
buffpek= (Merge_chunk *) sort->buffpek.str; buffpek= (Merge_chunk *) sort->buffpek.str;
close_cached_file(&buffpek_pointers); close_cached_file(&buffpek_pointers);
/* Open cached file if it isn't open */ /* Open cached file if it isn't open */
if (! my_b_inited(outfile) && if (! my_b_inited(outfile) &&
open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER, open_cached_file(outfile, mysql_tmpdir, TEMP_PREFIX, DISK_CHUNK_SIZE,
MYF(MY_WME))) MYF(MY_WME)))
goto err; goto err;
if (reinit_io_cache(outfile,WRITE_CACHE,0L,0,0)) if (reinit_io_cache(outfile,WRITE_CACHE,0L,0,0))
goto err; goto err;
...@@ -1065,7 +1065,7 @@ write_keys(Sort_param *param, SORT_INFO *fs_info, uint count, ...@@ -1065,7 +1065,7 @@ write_keys(Sort_param *param, SORT_INFO *fs_info, uint count,
fs_info->sort_buffer(param, count); fs_info->sort_buffer(param, count);
if (!my_b_inited(tempfile) && if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, mysql_tmpdir, TEMP_PREFIX, DISK_BUFFER_SIZE, open_cached_file(tempfile, mysql_tmpdir, TEMP_PREFIX, DISK_CHUNK_SIZE,
MYF(MY_WME))) MYF(MY_WME)))
DBUG_RETURN(1); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
/* check we won't have more buffpeks than we can possibly keep in memory */ /* check we won't have more buffpeks than we can possibly keep in memory */
...@@ -1647,8 +1647,8 @@ int merge_many_buff(Sort_param *param, Sort_buffer sort_buffer, ...@@ -1647,8 +1647,8 @@ int merge_many_buff(Sort_param *param, Sort_buffer sort_buffer,
if (*maxbuffer < MERGEBUFF2) if (*maxbuffer < MERGEBUFF2)
DBUG_RETURN(0); /* purecov: inspected */ DBUG_RETURN(0); /* purecov: inspected */
if (flush_io_cache(t_file) || if (flush_io_cache(t_file) ||
open_cached_file(&t_file2,mysql_tmpdir,TEMP_PREFIX,DISK_BUFFER_SIZE, open_cached_file(&t_file2, mysql_tmpdir, TEMP_PREFIX, DISK_CHUNK_SIZE,
MYF(MY_WME))) MYF(MY_WME)))
DBUG_RETURN(1); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
from_file= t_file ; to_file= &t_file2; from_file= t_file ; to_file= &t_file2;
......
...@@ -172,7 +172,7 @@ static inline double cache_hit_ratio(uint ratio) ...@@ -172,7 +172,7 @@ static inline double cache_hit_ratio(uint ratio)
#define HEAP_TEMPTABLE_LOOKUP_COST 0.05 #define HEAP_TEMPTABLE_LOOKUP_COST 0.05
#define HEAP_TEMPTABLE_CREATE_COST 1.0 #define HEAP_TEMPTABLE_CREATE_COST 1.0
#define DISK_TEMPTABLE_LOOKUP_COST 1.0 #define DISK_TEMPTABLE_LOOKUP_COST 1.0
#define DISK_TEMPTABLE_CREATE_COST 4.0 /* Creating and deleting 2 temp tables */ #define DISK_TEMPTABLE_CREATE_COST TMPFILE_CREATE_COST*2 /* 2 tmp tables */
#define DISK_TEMPTABLE_BLOCK_SIZE 8192 #define DISK_TEMPTABLE_BLOCK_SIZE 8192
#define SORT_INDEX_CMP_COST 0.02 #define SORT_INDEX_CMP_COST 0.02
......
...@@ -119,14 +119,13 @@ ...@@ -119,14 +119,13 @@
#define CREATE_MODE 0 /* Default mode on new files */ #define CREATE_MODE 0 /* Default mode on new files */
#define NAMES_SEP_CHAR 255 /* Char to sep. names */ #define NAMES_SEP_CHAR 255 /* Char to sep. names */
#define READ_RECORD_BUFFER (uint) (IO_SIZE*8) /* Pointer_buffer_size */
#define DISK_BUFFER_SIZE (uint) (IO_SIZE*16) /* Size of diskbuffer */
/* /*
When reading big blocks, assume that each block of this size is This is used when reading large blocks, sequential read.
is of simlar cost as key lookup (1) We assume that reading this much will be the same cost as 1 seek / fetching
one row from the storage engine.
*/ */
#define DISK_FAST_READ_SIZE ((uint) (IO_SIZE*16)) #define DISK_CHUNK_SIZE (uint) (65536) /* Size of diskbuffer for tmpfiles */
#define TMPFILE_CREATE_COST 2.0 /* Creating and deleting tmp file */
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */ #define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
#define FRM_VER_EXPRESSSIONS (FRM_VER+5) /* 11 */ #define FRM_VER_EXPRESSSIONS (FRM_VER+5) /* 11 */
......
...@@ -840,8 +840,8 @@ int mysql_update(THD *thd, ...@@ -840,8 +840,8 @@ int mysql_update(THD *thd,
explain->buf_tracker.on_scan_init(); explain->buf_tracker.on_scan_init();
IO_CACHE tempfile; IO_CACHE tempfile;
if (open_cached_file(&tempfile, mysql_tmpdir,TEMP_PREFIX, if (open_cached_file(&tempfile, mysql_tmpdir,TEMP_PREFIX,
DISK_BUFFER_SIZE, MYF(MY_WME))) DISK_CHUNK_SIZE, MYF(MY_WME)))
goto err; goto err;
/* If quick select is used, initialize it before retrieving rows. */ /* If quick select is used, initialize it before retrieving rows. */
if (select && select->quick && select->quick->reset()) if (select && select->quick && select->quick->reset())
......
...@@ -103,7 +103,7 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, ...@@ -103,7 +103,7 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
if (!max_elements) if (!max_elements)
max_elements= 1; max_elements= 1;
(void) open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, (void) open_cached_file(&file, mysql_tmpdir, TEMP_PREFIX, DISK_CHUNK_SIZE,
MYF(MY_WME)); MYF(MY_WME));
} }
...@@ -716,7 +716,7 @@ bool Unique::merge(TABLE *table, uchar *buff, size_t buff_size, ...@@ -716,7 +716,7 @@ bool Unique::merge(TABLE *table, uchar *buff, size_t buff_size,
/* Open cached file for table records if it isn't open */ /* Open cached file for table records if it isn't open */
if (! my_b_inited(outfile) && if (! my_b_inited(outfile) &&
open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER, open_cached_file(outfile, mysql_tmpdir, TEMP_PREFIX, DISK_CHUNK_SIZE,
MYF(MY_WME))) MYF(MY_WME)))
return 1; return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment