diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2014-12-02 15:03:35 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2014-12-05 11:01:50 +0400 |
commit | 974808772b63563d031f687fd0fd158f83eb94aa (patch) | |
tree | e0013411d59f7afaba7dd023ffa48af04ea4eb3f | |
parent | 9e9f1da0d2dd5d9de9094d20d0b39e71ec4ce479 (diff) | |
download | mariadb-git-974808772b63563d031f687fd0fd158f83eb94aa.tar.gz |
MDEV-7004 - Merge scalability fixes from 10.0-power
All callers of open_cached_file() use 2 characters prefix. Allocating memory for
such short string is an overkill. Store it on IO_CACHE structure instead.
All callers of open_cached_file() use mysql_tmpdir as dir. No need to allocate
memory for it since it is constant and available till server shutdown.
This reduces number of allocations from 31 to 27 per OLTP RO transaction.
-rw-r--r-- | include/my_sys.h | 3 | ||||
-rw-r--r-- | mysys/mf_cache.c | 18 |
2 files changed, 12 insertions, 9 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 9913ee8c79b..3ab8754cf2c 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -473,7 +473,8 @@ typedef struct st_io_cache /* Used when cacheing files */ ulong disk_writes; void* arg; /* for use by pre/post_read */ char *file_name; /* if used with 'open_cached_file' */ - char *dir,*prefix; + const char *dir; + char prefix[3]; File file; /* file descriptor */ /* seek_not_done is set by my_b_seek() to inform the upcoming read/write diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c index 545084ea97f..299e4e5f478 100644 --- a/mysys/mf_cache.c +++ b/mysys/mf_cache.c @@ -61,9 +61,14 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix, size_t cache_size, myf cache_myflags) { DBUG_ENTER("open_cached_file"); - cache->dir= dir ? my_strdup(dir,MYF(cache_myflags & MY_WME)) : (char*) 0; - cache->prefix= (prefix ? my_strdup(prefix,MYF(cache_myflags & MY_WME)) : - (char*) 0); + cache->dir= dir; + if (prefix) + { + DBUG_ASSERT(strlen(prefix) == 2); + memcpy(cache->prefix, prefix, 3); + } + else + cache->prefix[0]= 0; cache->file_name=0; cache->buffer=0; /* Mark that not open */ if (!init_io_cache(cache,-1,cache_size,WRITE_CACHE,0L,0, @@ -71,8 +76,6 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix, { DBUG_RETURN(0); } - my_free(cache->dir); - my_free(cache->prefix); DBUG_RETURN(1); } @@ -83,7 +86,8 @@ my_bool real_open_cached_file(IO_CACHE *cache) char name_buff[FN_REFLEN]; int error=1; DBUG_ENTER("real_open_cached_file"); - if ((cache->file=create_temp_file(name_buff, cache->dir, cache->prefix, + if ((cache->file=create_temp_file(name_buff, cache->dir, + cache->prefix[0] ? cache->prefix : 0, (O_RDWR | O_BINARY | O_TRUNC | O_TEMPORARY | O_SHORT_LIVED), MYF(MY_WME))) >= 0) @@ -114,8 +118,6 @@ void close_cached_file(IO_CACHE *cache) } #endif } - my_free(cache->dir); - my_free(cache->prefix); } DBUG_VOID_RETURN; } |