Following the "pause" engendered by the midterm exam, this assignment gets us back on track with OSTEP readings associated with memory management (e.g., paging, TLB) and performance measurement.
Specifically, your assignment is
Questions
For timing, you’ll need to use a timer (e.g.,gettimeofday()). How precise is such a timer? How long does an operation have to take in order for you to time it precisely? (this will help deter- mine how many times, in a loop, you’ll have to repeat a page access in order to time it successfully)
Writetheprogram,calledtlb.c,thatcanroughlymeasurethecost of accessing each page. Inputs to the program should be: the num- ber of pages to touch and the number of trials.
Now write a script in your favorite scripting language (bash?) to run this program, while varying the number of pages accessed from 1 up to a few thousand, perhaps incrementing by a factor of two per iteration. Run the script on different machines and gather some data. How many trials are needed to get reliable measurements?
Next, graph the results, making a graph that looks similar to the one above. Use a good tool likeploticusor evenzplot. Visual- ization usually makes the data much easier to digest; why do you think that is?
One thing to watch out for is compiler optimization. Compilers do all sorts of clever things, including removing loops which incre- ment values that no other part of the program subsequently uses. How can you ensure the compiler does not remove the main loop above from your TLB size estimator?
Another thing to watch out for is the fact that most systems today ship with multiple CPUs, and each CPU, of course, has its own TLB hierarchy. To really get good measurements, you have to run your code on just one CPU, instead of letting the scheduler bounce it from one CPU to the next. How can you do that? (hint: look up “pinning a thread” on Google for some clues) What will happen if you don’t do this, and the code moves from one CPU to the other?
Another issue that might arise relates to initialization. If you don’t initialize the arrayaabove before accessing it, the first time you access it will be very expensive, due to initial access costs such as demand zeroing. Will this affect your code and its timing? What can you do to counterbalance these potential costs?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here