Вы находитесь на странице: 1из 2

Hit

Ratio
It is sometimes believed that a database is fast if the number of blocks that are
read from memory is maximized. The term that is related to that idea is Hit
Ratio and is measured in percents. Ideally, the Hit Ratio is 100% (which would
mean that all data ever accessed from the database resides in memory).
However, this believ is usually wrong.
Although the hit ration should not be used for tuning, here's the formula for Hit
Ratio is for completness' sake: 100% * (total blocks read from memory) / (total
blocks read). This is the same as 100% * (1 - (blocks read from harddisk)/(total
blocks read))
Oracle uses the term physical reads for blocks read from harddisk. total blocks
read is made of two components: db blocks gets and consistent gets. So, the
formula becomes:100% * (1-(physical reads/(db block gets + consistent gets))).

It is a measure of well the data cache buffer is


handling requests for data.

Hit Ratio = (Logical Reads - Physical Reads - Hits Misses)/


Logical Reads.

hit ratio=number of hits/(number of hits+ number of miss)

Definitions of Hit ratio on the Web:

 A hit is a request to a web server for a file (web page, image, JavaScript,
Cascading Style Sheet, etc.). When a web page is uploaded from a server the
number of "hits" or "page hits" is equal to the number of files requested. ...
 Hit (Internet)
 From Wikipedia, the free encyclopedia
 (Redirected from Hit ratio)

 A hit is a request to a web server for a file (web page, image, JavaScript, Cascading Style Sheet, etc.).

When a web page is uploaded from a server the number of "hits" or "page hits" is equal to the number of

files requested. Therefore, one page load does not always equal one hit because often pages are made

up of other images and other files which stack up the number of hits counted. Because one page load

does not equal one hit it is an inaccurate measure of a website's popularity or web traffic. A more

accurate measure of web traffic is how many page views a web site has. Hits are useful when

evaluating the requirements of your server, depending on the number and size of files which need to be

transferred for one request. Servers should be tested to make sure they meet throughput targets (i.e.

they should be capable of processing a certain amount of 'hits' per second).


 Unique hits count the number of different individuals who have generated at least one hit.
What is a cache??
A mechanism where we maintain a copy of the data in a faster area as compared to the real data
that may be in a slower area. For example, hardware cache memory. Cache memory is faster than
main memory: so if we maintain a copy of the data in cache, then the next time the same data is
accessed, then if the copy of that data is in cache, then there is no need to go all the way to
memory to fetch the data. So, cache speeds up the access to data in main memory.

What is a Cache hit??


When the CPU generates a load instruction, the cache is first checked to see if the data being
loaded is already in the cache. How did it get into the cache?? From a prior access to the same
data, which went all the way to memory and stored a copy in the cache. When the data is found in
the cache itself, we call this as a Cache hit. If you do not find it in the cache, it is called a cache
miss. On a cache miss, data has to be fetched from memory itself.

What is a TLB??
TLB stands for Translation Lookaside Buffer. In Virtual memory systems, the cpu generates virtual
memory addresses. But, the data is stored in actual physical memory i.e. we need to place a
physical memory address on the memory bus to fetch the data from the memory circuitry. So, a
special table is maintained by the operating system called the Page table. This table contains a
mapping between the virtual addresses and physical addresses. So, everytime a cpu generates a
virtual address, the operating system page table has to be looked up to find the corresponding
physical address. To speed this up, there is hardware support called the TLB. The TLB is a high
speed cache of the page table i.e. contains recently accessed virtual to physical translations.

What is a TLB hit ratio??


Just like the cache hit, a TLB hit is the no of times a virtual-to-physical address translation was
already found in the TLB, instead of going all the way to the page table which is located in slower
physical memory.

TLB hit ratio is nothing but the ratio of TLB hits/Total no of queries into TLB. For example, if I
asked the TLB 10 times for virtual-to-physical mappings, and found the mapping 4 times, then my
hit ratio is 4/10 i.e. 40%.

In your example, 984506475 is the logical/virtual address sequence. Assuming an infinite size TLB,
how many tlb hits will we have?? 9, 4, 5 are accessed more than once. So, hit ration is 3/9 =
33%.

But, the question also mentions that the TLB is a FIFO i.e. this means that the TLB size is limited.
So, there is missing info in the question. Lets assume that the TLB size is 4. So, here is what
happens when each new address is accessed:
9
89
489
5489
0548
6054
4605
7460
5746

If you notice, the above is a FIFO simulation. So, how many hits will we have?? None. So, hit ratio
is 0%.

Hope that helps.

Вам также может понравиться