Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
io_uring-open-bench
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Fischer
io_uring-open-bench
Commits
938b55d6
Commit
938b55d6
authored
3 years ago
by
Florian Fischer
Browse files
Options
Downloads
Patches
Plain Diff
separate function calls for more meaningful flamegraphs
parent
42d3c44c
No related branches found
No related tags found
No related merge requests found
Pipeline
#84155
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.cpp
+53
-33
53 additions, 33 deletions
main.cpp
with
53 additions
and
33 deletions
main.cpp
+
53
−
33
View file @
938b55d6
...
...
@@ -26,6 +26,57 @@ static void collect_paths(const std::string& root) {
paths
.
emplace_back
(
new
std
::
string
(
p
.
path
()));
}
static
auto
submit_and_wait
(
struct
io_uring
*
ring
)
->
int
{
#ifdef NDEBUG
__attribute__
((
unused
))
#endif
int
submitted
=
io_uring_submit_and_wait
(
ring
,
1
);
assert
(
submitted
==
1
);
struct
io_uring_cqe
*
cqe
;
if
(
io_uring_peek_cqe
(
ring
,
&
cqe
)
<
0
)
err
(
EXIT_FAILURE
,
"failed to peek cqe"
);
int
res
=
cqe
->
res
;
if
(
res
<
0
)
{
errno
=
-
res
;
err
(
EXIT_FAILURE
,
"opening failed"
);
}
io_uring_cqe_seen
(
ring
,
cqe
);
return
res
;
}
static
void
close_fd
(
struct
io_uring
*
ring
,
int
fd
)
{
struct
io_uring_sqe
*
sqe
=
io_uring_get_sqe
(
ring
);
assert
(
sqe
);
io_uring_prep_close
(
sqe
,
fd
);
sqe
->
flags
|=
IOSQE_CQE_SKIP_SUCCESS
;
#ifdef NDEBUG
__attribute__
((
unused
))
#endif
int
submitted
=
io_uring_submit
(
ring
);
assert
(
submitted
==
1
);
}
static
void
open_global
(
struct
io_uring
*
ring
,
const
char
*
path
)
{
struct
io_uring_sqe
*
sqe
=
io_uring_get_sqe
(
ring
);
assert
(
sqe
);
io_uring_prep_openat
(
sqe
,
AT_FDCWD
,
path
,
O_RDONLY
,
0
);
int
fd
=
submit_and_wait
(
ring
);
close_fd
(
ring
,
fd
);
}
static
void
open_direct
(
struct
io_uring
*
ring
,
const
char
*
path
,
unsigned
slot
)
{
struct
io_uring_sqe
*
sqe
=
io_uring_get_sqe
(
ring
);
assert
(
sqe
);
io_uring_prep_openat_direct
(
sqe
,
AT_FDCWD
,
path
,
O_RDONLY
,
0
,
slot
);
submit_and_wait
(
ring
);
}
static
void
thread_func
(
pthread_barrier_t
&
init_barrier
,
unsigned
id
,
bool
direct
)
{
struct
io_uring
ring
;
if
(
io_uring_queue_init
(
URING_ENTRIES
,
&
ring
,
0
)
<
0
)
...
...
@@ -48,41 +99,10 @@ static void thread_func(pthread_barrier_t& init_barrier, unsigned id, bool direc
const
auto
*
p
=
paths
[
paths_offset
+
i
];
assert
(
p
->
c_str
());
struct
io_uring_sqe
*
sqe
=
io_uring_get_sqe
(
&
ring
);
assert
(
sqe
);
if
(
direct
)
{
io_uring_prep_openat_direct
(
sqe
,
AT_FDCWD
,
p
->
c_str
(),
O_RDONLY
,
0
,
i
%
URING_FILE_TABLE_SIZE
);
open_direct
(
&
ring
,
p
->
c_str
(),
i
%
URING_FILE_TABLE_SIZE
);
}
else
{
io_uring_prep_openat
(
sqe
,
AT_FDCWD
,
p
->
c_str
(),
O_RDONLY
,
0
);
}
#ifdef NDEBUG
__attribute__
((
unused
))
#endif
int
submitted
=
io_uring_submit_and_wait
(
&
ring
,
1
);
assert
(
submitted
==
1
);
struct
io_uring_cqe
*
cqe
;
if
(
io_uring_peek_cqe
(
&
ring
,
&
cqe
)
<
0
)
err
(
EXIT_FAILURE
,
"failed to peek cqe"
);
int
res
=
cqe
->
res
;
if
(
res
<
0
)
{
errno
=
-
res
;
err
(
EXIT_FAILURE
,
"%d: %sopening %s failed"
,
id
,
direct
?
"directly "
:
""
,
p
->
c_str
());
}
io_uring_cqe_seen
(
&
ring
,
cqe
);
if
(
!
direct
)
{
sqe
=
io_uring_get_sqe
(
&
ring
);
assert
(
sqe
);
io_uring_prep_close
(
sqe
,
res
);
sqe
->
flags
|=
IOSQE_CQE_SKIP_SUCCESS
;
submitted
=
io_uring_submit
(
&
ring
);
assert
(
submitted
==
1
);
open_global
(
&
ring
,
p
->
c_str
());
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment