210 likes | 351 Views
Data layouts for object-oriented programs. Martin Hirzel IBM Research SIGMETRICS 6/16/2007. Object-oriented programs put data in objects. Caches and TLBs put data in blocks. Scattering objects over blocks causes cache/TLB misses. Misses cost time. Problem. o 1. o 5. o 6. o 8. o 2. o 3.
E N D
Data layouts forobject-oriented programs Martin HirzelIBM Research SIGMETRICS 6/16/2007
Object-oriented programs put datain objects. Caches and TLBs put data in blocks. Scattering objects over blocks causes cache/TLB misses. Misses cost time. Problem o1 o5 o6 o8 o2 o3 o7 o10 o4 o9 o11 cache line TLB page
Most object-oriented languages use garbage collection. Garbage collection can move objects. To avoid misses, move objects to the right cache/TLB blocks. Simple, right? Solution o1 o5 o6 o8 o2 o3 o7 o10 o4 o9 o11 o1 o2 o3 o4 o9 o10 o11 o5 o6 o7 o8
scan=free scan scan scan scan free free free free Cheney Copying GC From-space o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 To-space Copied ¬ yet scanned Copied & scanned
BF: Breadth-first layout 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DF: Depth-first layout 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HI: Hierarchical layout 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
AO: Allocation order layout 1 2d 3 4d 5d 6 7 8d 9 1c 3c 6c 7c 9c
SZ: Size segregation layout 1 2 3d 4 5d 6 7 8d 9 1c 6c 2c 7c 9c 4c
TH: Thread local layout 001 010 1 8 3 111 11 2 4 9 12 101 110 10 6 5 7 100
Which layout is best, and which is worst? How much does it matter in practice? How similar are the layouts? How much does it matter in the limit? Problem
Solutions? • Appeal to intuition • They can’t all be right! • Formal • Petrank/Rawitz showed hardness • Simulation • Who would believe those numbers? • Brute-force • Do you have a few person-years to spare?
Avoiding Heisenberg Effects Garbage collector Garbage collector Garbage collector Application Application Time • Exclude garbage collector performance • Measure real effect of layout on application • Implement the layouts with simple algorithms
Object sorting garbage collection populate sort copy fixup Sort keys: AO, AS, PO, RA, SZ, TH, TY
% Mutator time overhead • All layouts sometimes best, sometimes worst • RA is worst, as expected • Low averages, but beware of worst cases! • AO has best average (but not by much) • DF has most best cases • TH has most benign worst case • Performance impact increases with SMP • Conclusions for AO, DF, TH, RA still hold
% Mutator miss rate increases • Layouts have large impact on miss rates • Miss rates confirm overhead conclusions • Miss rates can not replace time measurements
Layout similarities and differences • AO, PO, and TH are quite similar • As expected, RA is far out
Benchmarks:largest avg. overhead Baseline:best observed Linear regression: Estimated limit mutator time
Conclusions • Layouts matter little on average, but: • Beware of the worst cases! • Layout importance increases with SMP • All layouts are sometimes best,sometimes worst • AO has best average • DF has most best-cases • TH has best worst-cases