"I wish it need not have happened in my time," said Frodo.
"So do I," said Gandalf, "and so do all who live to see such times. But that
is not for them to decide. All we have to decide is what to do with the time
that is given, us."
—The Fellowship of the Ring , Book 1, Chapter 2
Benchmarking programs is a common task that drives decisions about where and how to invest the effort of software developers. This task can be very simple to very complex, depending on desired accuracy and the kind of code being profiled. In an OS, code that is run very infrequently or at a low priority doesn't need to be validated to as high a standard as code that runs very frequently (such as the system timer interrupt handler) or at high priority (such as real-time priority). Benchmarking in userspace serves as an introduction to the concepts behind benchmarking in the kernel, and it allows us to measure the impact of the kernel on userspace performance.
In this studio, you will:
Please complete the required exercises below, as well as any optional enrichment exercises that you wish to complete.
As you work through these exercises, please record your answers, and when finished email your results to dferry@email.wustl.edu with the phrase Userspace Benchmarking in the subject line.
Make sure that the name of each person who worked on these exercises is listed in the first answer, and make sure you number each of your responses so it is easy to match your responses with each exercise.
time
. This is
actually a special command built into the bash shell, so its documentation
can be found under man bash
. As the answer to this exercise,
use this command to make a few timings of the test programs and copy the
results here.
time
command outputs three different timings. List them
here and explain the difference.
user
and real
timings? Explain your observations.
time ./dense_mm 400
time ./parallel_dense_mm 400
user
and sys
timings?
Look at the code in sing.c
and explain your observations.
time ./sing 1000
clock_getres
. You can access the documentation
for this function in the manual pages: man clock_getres
.
Warning: Internet versions of
man pages are often not up to date. Use the version on your machine.
Look through the clocks available at the clock_getres
man page.
For this exercise, give two clock names. For the first, give a clock that would
be well suited for userspace benchmarking, and explain why. For the second,
give a clock that would be poorly suited for userspace benchmarking, and
explain why.
clock_getres
to write a short program called
getres.c
that gives
the resolutions for several different clock types. This function requires
using a structure called a timespec
which is also documented at
the same man page, and is the basic data structure used to report timing
information from the kernel to userspace.
As the answer to this exercise, copy and paste your program output.
Include at least one _COARSE
clock type.
CLOCK_MONOTONIC
and CLOCK_MONOTONIC_COARSE
.
clock_gettime
to figure out how long a call to
clock_gettime
takes. As the answer to this exercise,
report this value.
parallel_dense_mm.c
. First modify it so
that you time the critical computational loop with the clock
CLOCK_MONOTONIC_RAW
. Then modify it again so that the program
takes a second parameter and executes the timed segment multiple times. Your
program should output the minimum, average, and maximum timings over all
timed iterations.
Leave the answer to this exercise blank
In addition to the answers above, please submit: