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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
30f97ccd
Commit
30f97ccd
authored
Jul 31, 2014
by
John Esmet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FT-300 Add mean / stddev tracking for block allocation sizes to
ba_replay
parent
600a8647
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
7 deletions
+37
-7
tools/ba_replay.cc
tools/ba_replay.cc
+37
-7
No files found.
tools/ba_replay.cc
View file @
30f97ccd
...
...
@@ -91,6 +91,7 @@ PATENT RIGHTS GRANT:
#include <db.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
...
...
@@ -308,6 +309,26 @@ static vector<string> canonicalize_trace_from(FILE *file) {
return
canonicalized_trace
;
}
struct
streaming_variance_calculator
{
int64_t
n_samples
;
int64_t
mean
;
int64_t
variance
;
// math credit: AoCP, Donald Knuth, '62
void
add_sample
(
int64_t
x
)
{
n_samples
++
;
if
(
n_samples
==
1
)
{
mean
=
x
;
variance
=
0
;
}
else
{
int64_t
old_mean
=
mean
;
mean
=
old_mean
+
((
x
-
old_mean
)
/
n_samples
);
variance
=
(((
n_samples
-
1
)
*
variance
)
+
((
x
-
old_mean
)
*
(
x
-
mean
)))
/
n_samples
;
}
}
};
struct
canonical_trace_stats
{
uint64_t
n_lines_replayed
;
...
...
@@ -318,6 +339,9 @@ struct canonical_trace_stats {
uint64_t
n_free
;
uint64_t
n_destroy
;
struct
streaming_variance_calculator
alloc_hot_bytes
;
struct
streaming_variance_calculator
alloc_cold_bytes
;
canonical_trace_stats
()
{
memset
(
this
,
0
,
sizeof
(
*
this
));
}
...
...
@@ -389,6 +413,7 @@ static void replay_canonicalized_trace(const vector<string> &canonicalized_trace
ba
->
alloc_block
(
size
,
heat
,
&
offset
);
seq_num_to_offset
[
asn
]
=
offset
;
heat
?
stats
->
n_alloc_hot
++
:
stats
->
n_alloc_cold
++
;
heat
?
stats
->
alloc_hot_bytes
.
add_sample
(
size
)
:
stats
->
alloc_cold_bytes
.
add_sample
(
size
);
}
else
if
(
fn
==
"ba_trace_free_asn"
)
{
// replay a `free' on a block whose offset is the result of an alloc with an asn
const
uint64_t
asn
=
parse_uint64
(
&
ptr
,
line_num
);
...
...
@@ -559,13 +584,18 @@ int main(void) {
printf
(
"
\n
"
);
printf
(
"Overall trace stats:
\n
"
);
printf
(
"
\n
"
);
printf
(
" n_lines_played: %9"
PRIu64
"
\n
"
,
stats
.
n_lines_replayed
);
printf
(
" n_create: %9"
PRIu64
"
\n
"
,
stats
.
n_create
);
printf
(
" n_create_from_blockpairs: %9"
PRIu64
"
\n
"
,
stats
.
n_create_from_blockpairs
);
printf
(
" n_alloc_hot: %9"
PRIu64
"
\n
"
,
stats
.
n_alloc_hot
);
printf
(
" n_alloc_cold: %9"
PRIu64
"
\n
"
,
stats
.
n_alloc_cold
);
printf
(
" n_free: %9"
PRIu64
"
\n
"
,
stats
.
n_free
);
printf
(
" n_destroy: %9"
PRIu64
"
\n
"
,
stats
.
n_destroy
);
printf
(
" n_lines_played: %15"
PRIu64
"
\n
"
,
stats
.
n_lines_replayed
);
printf
(
" n_create: %15"
PRIu64
"
\n
"
,
stats
.
n_create
);
printf
(
" n_create_from_blockpairs: %15"
PRIu64
"
\n
"
,
stats
.
n_create_from_blockpairs
);
printf
(
" n_alloc_hot: %15"
PRIu64
"
\n
"
,
stats
.
n_alloc_hot
);
printf
(
" n_alloc_cold: %15"
PRIu64
"
\n
"
,
stats
.
n_alloc_cold
);
printf
(
" n_free: %15"
PRIu64
"
\n
"
,
stats
.
n_free
);
printf
(
" n_destroy: %15"
PRIu64
"
\n
"
,
stats
.
n_destroy
);
printf
(
"
\n
"
);
printf
(
" avg_alloc_hot: %15"
PRIu64
"
\n
"
,
stats
.
alloc_hot_bytes
.
mean
);
printf
(
" stddev_alloc_hot: %15"
PRIu64
"
\n
"
,
(
uint64_t
)
sqrt
(
stats
.
alloc_hot_bytes
.
variance
));
printf
(
" avg_alloc_cold: %15"
PRIu64
"
\n
"
,
stats
.
alloc_cold_bytes
.
mean
);
printf
(
" stddev_alloc_cold: %15"
PRIu64
"
\n
"
,
(
uint64_t
)
sqrt
(
stats
.
alloc_cold_bytes
.
variance
));
printf
(
"
\n
"
);
return
0
;
...
...
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