Informed Prefetching and Caching R Hugo Patterson Garth

  • Slides: 33
Download presentation
Informed Prefetching and Caching R. Hugo Patterson, Garth A. Gibson, Eka Ginting, Daniel Stodolsky,

Informed Prefetching and Caching R. Hugo Patterson, Garth A. Gibson, Eka Ginting, Daniel Stodolsky, Jim Zelenka

Contribution n One of basic functions of file system: n n n Management of

Contribution n One of basic functions of file system: n n n Management of disk accesses Management of main-memory file buffers Approach: n n Use hints from I/O-intensive applications to prefetch aggressively enough to eliminate I/O stall time while maximizing buffer availability for caching Balance caching against prefetching How to allocate cache buffers dynamically among competing hinting and non-hinting applications for the greatest performance benefit Distribute cache buffers among competing applications

Motivation n n Storage parallelism CPU I/O performance dependence Cache cache-hit ratios I/O intensive

Motivation n n Storage parallelism CPU I/O performance dependence Cache cache-hit ratios I/O intensive applications: Amount of data processed >> file cache size n Locality is poor or limited n Frequently non-sequential accesses n Large I/O stall time/total execution time n Access patterns are largely predictable How can I/O workloads be improved to take full advantage of the hardware that already exists? n

ASAP: the four virtues of I/O workloads n n Avoidance: not a scalable solution

ASAP: the four virtues of I/O workloads n n Avoidance: not a scalable solution to the I/O bottleneck Sequentiality: scale for writes but not for reads Asynchrony: scalable through write buffering, scaling for reads depends on prefetching aggressiveness Parallelism: scalable for explicitly parallel I/O requests; but for serial workloads, scalable parallelisms achieved by scaling no. of asyn requests Asynchrony eliminates write latency, and parallelism provides throughput. No existing techniques scalably relieve the I/O bottleneck for reads. Aggressive prefetching

Prefetching n Aggressive prefetching for reads writing buffers for writes

Prefetching n Aggressive prefetching for reads writing buffers for writes

Hints n n n Historical Information: LRU cache replacement algorithm Sequential readahead: prefetching up

Hints n n n Historical Information: LRU cache replacement algorithm Sequential readahead: prefetching up to 64 blocks ahead when it detects long sequential runs Disclosure: hints based on advance knowledge n n n A mechanism for portable I/O optimizations Providing evidence for a policy decision Conforms to software engineering principles of modularity

Informed Prefetching n n n System: TIP-1 implemented in OSF/1, which has 2 I/O

Informed Prefetching n n n System: TIP-1 implemented in OSF/1, which has 2 I/O optimizations Application: 5 I/O-intensive benchmarks single threaded, data fetched from FS Hardware: DEC 3000/500 workstation, 1 150 MHz 21064 processor, 128 MB RAM, 5 KZTSA fast SCSI-2 adapters, each hosting 3 HP 2247 1 GB disks, 12 MB (1536 x 8 KB) cache 512 buffers (1/3 cache) Stripe unit: 64 KB Unread hinted prefetch Cluster prefetch: 5 prefetches. Disk scheduler: striper SCAN LRU count_unread_buffers--

Agrep n Agrep woodworking 224_newsgroup_msg: 358 disk blocks Read from the beginning to the

Agrep n Agrep woodworking 224_newsgroup_msg: 358 disk blocks Read from the beginning to the end

Agrep (cont’d) n Elapsed time for the sum of 4 searches is reduced by

Agrep (cont’d) n Elapsed time for the sum of 4 searches is reduced by up to 84%

Postgres n Join of two relations n n n Outer relation: 20, 000 unindexed

Postgres n Join of two relations n n n Outer relation: 20, 000 unindexed tuples (3. 2 MB) Inner relation: 200, 000 tuples (32 MB) and indexed (5 MB) Output about 4, 000 tuples written sequentially

Postgres (cont’d)

Postgres (cont’d)

Postgres (cont’d) n Elapsed time reduced by up to 55%

Postgres (cont’d) n Elapsed time reduced by up to 55%

MCHF Davidson algorithm n n MCHF: A suite of computational-chemistry programs used for atomic-structures

MCHF Davidson algorithm n n MCHF: A suite of computational-chemistry programs used for atomic-structures calculations Davidson algorithm: an element of MCHF that computes, by successive refinement, the extreme eigenvalue-eigenvector pairs of a large, sparse, real, symmetric matrix stored on disk Matrix size: 17 MB The algorithm repeatedly accesses the same large file sequentially.

