|
SwapReplay
Design and usage details for SwapReplay infrastructure.
Kernel module + userspace utils to replay swap events in userspace. IntroductionA kernel module dumps <sector no.> <R/W bit> <compress len> to userspace in compact form. This is parsed using a parser lib which then presents event callback interface to these swap R/W event. We use this event interface to simulate same swapping activity in userspace. <compressed len> - On every swap-out, page is compressed and its compressed length is noted. We do not require actual data itself, so its not dumped. Detailscompcache project compresses and stores swap pages in memory. The most challenging part of project is to design allocator than can efficiently store these variable sized compressed pages. Simulating swapping activity allows us to see allocator behavior in userspace itself. This is much more friendly than rebooting, setting up workload to trigger swapping again and again. Also, gradual improvements to allocator will be easier to develop/debug in userspace. Following shows various components involved: sr_relay.ko (kernel mod): relays info to user. | | V sr_collect (user): collects data and dumps to a file. | | V libsr_parse.so (user lib): Parses data and provides callback interface to let client app process data. | +--> Sample client app: sr_data_histo - provides compressed page size histogram - easy to plot using gnuplot (see below). Details for individual components:sr_relay.ko (kernel mod)
insmod sr_relay.ko backing_dev=/dev/sdaXX Where /dev/sdaXX is partition where real swapping happens. Be very careful: if you specify wrong partition, all data there will be lost - it must be a valid swap partition.
swapon /dev/sr_relay -p 1
sr_collect (user app)
where, <input file> is /debug/sr_relay0 (assuming debugfs is mounted on /debug)<output file> is file where to dump data sent by sr_relay (e.g. ~/temp/sr_data) lib_srparse.so (user lib)
<libsr_parse.h> typedef void (swap_read_fn)(unsigned long index); typedef void (swap_write_fn)(unsigned long index, unsigned long len); /* * Arg: * 0: Sucess * >0: Error: partial read * <0: Error: file read error */ typedef void (replay_end_fn)(int err); int set_sr_file(const char *); int set_sr_callbacks(swap_read_fn, swap_write_fn, replay_end_fn); int sr_start(void); sr_data_histo (user app)
<commands at gnuplot prompt> set xlabel "Compressed page size" set ylabel "No. of pages" set xtics 0,256 plot "sample_sr_data_histo.txt" using 1:2 w boxes t "Compressed page size histogram"
(data is compressed using LZO1X). Here is MoreReplayData We will get info about allocator when we do actual alloc()/free() for these variable size chunks. Plan is to relay this data over TLSF allocator. This will provide data regarding its fragmentation and speed. In general, it will allow easy study/tweaking/testing of different compression algorithms and memory allocators. Collecting this replay data over variety of workloads will present more patterns which we can utilize. Resulting dump is small (just 151K for this sample data) so its easy to share too. |
Sign in to add a comment