home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / arch / 8974 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  5.8 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!hpscdc!hplextra!hpcc05!aspen!morris
  2. From: morris@aspen.NSA.HP.COM (Dale Morris)
  3. Newsgroups: comp.arch
  4. Subject: Re: Caches and Hashing
  5. Message-ID: <1360024@aspen.NSA.HP.COM>
  6. Date: 19 Aug 92 17:33:47 GMT
  7. References: <Bt5DKp.z0@netnews.jhuapl.edu>
  8. Organization: HP Networked Systems Architecture - Cupertino, CA
  9. Lines: 109
  10.  
  11.  
  12. John Hayes writes:
  13.  
  14. > There was an interesting idea in a recent article in Microprocessor
  15. > Report.  The article was describing HP's PA-RISC.  Here is what caught
  16. > my eye:
  17. >     "The caches are direct mapped to eliminate the performance
  18. >     impact of multiplexers that would be required with set-
  19. >     associativity.  To reduce the cache miss rates, the addresses
  20. >     are hashed before they drive the cache SRAMS."*
  21. > This raises several questions in my mind:
  22. > 1) How much does hashing improve the miss rate of a direct-mapped
  23. > cache?
  24.  
  25. Let me describe the rationale behind this.  The approaches people take
  26. to improving system performance can often be deeply intertwingled, so
  27. pardon me if some of this might appear "obvious".  Design context is
  28. important in evaluating something like this.
  29.  
  30. One of the working assumptions of caches is that, although there is
  31. temporal and spacial locality in the stream of memory references, on
  32. the whole, these references tend to cover the cache's index space
  33. somewhat uniformly.  This means that for a cache that is not fully
  34. associative, each of the sets (or each of the lines in a direct-mapped
  35. cache) has approximately the same utilization.
  36.  
  37. This is usually a good assumption for small caches and for caches
  38. which are physically indexed.  The behavior of small caches can be
  39. modelled accurately based on the reference patterns of single
  40. programs, since a small cache generally cannot hold the entire context
  41. of even one program.  Physically indexed caches benefit from the
  42. pseudo-random mapping function between virtual and physical addresses
  43. that tends to smear references across the cache.
  44.  
  45. HP's machines typically have a large cache system, and we use
  46. virtually-indexed caches (as many RISC companies do, to decrease the
  47. latency on loads).  With larger caches, one begins to see larger-scale
  48. patterns in memory reference, and utilization of the cache begins to
  49. become non-uniform.  The cache develops "hot spots".  Hashing the
  50. address tends to smear references across the cache.  The resulting
  51. improvement in performance varies tremendously with application, OS
  52. policy and even system configuration (like what mix of applications
  53. are running at any given time).  Something like SPEC benchmarks are
  54. affected very little, while large-scale transaction processing sees a
  55. substantial improvement.  I can't give any specific examples, but
  56. suffice it to say that the difference between different hashes is
  57. sufficient to warrant a good deal of work in chosing the specifics of
  58. the hash.
  59.  
  60.  
  61. > 2) The argument for direct mapped caches is that they have a better
  62. > effective access time than set-associative caches because direct
  63. > mapped caches do not need multiplexers to select the data.  Would
  64. > the cost of hashing eliminate this advantage?  In other words:
  65. > would a direct mapped cache with hashing or a set-associative
  66. > cache (with associated multiplexers) give the best performance?
  67.  
  68. There is an additional benefit of direct mapped caches over
  69. set-associative.  Generally pipelines are optimized for cache hits,
  70. because there is usually a little time to do some backing up on cache
  71. misses while you're waiting for the data.  So, with a direct-mapped
  72. cache, when the data pops out the processor runs with it and does not
  73. wait for the tag compare.  The compare is done in parallel with
  74. subsequent processing.  Removing the tag match from the basic load-use
  75. cycle adds a lot to performance.  With a set-associative cache this
  76. can't be done unless you do some fairly costly functional unit
  77. replication.  This problem can be gotten around by building "extra
  78. fast" tags, but this approach tends to limit your ability to scale up
  79. frequency, and as Mitch Alsup pointed out, this does not work with SRAMS.
  80.  
  81. Additionally, the hashing is combined in circuits which "power-up" the
  82. cache index, adding only a fractional gate delay to the path.
  83.  
  84. As to whether direct-mapped or set-associative is best, this depends a
  85. lot on many things (where have you heard that before? :-).  Set
  86. associativity improves hit rate, but can increase latency (as I
  87. described).  Additionally, large caches cannot be implemented on-chip
  88. (I don't think of 32KB as large :-), and off-chip set-associative
  89. caches are expensive (although HP builds those too, but only for our
  90. larger business-class PA machines).
  91.  
  92.  
  93. > 3) What hash function does HP use?
  94.  
  95. Although the user-visible virtual address space in current PA-RISC
  96. products is 32-bit, PA machines actually implement a larger virtual
  97. address space (48 bits in the snakes workstations).  This large global
  98. address space is used by the OS in many ways to improve performance.
  99. The cache index hash is an xor of bits from the lower 32 address bits
  100. with bits from the upper portion (which we call the "space").  The OS
  101. randomly assigns spaces to user processes, effectively smearing their
  102. references across the cache.
  103.  
  104. The hash does cause good separation in the caches between:
  105.     one user's code and data   and   another user's code and data
  106.     user's code and data       and   OS code and data
  107.     database data              and   I/O buffer data
  108.  
  109.  
  110. > I would be interestered to hear from anyone who knows the answer
  111. > to these questions from papers or first-hand knowledge.
  112.  
  113. I hope this answers your questions.
  114.  
  115. ------------------------------------------------------------------------------
  116. Dale Morris        |  Now is the time, and now is the record...
  117. morris@nsa.hp.com   |          of the time.
  118. ------------------------------------------------------------------------------
  119.