120 likes | 193 Views
V Storage Manager. Shahram Ghandeharizadeh Computer Science Department University of Southern California. Traces. Make sure your persistent BDB is configured with 256 MB of memory.
E N D
V Storage Manager Shahram Ghandeharizadeh Computer Science Department University of Southern California
Traces • Make sure your persistent BDB is configured with 256 MB of memory. • With a trace, say 21, use its “21Objs.Save” to create and populate your persistent database. Subsequently, use its “Trace21.1KGet” to debug your software. • Start with 1 thread and expand to 2, 3, and 4. • Try to make your software as efficient as possible. If it is too slow (maybe because of low byte hit rates) then you may not be able to run “Trace21.1MGet”.
Questions • Will there be another release of the workload generator before Friday? • I do not anticipate one unless there is a bug report. • Is there an obvious item missing from the current workload generator? • Mandatory: Invocation of the method to report cache and byte hit rates. • Optional: Dump the content of the cache to analyze the behavior of your cache replacement technique.
Hints • BDB-Disk is a full-fledged storage manager with a buffer pool, locking, crash-recovery, index structures. • Configure its buffer pool size to be 256 MB. V Functionalities Cache Replacement BDB-Disk BDB-Mem
Hints • Your implementation may need to keep track of different counters. Example: count the number of requests issued (and the number of requests serviced from the main-memory instance of BDB) to compute the cache hit rate. • How to do this with multiple worker threads?
Hints • Your implementation may need to keep track of different counters. Example: count the number of requests issued to compute the cache hit rate. • How to do this with multiple worker threads? • The interlocked function provides a mechanism for synchronizing access to a variable that is shared by multiple threads. • You may define a “long” variable and use InterlockedIncrement: “long cntr; InterlockedIncrement(&cntr);” • Make sure to include <windows.h>
Hints • To compute byte hit rates, you need to maintain two counters and increment them by the size of the referenced object. • Use “InterlockedExchangeAdd” function to perform an atomic addition of two 32 bit values. • Example: a = a + b; • InterlockedExchangeAdd(&a, &b); • Other Interlocked methods might be useful to you, such as InterlockedExchangePointer.
Hints • With invocation of methods, local variables are pushed on the stack of a thread. • 4 different threads invoking a method will have 4 different sets of mutually exclusive local variables as declared by that method. Foo(){ Char res[200]; Int cntr; … } • A global variable is not part of the stack and must be protected when multiple threads are manipulating it. How?
Hints • With invocation of methods, local variables are pushed on the stack of a thread. • 4 different threads invoking a method will have 4 different sets of mutually exclusive local variables as declared by that method. Foo(){ Char res[200]; Int cntr; … } • A global variable is not part of the stack and must be protected when multiple threads are manipulating it. How? • Consider making it a variable local to a method. Ask: Does this variable have to be global? • Use critical sections. • Manage memory.
Hints • With invocation of methods, local variables are pushed on the stack of a thread. • 4 different threads invoking a method will have 4 different sets of mutually exclusive local variables as declared by that method. Foo(){ Char res[200]; Int cntr; … } • Similarly, memory allocated from the heap (new/malloc) is not a part of the stack and must be managed. • No memory-leaks.
Hints • Consider an admission control technique. • Without admission control: • Everytime an object is referenced and it is not in memory then you place it in memory. • With admission control: • Every time a disk resident object is referenced, compare its Q value with the minimum Q value to see if it should be admitted into memory.