- 论坛徽章:
- 0
|
Redhat Enterprise Advanced Server 3.0性能问题
i'll test system under different kernels.
Someone said
2.4.22-1.2115.nptlsmp from fedora solved his I/O probs.
I ued 2.4.22-1.2174 does not work.
run the following program
./test_write aaa 20 200
and do
/sbin/hdparm -Tt /dev/md2
while the program is running
from
http://www.redhat.com/archives/taroon-list/2003-December/msg00174.html
test_write.c
#include <stdio.h>;
#include <unistd.h>;
#include <errno.h>;
#include <stdlib.h>;
#include <string.h>;
#include <sys/types.h>;
#include <sys/stat.h>;
#include <fcntl.h>;
#include <sys/time.h>;
#define LOG_FILENAME "/tmp/error.log"
#define MAX_FILE_NAME 32
#define MILLISEC_DIFF(new, old, diff) { \
(diff) = (((new).tv_sec - (old).tv_sec) * 1000L ) + \
(((new).tv_usec - (old).tv_usec) / 1000L ); \
}
int main(int argc, char* argv[]) {
char* data, log_str[1024], filename[MAX_FILE_NAME];
int frequency, chunk_len, flags, elapsed, interval, sleep_time,
fd = -1, fd2 = -1;
struct timeval t1, t2;
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
if(argc != 4) {
printf("usage: test_writes filename frequency(eg. 20 for 50 ms) write_size(Bytes)\n" ;
_exit(1);
}
bzero(filename, MAX_FILE_NAME);
strncpy(filename, argv[1], MAX_FILE_NAME -1);
frequency = atoi(argv[2]);
chunk_len = atoi(argv[3]);
printf("filename <%s>; frequency <%d>; chunk_len <%d>;\n", filename, frequency, chunk_len);
flags = O_CREAT | O_WRONLY | O_TRUNC;
fd2 = open(LOG_FILENAME, O_WRONLY | O_CREAT | O_APPEND, mode);
fd = open(filename, flags);
if(fd < 0) {
perror("Unable to open the input file" ;
_exit(2);
}
if(fd2 < 0) {
perror("Unable to open the log file" ;
_exit(2);
}
data = (char*) malloc(sizeof(char)*chunk_len);
if(data == NULL) {
perror("Unable to allocate the input buffer" ;
_exit(3);
}
interval = (int)(((double)1000/frequency));
while(1) {
gettimeofday(&t1, NULL);
write(fd, data, chunk_len);
gettimeofday(&t2, NULL);
MILLISEC_DIFF(t2, t1, elapsed);
if(elapsed >;= interval) {
sprintf(log_str,"<%ld>;<%ld>; write to file <%s>;<%d>;\n", t1.tv_sec, t1.tv_usec/1000L, filename, elapsed);
write(fd2, log_str, strlen(log_str));
}
sleep_time = (interval - elapsed)*1000;
if(sleep_time >; 0)
usleep(sleep_time);
}
} |
|