MCHF Davidson algorithm (cont’d)

MCHF Davidson algorithm (cont’d)

MCHF Davidson algorithm (cont’d) n n Hints disclose only sequential access in one large

MCHF Davidson algorithm (cont’d) n n Hints disclose only sequential access in one large file. OSF/1’s aggressive readahead performs better than TIP-1. Neither OSF/1 nor informed prefetching alone uses the 12 MB of cache buffers well. LRU replacement algorithm flushes all of the blocks before any of them are reused.

Informed caching n n n Goal: allocate cache buffers to minimize application elapsed time

Informed caching n n n Goal: allocate cache buffers to minimize application elapsed time Approach: estimate the impact on execution time of alternative buffer allocations and then choose the best allocation 3 broad uses for each buffer: n Caching recently used data in the traditional LRU queue n Prefetching data according to hints n Caching data that a predictor indicates will be reused in the future

Three uses of cache buffers Difficult to estimate the performance of allocations at a

Three uses of cache buffers Difficult to estimate the performance of allocations at a global level

Cost-benefit analysis n n n System model: from which the various cost and benefit

Cost-benefit analysis n n n System model: from which the various cost and benefit estimates are derived Derivations: for each component Comparison: how to compare the estimates at a global level to find the globally least valuable buffer and the globally most beneficial consumer

System assumptions n Assumptions: n n n Modern OS with a file buffer cache

System assumptions n Assumptions: n n n Modern OS with a file buffer cache running on a uniprocessor with sufficient memory to make available number of cache buffers Workload emphasized on read-intensive applications All application I/O accesses request a single file block that can be read in a single disk access and that the requests are not too bursty. System parameters are constant. Enough parallelism, no congestion

System model Elapsed time Avg time to service an I/O req. # I/O req.

System model Elapsed time Avg time to service an I/O req. # I/O req. Avg app CPU time between requests Overhead: allocating of a buffer, queuing the request at the drive, and servicing the interrupt when the I/O completes

Cost of deallocating LRU buffer

Cost of deallocating LRU buffer

The benefit of prefetching Prefetching a block can mask some of the latency of

The benefit of prefetching Prefetching a block can mask some of the latency of a disk read, n is the upper bound of the benefit of fetching a block. n If the prefetch can be delayed and still complete before it is needed, we consider there to be no benefit from starting the prefetch now. . . . X. requests. . . prefetch consume n There is no benefit from prefetching further than P

The prefetch horizon

The prefetch horizon

Comparison of LRU cost to prefetching benefit n n Shared resources: cache buffers Common

Comparison of LRU cost to prefetching benefit n n Shared resources: cache buffers Common currency: T/access = T/buffer Rate of unhinted demand accesses Rate of hinted accesses A buffer should be reallocated from the LRU cache for prefetching

The cost of flushing a hinted block n When should we flush a hinted

The cost of flushing a hinted block n When should we flush a hinted block? flush n . . y. . accesses. . Cost: y-P Hint access P prefetch back

Putting it all together: global min-max n n n 3 estimates: Which block should

Putting it all together: global min-max n n n 3 estimates: Which block should be replaced when a buffer is needed for prefetching or to service a demand request? The globally least valuable block in the cache. Should a cache buffer be used to prefetch data now? Prefetch if the expected benefit is greater than the expected cost of flushing or stealing the least valuable block. Separate estimators for LRU cache and for each independent Stream of hints

Value estimators n LRU cache: i- th position if the LRU queue n Hint

Value estimators n LRU cache: i- th position if the LRU queue n Hint estimators: n n Global value=max(value_LRU, value_hint) Globally least valuable block = min(global value) A global min-max valuation of blocks

Informed caching example: MRU The informed cache manager discovers MRU caching without being specifically

Informed caching example: MRU The informed cache manager discovers MRU caching without being specifically coded to implement this policy.

Implementation of informed caching and prefetch

Implementation of informed caching and prefetch

Implementation of informed caching and prefetch(cont’d)

Implementation of informed caching and prefetch(cont’d)

Performance improvement by informed caching

Performance improvement by informed caching

Balance contention

Balance contention

Future work n n Richer hint languages to disclosure future accesses Strategies for dealing

Future work n n Richer hint languages to disclosure future accesses Strategies for dealing with imprecise but still useful hints Cost-benefit model adapted to nonuniform bandwidths Extensibility, e. g. : VM estimator to track VM pages