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
1f9a77d3
Commit
1f9a77d3
authored
Jul 22, 2014
by
John Esmet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FT-300 Use an environment variable to determine which file the block
allocator trace gets written to
parent
a0252cbe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
24 deletions
+54
-24
ft/serialize/block_allocator.cc
ft/serialize/block_allocator.cc
+38
-18
ft/serialize/block_allocator.h
ft/serialize/block_allocator.h
+8
-0
ft/serialize/ft_node-serialize.cc
ft/serialize/ft_node-serialize.cc
+8
-6
No files found.
ft/serialize/block_allocator.cc
View file @
1f9a77d3
...
...
@@ -106,12 +106,32 @@ PATENT RIGHTS GRANT:
#define VALIDATE()
#endif
static
inline
bool
ba_trace_enabled
()
{
#if 0
return true;
#else
return
false
;
#endif
static
FILE
*
ba_trace_file
=
nullptr
;
void
block_allocator
::
maybe_initialize_trace
(
void
)
{
const
char
*
ba_trace_path
=
getenv
(
"TOKU_BA_TRACE_PATH"
);
if
(
ba_trace_path
!=
nullptr
)
{
ba_trace_file
=
toku_os_fopen
(
ba_trace_path
,
"w"
);
if
(
ba_trace_file
==
nullptr
)
{
fprintf
(
stderr
,
"tokuft: error: block allocator trace path found in environment (%s), "
"but it could not be opened for writing (errno %d)
\n
"
,
ba_trace_path
,
get_maybe_error_errno
());
}
else
{
fprintf
(
stderr
,
"tokuft: block allocator tracing enabled, path: %s
\n
"
,
ba_trace_path
);
}
}
}
void
block_allocator
::
maybe_close_trace
()
{
if
(
ba_trace_file
!=
nullptr
)
{
int
r
=
toku_os_fclose
(
ba_trace_file
);
if
(
r
!=
0
)
{
fprintf
(
stderr
,
"tokuft: error: block allocator trace file did not close properly (r %d, errno %d)
\n
"
,
r
,
get_maybe_error_errno
());
}
else
{
fprintf
(
stderr
,
"tokuft: block allocator tracing finished, file closed successfully
\n
"
);
}
}
}
void
block_allocator
::
_create_internal
(
uint64_t
reserve_at_beginning
,
uint64_t
alignment
)
{
...
...
@@ -131,16 +151,16 @@ void block_allocator::_create_internal(uint64_t reserve_at_beginning, uint64_t a
void
block_allocator
::
create
(
uint64_t
reserve_at_beginning
,
uint64_t
alignment
)
{
_create_internal
(
reserve_at_beginning
,
alignment
);
if
(
ba_trace_
enabled
()
)
{
fprintf
(
stderr
,
"ba_trace_create %p
\n
"
,
this
);
if
(
ba_trace_
file
!=
nullptr
)
{
fprintf
(
ba_trace_file
,
"ba_trace_create %p
\n
"
,
this
);
}
}
void
block_allocator
::
destroy
()
{
toku_free
(
_blocks_array
);
if
(
ba_trace_
enabled
()
)
{
fprintf
(
stderr
,
"ba_trace_destroy %p
\n
"
,
this
);
if
(
ba_trace_
file
!=
nullptr
)
{
fprintf
(
ba_trace_file
,
"ba_trace_destroy %p
\n
"
,
this
);
}
}
...
...
@@ -264,8 +284,8 @@ done:
_n_blocks
++
;
VALIDATE
();
if
(
ba_trace_
enabled
()
)
{
fprintf
(
stderr
,
"ba_trace_alloc %p %lu %lu
\n
"
,
if
(
ba_trace_
file
!=
nullptr
)
{
fprintf
(
ba_trace_file
,
"ba_trace_alloc %p %lu %lu
\n
"
,
this
,
static_cast
<
unsigned
long
>
(
size
),
static_cast
<
unsigned
long
>
(
*
offset
));
}
}
...
...
@@ -282,11 +302,11 @@ int64_t block_allocator::find_block(uint64_t offset) {
uint64_t
lo
=
0
;
uint64_t
hi
=
_n_blocks
;
while
(
1
)
{
assert
(
lo
<
hi
);
// otherwise no such block exists.
uint64_t
mid
=
(
lo
+
hi
)
/
2
;
assert
(
lo
<
hi
);
// otherwise no such block exists.
uint64_t
mid
=
(
lo
+
hi
)
/
2
;
uint64_t
thisoff
=
_blocks_array
[
mid
].
offset
;
if
(
thisoff
<
offset
)
{
lo
=
mid
+
1
;
lo
=
mid
+
1
;
}
else
if
(
thisoff
>
offset
)
{
hi
=
mid
;
}
else
{
...
...
@@ -305,13 +325,13 @@ void block_allocator::free_block(uint64_t offset) {
int64_t
bn
=
find_block
(
offset
);
assert
(
bn
>=
0
);
// we require that there is a block with that offset.
_n_bytes_in_use
-=
_blocks_array
[
bn
].
size
;
memmove
(
&
_blocks_array
[
bn
],
&
_blocks_array
[
bn
+
1
],
memmove
(
&
_blocks_array
[
bn
],
&
_blocks_array
[
bn
+
1
],
(
_n_blocks
-
bn
-
1
)
*
sizeof
(
struct
blockpair
));
_n_blocks
--
;
VALIDATE
();
if
(
ba_trace_
enabled
()
)
{
fprintf
(
stderr
,
"ba_trace_free %p %lu
\n
"
,
if
(
ba_trace_
file
!=
nullptr
)
{
fprintf
(
ba_trace_file
,
"ba_trace_free %p %lu
\n
"
,
this
,
static_cast
<
unsigned
long
>
(
offset
));
}
...
...
ft/serialize/block_allocator.h
View file @
1f9a77d3
...
...
@@ -215,6 +215,14 @@ public:
// report->checkpoint_bytes_additional is ignored on return
void
get_statistics
(
TOKU_DB_FRAGMENTATION
report
);
// Block allocator tracing.
// - Enabled by setting TOKU_BA_TRACE_PATH to the file that the trace file
// should be written to.
// - Trace may be replayed by ba_trace_replay tool in tools/ directory
// eg: "cat mytracefile | ba_trace_replay"
static
void
maybe_initialize_trace
();
static
void
maybe_close_trace
();
private:
void
_create_internal
(
uint64_t
reserve_at_beginning
,
uint64_t
alignment
);
void
grow_blocks_array_by
(
uint64_t
n_to_add
);
...
...
ft/serialize/ft_node-serialize.cc
View file @
1f9a77d3
...
...
@@ -97,6 +97,7 @@ PATENT RIGHTS GRANT:
#include "ft/node.h"
#include "ft/logger/log-internal.h"
#include "ft/txn/rollback.h"
#include "ft/serialize/block_allocator.h"
#include "ft/serialize/block_table.h"
#include "ft/serialize/compress.h"
#include "ft/serialize/ft_node-serialize.h"
...
...
@@ -141,18 +142,19 @@ struct toku_thread_pool *get_ft_pool(void) {
return
ft_pool
;
}
void
toku_ft_serialize_layer_init
(
void
)
{
void
toku_ft_serialize_layer_init
(
void
)
{
num_cores
=
toku_os_get_number_active_processors
();
int
r
=
toku_thread_pool_create
(
&
ft_pool
,
num_cores
);
lazy_assert_zero
(
r
);
int
r
=
toku_thread_pool_create
(
&
ft_pool
,
num_cores
);
lazy_assert_zero
(
r
);
block_allocator
::
maybe_initialize_trace
();
}
void
toku_ft_serialize_layer_destroy
(
void
)
{
void
toku_ft_serialize_layer_destroy
(
void
)
{
toku_thread_pool_destroy
(
&
ft_pool
);
block_allocator
::
maybe_close_trace
();
}
enum
{
FILE_CHANGE_INCREMENT
=
(
16
<<
20
)
};
enum
{
FILE_CHANGE_INCREMENT
=
(
16
<<
20
)
};
static
inline
uint64_t
alignup64
(
uint64_t
a
,
uint64_t
b
)
{
...
...
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