Bug 107311 - [patch] benchmarks/raidtest: make more accurate and avoid crashes
Summary: [patch] benchmarks/raidtest: make more accurate and avoid crashes
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Pawel Jakub Dawidek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-29 11:30 UTC by Vasil Dimov
Modified: 2007-01-23 10:30 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vasil Dimov freebsd_committer freebsd_triage 2006-12-29 11:30:19 UTC
raidtest receives SIGFPE:

Core was generated by `raidtest'.
Program terminated with signal 8, Arithmetic exception.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x000000000040185c in show_stats (secs=0, nbytes=12815872, nreqs=200)
    at raidtest.c:260
260             printf("Bytes per second: %ju\n", nbytes / secs);
(gdb) bt
#0  0x000000000040185c in show_stats (secs=0, nbytes=12815872, nreqs=200)
    at raidtest.c:260
#1  0x0000000000402000 in raidtest_test (argc=0, argv=0x7fffffffea98)
    at raidtest.c:407
#2  0x000000000040207c in main (argc=6, argv=0x7fffffffea68) at raidtest.c:421

The reason for this is obvious: secs is 0.

Fix: In addition to avoiding the division by zero this patch makes raidtest
more accurate by not truncating seconds fractions.



-- 
Vasil Dimov
gro.DSBeerF@dv
%
The Roman Rule
        The one who says it cannot be done should never interrupt the
        one who is doing it.--9T6inmKABCAjzjTD3cndORtAcbHcFIK5ojU7Paq0GDoMvKI3
Content-Type: text/plain; name="raidtest_accuracy.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="raidtest_accuracy.diff"

Index: Makefile
===================================================================
RCS file: /usr/local/pcvs/ports/benchmarks/raidtest/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile	7 May 2006 12:31:44 -0000	1.4
+++ Makefile	29 Dec 2006 10:15:31 -0000
@@ -7,7 +7,7 @@
 #
 
 PORTNAME=	raidtest
-PORTVERSION=	1.0
+PORTVERSION=	1.1
 CATEGORIES=	benchmarks
 MASTER_SITES=	# none
 DISTFILES=	# none
Index: files/Makefile
===================================================================
RCS file: /usr/local/pcvs/ports/benchmarks/raidtest/files/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- files/Makefile	5 Dec 2004 04:13:29 -0000	1.1
+++ files/Makefile	29 Dec 2006 10:15:31 -0000
@@ -1,7 +1,7 @@
 # $FreeBSD: ports/benchmarks/raidtest/files/Makefile,v 1.1 2004/12/05 04:13:29 obrien Exp $
 
 PROG=	raidtest
-NOMAN=	true
+NO_MAN=	true
 WARNS?=	6
 BINDIR?= ${PREFIX}/bin
 
Index: files/raidtest.c
===================================================================
RCS file: /usr/local/pcvs/ports/benchmarks/raidtest/files/raidtest.c,v
retrieving revision 1.3
diff -u -r1.3 raidtest.c
--- files/raidtest.c	29 Dec 2004 01:57:28 -0000	1.3
+++ files/raidtest.c	29 Dec 2006 10:15:31 -0000
@@ -254,11 +254,11 @@
 }
 
 static void
-show_stats(long secs, uintmax_t nbytes, uintmax_t nreqs)
+show_stats(double secs, uintmax_t nbytes, uintmax_t nreqs)
 {
 
-	printf("Bytes per second: %ju\n", nbytes / secs);
-	printf("Requests per second: %ju\n", nreqs / secs);
+	printf("Bytes per second: %ju\n", (uintmax_t)(nbytes / secs));
+	printf("Requests per second: %ju\n", (uintmax_t)(nreqs / secs));
 }
 
 static void
@@ -266,7 +266,7 @@
 {
 	uintmax_t i, nbytes, nreqs, nrreqs, nwreqs, reqs_per_proc, nstart;
 	const char *dev, *file = NULL;
-	struct timeval tstart, tend;
+	struct timeval tstart, tend, tdiff;
 	struct ioreq *iorqs;
 	unsigned nprocs;
 	struct stat sb;
@@ -404,7 +404,9 @@
 		wait(&status);
 	}
 	gettimeofday(&tend, NULL);
-	show_stats(tend.tv_sec - tstart.tv_sec, nbytes, nreqs);
+	timersub(&tend, &tstart, &tdiff);
+	show_stats(tdiff.tv_sec + (double)tdiff.tv_usec / 1000000,
+		   nbytes, nreqs);
 }
 
 int
How-To-Repeat: 
Run test which finishes in less than one second.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2006-12-29 11:31:17 UTC
Responsible Changed
From-To: freebsd-ports-bugs->pjd

Over to maintainer
Comment 2 dfilter service freebsd_committer freebsd_triage 2007-01-23 10:26:12 UTC
vd          2007-01-23 10:26:06 UTC

  FreeBSD ports repository

  Modified files:
    benchmarks/raidtest  Makefile 
    benchmarks/raidtest/files Makefile raidtest.c 
  Log:
  * Make benchmarks/raidtest more accurate and avoid crashes
  * Bump PORTVERSION
  * s/NOMAN/NO_MAN
  
  PR:             ports/107311
  Submitted by:   vd
  Approved by:    pjd@FreeBSD.org (maintainer timeout)
  
  Revision  Changes    Path
  1.5       +1 -1      ports/benchmarks/raidtest/Makefile
  1.2       +1 -1      ports/benchmarks/raidtest/files/Makefile
  1.4       +8 -6      ports/benchmarks/raidtest/files/raidtest.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 3 Vasil Dimov freebsd_committer freebsd_triage 2007-01-23 10:26:25 UTC
State Changed
From-To: open->closed

Committed (maintainer timeout)