summaryrefslogtreecommitdiff
path: root/mysys/mf_cache.c
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2014-12-02 15:03:35 +0400
committerSergey Vojtovich <svoj@mariadb.org>2014-12-05 11:01:50 +0400
commit974808772b63563d031f687fd0fd158f83eb94aa (patch)
treee0013411d59f7afaba7dd023ffa48af04ea4eb3f /mysys/mf_cache.c
parent9e9f1da0d2dd5d9de9094d20d0b39e71ec4ce479 (diff)
downloadmariadb-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.
Diffstat (limited to 'mysys/mf_cache.c')
-rw-r--r--mysys/mf_cache.c18
1 files changed, 10 insertions, 8 deletions
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;
}