Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
fadb7502
Commit
fadb7502
authored
Jul 16, 2009
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Partial ordering of traverses: reduces number of deadlocks by factor of 10.
parent
fdc6fb3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
1 deletion
+78
-1
ccan/tdb/tools/replay_trace.c
ccan/tdb/tools/replay_trace.c
+78
-1
No files found.
ccan/tdb/tools/replay_trace.c
View file @
fadb7502
...
...
@@ -941,9 +941,15 @@ static bool in_transaction(const struct op op[], unsigned int i)
return
op
[
i
].
group_start
&&
is_transaction
(
&
op
[
op
[
i
].
group_start
]);
}
static
bool
is_traverse
(
const
struct
op
*
op
)
{
return
op
->
op
==
OP_TDB_TRAVERSE_START
||
op
->
op
==
OP_TDB_TRAVERSE_READ_START
;
}
static
bool
in_traverse
(
const
struct
op
op
[],
unsigned
int
i
)
{
return
op
[
i
].
group_start
&&
!
is_transaction
(
&
op
[
op
[
i
].
group_start
]);
return
op
[
i
].
group_start
&&
is_traverse
(
&
op
[
op
[
i
].
group_start
]);
}
static
struct
keyinfo
*
hash_ops
(
struct
op
*
op
[],
unsigned
int
num_ops
[],
...
...
@@ -1393,6 +1399,73 @@ static void optimize_dependencies(struct op *op[], unsigned int num_ops[],
}
}
#if TRAVERSALS_TAKE_TRANSACTION_LOCK
struct
traverse_dep
{
unsigned
int
file
;
unsigned
int
op_num
;
};
/* Force an order among the traversals, so they don't deadlock (as much) */
static
void
make_traverse_depends
(
char
*
filename
[],
struct
op
*
op
[],
unsigned
int
num_ops
[],
unsigned
int
num
)
{
unsigned
int
i
,
num_traversals
=
0
;
int
j
;
struct
traverse_dep
*
dep
;
/* Sort by which one runs first. */
int
compare_traverse_dep
(
const
void
*
_a
,
const
void
*
_b
)
{
const
struct
traverse_dep
*
ta
=
_a
,
*
tb
=
_b
;
const
struct
op
*
a
=
&
op
[
ta
->
file
][
ta
->
op_num
],
*
b
=
&
op
[
tb
->
file
][
tb
->
op_num
];
if
(
a
->
serial
!=
b
->
serial
)
return
a
->
serial
-
b
->
serial
;
/* If they have same serial, it means one didn't make any
* changes. Thus sort by end in that case. */
return
a
[
a
->
group_len
].
serial
-
b
[
b
->
group_len
].
serial
;
}
dep
=
talloc_array
(
NULL
,
struct
traverse_dep
,
1
);
/* Count them. */
for
(
i
=
0
;
i
<
num
;
i
++
)
{
for
(
j
=
1
;
j
<
num_ops
[
i
];
j
++
)
{
/* Traverse start (ignore those in
* transactions; they're already covered by
* transaction dependencies). */
if
(
is_traverse
(
&
op
[
i
][
j
])
&&
!
in_transaction
(
op
[
i
],
j
))
{
dep
=
talloc_realloc
(
NULL
,
dep
,
struct
traverse_dep
,
num_traversals
+
1
);
dep
[
num_traversals
].
file
=
i
;
dep
[
num_traversals
].
op_num
=
j
;
num_traversals
++
;
}
}
}
qsort
(
dep
,
num_traversals
,
sizeof
(
dep
[
0
]),
compare_traverse_dep
);
for
(
i
=
1
;
i
<
num_traversals
;
i
++
)
{
const
struct
op
*
prev
=
&
op
[
dep
[
i
-
1
].
file
][
dep
[
i
-
1
].
op_num
];
/* Only make dependency if it's clear. */
if
(
compare_traverse_dep
(
&
dep
[
i
],
&
dep
[
i
-
1
]))
{
/* i depends on end of traverse i-1. */
add_dependency
(
NULL
,
op
,
filename
,
dep
[
i
].
file
,
dep
[
i
].
op_num
,
dep
[
i
-
1
].
file
,
dep
[
i
-
1
].
op_num
+
prev
->
group_len
);
}
}
talloc_free
(
dep
);
}
#endif
static
void
derive_dependencies
(
char
*
filename
[],
struct
op
*
op
[],
unsigned
int
num_ops
[],
unsigned
int
num
)
...
...
@@ -1435,6 +1508,10 @@ static void derive_dependencies(char *filename[],
}
}
#if TRAVERSALS_TAKE_TRANSACTION_LOCK
make_traverse_depends
(
filename
,
op
,
num_ops
,
num
);
#endif
optimize_dependencies
(
op
,
num_ops
,
num
);
}
...
...
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