Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
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
Abuhujair Javed
Postgres FD Implementation
Commits
933b17b6
Commit
933b17b6
authored
Aug 10, 2009
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust test_fsync code to be more sane.
Backpatch to 8.4.X.
parent
f3f6737a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
12 deletions
+29
-12
src/tools/fsync/test_fsync.c
src/tools/fsync/test_fsync.c
+29
-12
No files found.
src/tools/fsync/test_fsync.c
View file @
933b17b6
/*
/*
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.2
3 2009/06/11 14:49:15
momjian Exp $
* $PostgreSQL: pgsql/src/tools/fsync/test_fsync.c,v 1.2
4 2009/08/10 18:19:06
momjian Exp $
*
*
*
*
* test_fsync.c
* test_fsync.c
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define FSYNC_FILENAME "/var/tmp/test_fsync.out"
#define FSYNC_FILENAME "/var/tmp/test_fsync.out"
#endif
#endif
#define WRITE_SIZE (16 * 1024)
#define WRITE_SIZE (16 * 1024)
/* 16k */
void
die
(
char
*
str
);
void
die
(
char
*
str
);
void
print_elapse
(
struct
timeval
start_t
,
struct
timeval
elapse_t
);
void
print_elapse
(
struct
timeval
start_t
,
struct
timeval
elapse_t
);
...
@@ -71,6 +71,9 @@ main(int argc, char *argv[])
...
@@ -71,6 +71,9 @@ main(int argc, char *argv[])
buf
=
(
char
*
)
TYPEALIGN
(
ALIGNOF_XLOG_BUFFER
,
full_buf
);
buf
=
(
char
*
)
TYPEALIGN
(
ALIGNOF_XLOG_BUFFER
,
full_buf
);
/*
* Simple write
*/
printf
(
"Simple write timing:
\n
"
);
printf
(
"Simple write timing:
\n
"
);
/* write only */
/* write only */
gettimeofday
(
&
start_t
,
NULL
);
gettimeofday
(
&
start_t
,
NULL
);
...
@@ -87,8 +90,11 @@ main(int argc, char *argv[])
...
@@ -87,8 +90,11 @@ main(int argc, char *argv[])
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
/*
* Fsync another file descriptor?
*/
printf
(
"
\n
Compare fsync times on write() and non-write() descriptor:
\n
"
);
printf
(
"
\n
Compare fsync times on write() and non-write() descriptor:
\n
"
);
printf
(
"
(If the times are similar, fsync() can sync data written
\n
on a different descriptor.)
\n
"
);
printf
(
"
If the times are similar, fsync() can sync data written
\n
on a different descriptor.
\n
"
);
/* write, fsync, close */
/* write, fsync, close */
gettimeofday
(
&
start_t
,
NULL
);
gettimeofday
(
&
start_t
,
NULL
);
...
@@ -132,6 +138,9 @@ main(int argc, char *argv[])
...
@@ -132,6 +138,9 @@ main(int argc, char *argv[])
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
/*
* Compare 1 to 2 writes
*/
printf
(
"
\n
Compare one o_sync write to two:
\n
"
);
printf
(
"
\n
Compare one o_sync write to two:
\n
"
);
#ifdef OPEN_SYNC_FLAG
#ifdef OPEN_SYNC_FLAG
...
@@ -148,7 +157,7 @@ main(int argc, char *argv[])
...
@@ -148,7 +157,7 @@ main(int argc, char *argv[])
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
/*
2*
8k o_sync writes */
/*
Two
8k o_sync writes */
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
,
0
))
==
-
1
)
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
,
0
))
==
-
1
)
die
(
"Cannot open output file."
);
die
(
"Cannot open output file."
);
gettimeofday
(
&
start_t
,
NULL
);
gettimeofday
(
&
start_t
,
NULL
);
...
@@ -163,14 +172,16 @@ main(int argc, char *argv[])
...
@@ -163,14 +172,16 @@ main(int argc, char *argv[])
close
(
tmpfile
);
close
(
tmpfile
);
printf
(
"
\t
two 8k o_sync writes "
);
printf
(
"
\t
two 8k o_sync writes "
);
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
printf
(
"
\n
"
);
printf
(
"
\n
Compare file sync methods with one 8k write:
\n
"
);
#else
#else
printf
(
"
\t
(o_sync unavailable) "
);
printf
(
"
\t
(o_sync unavailable) "
);
#endif
#endif
printf
(
"
\n
"
);
printf
(
"
\n
"
);
/*
* Compare file sync methods with one 8k write
*/
printf
(
"
\n
Compare file sync methods with one 8k write:
\n
"
);
#ifdef OPEN_DATASYNC_FLAG
#ifdef OPEN_DATASYNC_FLAG
/* open_dsync, write */
/* open_dsync, write */
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
O_DSYNC
,
0
))
==
-
1
)
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
O_DSYNC
,
0
))
==
-
1
)
...
@@ -183,7 +194,11 @@ main(int argc, char *argv[])
...
@@ -183,7 +194,11 @@ main(int argc, char *argv[])
close
(
tmpfile
);
close
(
tmpfile
);
printf
(
"
\t
open o_dsync, write "
);
printf
(
"
\t
open o_dsync, write "
);
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
#else
printf
(
"
\t
(o_dsync unavailable) "
);
#endif
printf
(
"
\n
"
);
printf
(
"
\n
"
);
#ifdef OPEN_SYNC_FLAG
#ifdef OPEN_SYNC_FLAG
/* open_fsync, write */
/* open_fsync, write */
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
,
0
))
==
-
1
)
if
((
tmpfile
=
open
(
filename
,
O_RDWR
|
OPEN_SYNC_FLAG
,
0
))
==
-
1
)
...
@@ -196,9 +211,8 @@ main(int argc, char *argv[])
...
@@ -196,9 +211,8 @@ main(int argc, char *argv[])
close
(
tmpfile
);
close
(
tmpfile
);
printf
(
"
\t
open o_sync, write "
);
printf
(
"
\t
open o_sync, write "
);
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
#endif
#else
#else
printf
(
"
\t
(o_
d
sync unavailable) "
);
printf
(
"
\t
(o_sync unavailable) "
);
#endif
#endif
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
@@ -235,11 +249,14 @@ main(int argc, char *argv[])
...
@@ -235,11 +249,14 @@ main(int argc, char *argv[])
}
}
gettimeofday
(
&
elapse_t
,
NULL
);
gettimeofday
(
&
elapse_t
,
NULL
);
close
(
tmpfile
);
close
(
tmpfile
);
printf
(
"
\t
write, fsync
,
"
);
printf
(
"
\t
write, fsync
"
);
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
printf
(
"
\n
Compare file sync methods with 2 8k writes:
\n
"
);
/*
* Compare file sync methods with two 8k write
*/
printf
(
"
\n
Compare file sync methods with two 8k writes:
\n
"
);
#ifdef OPEN_DATASYNC_FLAG
#ifdef OPEN_DATASYNC_FLAG
/* open_dsync, write */
/* open_dsync, write */
...
@@ -318,7 +335,7 @@ main(int argc, char *argv[])
...
@@ -318,7 +335,7 @@ main(int argc, char *argv[])
}
}
gettimeofday
(
&
elapse_t
,
NULL
);
gettimeofday
(
&
elapse_t
,
NULL
);
close
(
tmpfile
);
close
(
tmpfile
);
printf
(
"
\t
write, fsync
,
"
);
printf
(
"
\t
write, fsync
"
);
print_elapse
(
start_t
,
elapse_t
);
print_elapse
(
start_t
,
elapse_t
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
...
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