Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
misc
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
misc
Commits
43f6d98d
Commit
43f6d98d
authored
Dec 11, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X bench for fallocate on tmpfs
parent
24397957
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
0 deletions
+83
-0
tmpfs/.gitignore
tmpfs/.gitignore
+1
-0
tmpfs/1.txt
tmpfs/1.txt
+6
-0
tmpfs/t_fallocate.c
tmpfs/t_fallocate.c
+76
-0
No files found.
tmpfs/.gitignore
0 → 100644
View file @
43f6d98d
a.out
tmpfs/1.txt
0 → 100644
View file @
43f6d98d
host: deco
os: Linux deco 4.13.0-1-amd64 #1 SMP Debian 4.13.13-1 (2017-11-16) x86_64 GNU/Linux
BenchmarkTmpfsFallocate/xpage=4K 786432 0.448 µs/op # t_total: 0.352s
BenchmarkTmpfsFallocate/xpage=32K 98304 2.653 µs/op # t_total: 0.261s
BenchmarkTmpfsFallocate/xpage=256K 12288 20.263 µs/op # t_total: 0.249s
BenchmarkTmpfsFallocate/xpage=2048K 1536 161.343 µs/op # t_total: 0.248s
tmpfs/t_fallocate.c
0 → 100644
View file @
43f6d98d
// This program benchmarks fallocate on tmpfs
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/user.h>
#include <sys/mman.h>
// microtime returns current time as double
double
microtime
()
{
int
err
;
struct
timeval
tv
;
err
=
gettimeofday
(
&
tv
,
NULL
);
if
(
err
==
-
1
)
{
perror
(
"gettimeofday"
);
abort
();
}
return
tv
.
tv_sec
+
1E-6
*
tv
.
tv_usec
;
}
int
bench_tmpfs_fallocate
(
size_t
xpagesize
)
{
int
fd
,
err
,
i
;
double
Tstart
,
Tend
;
fd
=
open
(
"/dev/shm/y.dat"
,
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0666
);
if
(
fd
==
-
1
)
{
perror
(
"open"
);
abort
();
}
size_t
filesize
=
(
3
*
1024
*
1024
*
1024ULL
);
// whole file size
//size_t xpagesize = 1 * PAGE_SIZE;
//size_t xpagesize = 512 * PAGE_SIZE;
size_t
niter
=
filesize
/
xpagesize
;
err
=
ftruncate
(
fd
,
filesize
);
if
(
err
==
-
1
)
{
perror
(
"ftruncate"
);
abort
();
}
Tstart
=
microtime
();
for
(
i
=
0
;
i
<
niter
;
i
++
)
{
err
=
fallocate
(
fd
,
/*mode*/
0
,
i
*
xpagesize
,
xpagesize
);
if
(
err
==
-
1
)
{
perror
(
"fallocate"
);
abort
();
}
}
Tend
=
microtime
();
printf
(
"BenchmarkTmpfsFallocate/xpage=%ldK
\t
%ld
\t
%.3lf µs/op
\t
# t_total: %.3lfs
\n
"
,
xpagesize
/
1024
,
niter
,
(
Tend
-
Tstart
)
*
1E6
/
niter
,
(
Tend
-
Tstart
));
err
=
close
(
fd
);
if
(
err
==
-
1
)
{
perror
(
"close"
);
abort
();
}
return
0
;
}
int
main
()
{
bench_tmpfs_fallocate
(
1
*
PAGE_SIZE
);
bench_tmpfs_fallocate
(
8
*
PAGE_SIZE
);
bench_tmpfs_fallocate
(
64
*
PAGE_SIZE
);
bench_tmpfs_fallocate
(
512
*
PAGE_SIZE
);
}
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