Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
59baf97d
Commit
59baf97d
authored
Apr 01, 2010
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Post-review fixes.
parent
ecba0ec8
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
558 additions
and
540 deletions
+558
-540
include/keycache.h
include/keycache.h
+62
-27
mysql-test/r/key_cache.result
mysql-test/r/key_cache.result
+19
-13
mysql-test/t/key_cache.test
mysql-test/t/key_cache.test
+2
-0
mysys/mf_keycache.c
mysys/mf_keycache.c
+460
-486
sql/sql_show.cc
sql/sql_show.cc
+15
-14
No files found.
include/keycache.h
View file @
59baf97d
...
...
@@ -37,7 +37,6 @@ C_MODE_START
#define MAX_KEY_CACHE_PARTITIONS 64
/* The structure to get statistical data about a key cache */
typedef
struct
st_key_cache_statistics
...
...
@@ -53,6 +52,8 @@ typedef struct st_key_cache_statistics
ulonglong
writes
;
/* number of actual writes from buffers into files */
}
KEY_CACHE_STATISTICS
;
#define NO_LONG_KEY_CACHE_STAT_VARIABLES 3
/* The type of a key cache object */
typedef
enum
key_cache_type
{
...
...
@@ -61,6 +62,55 @@ typedef enum key_cache_type
}
KEY_CACHE_TYPE
;
typedef
int
(
*
INIT_KEY_CACHE
)
(
void
*
,
uint
key_cache_block_size
,
size_t
use_mem
,
uint
division_limit
,
uint
age_threshold
);
typedef
int
(
*
RESIZE_KEY_CACHE
)
(
void
*
,
uint
key_cache_block_size
,
size_t
use_mem
,
uint
division_limit
,
uint
age_threshold
);
typedef
void
(
*
CHANGE_KEY_CACHE_PARAM
)
(
void
*
keycache_cb
,
uint
division_limit
,
uint
age_threshold
);
typedef
uchar
*
(
*
KEY_CACHE_READ
)
(
void
*
keycache_cb
,
File
file
,
my_off_t
filepos
,
int
level
,
uchar
*
buff
,
uint
length
,
uint
block_length
,
int
return_buffer
);
typedef
int
(
*
KEY_CACHE_INSERT
)
(
void
*
keycache_cb
,
File
file
,
my_off_t
filepos
,
int
level
,
uchar
*
buff
,
uint
length
);
typedef
int
(
*
KEY_CACHE_WRITE
)
(
void
*
keycache_cb
,
File
file
,
void
*
file_extra
,
my_off_t
filepos
,
int
level
,
uchar
*
buff
,
uint
length
,
uint
block_length
,
int
force_write
);
typedef
int
(
*
FLUSH_KEY_BLOCKS
)
(
void
*
keycache_cb
,
int
file
,
void
*
file_extra
,
enum
flush_type
type
);
typedef
int
(
*
RESET_KEY_CACHE_COUNTERS
)
(
const
char
*
name
,
void
*
keycache_cb
);
typedef
void
(
*
END_KEY_CACHE
)
(
void
*
keycache_cb
,
my_bool
cleanup
);
typedef
void
(
*
GET_KEY_CACHE_STATISTICS
)
(
void
*
keycache_cb
,
uint
partition_no
,
KEY_CACHE_STATISTICS
*
key_cache_stats
);
typedef
ulonglong
(
*
GET_KEY_CACHE_STAT_VALUE
)
(
void
*
keycache_cb
,
uint
var_no
);
/*
An object of the type KEY_CACHE_FUNCS contains pointers to all functions
from the key cache interface.
...
...
@@ -74,32 +124,17 @@ typedef enum key_cache_type
typedef
struct
st_key_cache_funcs
{
int
(
*
init
)
(
void
*
,
uint
key_cache_block_size
,
size_t
use_mem
,
uint
division_limit
,
uint
age_threshold
);
int
(
*
resize
)
(
void
*
,
uint
key_cache_block_size
,
size_t
use_mem
,
uint
division_limit
,
uint
age_threshold
);
void
(
*
change_param
)
(
void
*
keycache_cb
,
uint
division_limit
,
uint
age_threshold
);
uchar
*
(
*
read
)
(
void
*
keycache_cb
,
File
file
,
my_off_t
filepos
,
int
level
,
uchar
*
buff
,
uint
length
,
uint
block_length
,
int
return_buffer
);
int
(
*
insert
)
(
void
*
keycache_cb
,
File
file
,
my_off_t
filepos
,
int
level
,
uchar
*
buff
,
uint
length
);
int
(
*
write
)
(
void
*
keycache_cb
,
File
file
,
void
*
file_extra
,
my_off_t
filepos
,
int
level
,
uchar
*
buff
,
uint
length
,
uint
block_length
,
int
force_write
);
int
(
*
flush
)
(
void
*
keycache_cb
,
int
file
,
void
*
file_extra
,
enum
flush_type
type
);
int
(
*
reset_counters
)
(
const
char
*
name
,
void
*
keycache_cb
);
void
(
*
end
)
(
void
*
keycache_cb
,
my_bool
cleanup
);
void
(
*
get_stats
)
(
void
*
keycache_cb
,
uint
partition_no
,
KEY_CACHE_STATISTICS
*
key_cache_stats
);
ulonglong
(
*
get_stat_val
)
(
void
*
keycache_cb
,
uint
var_no
);
INIT_KEY_CACHE
init
;
RESIZE_KEY_CACHE
resize
;
CHANGE_KEY_CACHE_PARAM
change_param
;
KEY_CACHE_READ
read
;
KEY_CACHE_INSERT
insert
;
KEY_CACHE_WRITE
write
;
FLUSH_KEY_BLOCKS
flush
;
RESET_KEY_CACHE_COUNTERS
reset_counters
;
END_KEY_CACHE
end
;
GET_KEY_CACHE_STATISTICS
get_stats
;
GET_KEY_CACHE_STAT_VALUE
get_stat_val
;
}
KEY_CACHE_FUNCS
;
...
...
mysql-test/r/key_cache.result
View file @
59baf97d
...
...
@@ -672,12 +672,12 @@ insert into t2 values (2000, 3, 'yyyy');
select * from information_schema.key_caches where key_cache_name like "keycache2"
and partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
keycache2 NULL NULL 1048576 1024
0 # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024
6 # 0 6 6 3 3
select * from information_schema.key_caches where key_cache_name like "key%"
and partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19
keycache2 NULL NULL 1048576 1024
0 # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024
6 # 0 6 6 3 3
cache index t2 in keycache1;
Table Op Msg_type Msg_text
test.t2 assign_to_keycache status OK
...
...
@@ -718,7 +718,7 @@ KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUS
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache1 7 NULL 262143 2048 # # 0 3201 43 1594 30
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_cache_block_size=2*1024;
insert into t2 values (7000, 3, 'yyyy');
select * from information_schema.key_caches where partition_number is null;
...
...
@@ -726,66 +726,72 @@ KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUS
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache1 7 NULL 262143 2048 # # 0 6 6 3 3
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_cache_block_size=8*1024;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache1 3 NULL 262143 8192 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
insert into t2 values (8000, 3, 'yyyy');
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache1 3 NULL 262143 8192 # # 0 6 5 3 3
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_buffer_size=64*1024;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_cache_block_size=2*1024;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache1 3 NULL 65535 2048 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_cache_block_size=8*1024;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_buffer_size=0;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_cache_block_size=8*1024;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_buffer_size=0;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_buffer_size=128*1024;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache1 1 NULL 131072 8192 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
set global keycache1.key_cache_block_size=1024;
select * from information_schema.key_caches where partition_number is null;
KEY_CACHE_NAME PARTITIONS PARTITION_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
keycache1 7 NULL 131068 1024 # # 0 0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
0 0 0 0
keycache2 NULL NULL 1048576 1024 # # 0
6 6 3 3
drop table t1,t2;
set global keycache1.key_buffer_size=0;
set global keycache2.key_buffer_size=0;
...
...
mysql-test/t/key_cache.test
View file @
59baf97d
...
...
@@ -469,6 +469,8 @@ insert into t2 values (7000, 3, 'yyyy');
select
*
from
information_schema
.
key_caches
where
partition_number
is
null
;
set
global
keycache1
.
key_cache_block_size
=
8
*
1024
;
--
replace_column
6
# 7 #
select
*
from
information_schema
.
key_caches
where
partition_number
is
null
;
insert
into
t2
values
(
8000
,
3
,
'yyyy'
);
--
replace_column
6
# 7 #
select
*
from
information_schema
.
key_caches
where
partition_number
is
null
;
...
...
mysys/mf_keycache.c
View file @
59baf97d
This diff is collapsed.
Click to expand it.
sql/sql_show.cc
View file @
59baf97d
...
...
@@ -2235,8 +2235,9 @@ static void update_key_cache_stat_var(KEY_CACHE *key_cache, size_t ofs)
case
offsetof
(
KEY_CACHE
,
global_cache_read
):
case
offsetof
(
KEY_CACHE
,
global_cache_w_requests
):
case
offsetof
(
KEY_CACHE
,
global_cache_write
):
var_no
=
3
+
(
ofs
-
offsetof
(
KEY_CACHE
,
global_cache_w_requests
))
/
sizeof
(
ulonglong
);
var_no
=
NO_LONG_KEY_CACHE_STAT_VARIABLES
+
(
ofs
-
offsetof
(
KEY_CACHE
,
global_cache_w_requests
))
/
sizeof
(
ulonglong
);
*
(
ulonglong
*
)((
char
*
)
key_cache
+
ofs
)
=
get_key_cache_stat_value
(
key_cache
,
var_no
);
break
;
...
...
@@ -6643,13 +6644,13 @@ int store_key_cache_table_record(THD *thd, TABLE *table,
KEY_CACHE
*
key_cache
,
uint
partitions
,
uint
partition_no
)
{
KEY_CACHE_STATISTICS
key
_
cache_stats
;
KEY_CACHE_STATISTICS
keycache_stats
;
uint
err
;
DBUG_ENTER
(
"store_key_cache_table_record"
);
get_key_cache_statistics
(
key_cache
,
partition_no
,
&
key
_
cache_stats
);
get_key_cache_statistics
(
key_cache
,
partition_no
,
&
keycache_stats
);
if
(
key_
cache_stats
.
mem_size
==
0
)
if
(
!
key_cache
->
key_cache_inited
||
key
cache_stats
.
mem_size
==
0
)
DBUG_RETURN
(
0
);
restore_record
(
table
,
s
->
default_values
);
...
...
@@ -6669,15 +6670,15 @@ int store_key_cache_table_record(THD *thd, TABLE *table,
table
->
field
[
2
]
->
set_notnull
();
table
->
field
[
2
]
->
store
((
long
)
partition_no
,
TRUE
);
}
table
->
field
[
3
]
->
store
(
key
_
cache_stats
.
mem_size
,
TRUE
);
table
->
field
[
4
]
->
store
(
key
_
cache_stats
.
block_size
,
TRUE
);
table
->
field
[
5
]
->
store
(
key
_
cache_stats
.
blocks_used
,
TRUE
);
table
->
field
[
6
]
->
store
(
key
_
cache_stats
.
blocks_unused
,
TRUE
);
table
->
field
[
7
]
->
store
(
key
_
cache_stats
.
blocks_changed
,
TRUE
);
table
->
field
[
8
]
->
store
(
key
_
cache_stats
.
read_requests
,
TRUE
);
table
->
field
[
9
]
->
store
(
key
_
cache_stats
.
reads
,
TRUE
);
table
->
field
[
10
]
->
store
(
key
_
cache_stats
.
write_requests
,
TRUE
);
table
->
field
[
11
]
->
store
(
key
_
cache_stats
.
writes
,
TRUE
);
table
->
field
[
3
]
->
store
(
keycache_stats
.
mem_size
,
TRUE
);
table
->
field
[
4
]
->
store
(
keycache_stats
.
block_size
,
TRUE
);
table
->
field
[
5
]
->
store
(
keycache_stats
.
blocks_used
,
TRUE
);
table
->
field
[
6
]
->
store
(
keycache_stats
.
blocks_unused
,
TRUE
);
table
->
field
[
7
]
->
store
(
keycache_stats
.
blocks_changed
,
TRUE
);
table
->
field
[
8
]
->
store
(
keycache_stats
.
read_requests
,
TRUE
);
table
->
field
[
9
]
->
store
(
keycache_stats
.
reads
,
TRUE
);
table
->
field
[
10
]
->
store
(
keycache_stats
.
write_requests
,
TRUE
);
table
->
field
[
11
]
->
store
(
keycache_stats
.
writes
,
TRUE
);
err
=
schema_table_store_record
(
thd
,
table
);
DBUG_RETURN
(
err
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment