# An FPGA-Based Performance Analysis of Hardware Caching Techniques for Blockchain Key-Value Database
## 5 Results and Discussion
### Comparison of Cache Hit Rate and Miss Rate  
Table 4 shows cache hit and cache miss in the direct-mapped cache system, 2-way cache system, and 4-way cache system for 10 K key addresses. The cache hit rate and cache miss rate are calculated by counting the clock cycle for a cache hit and miss. Equations (1) and (2) calculate the cache hit ratio and cache miss ratio, respectively. \[\textit{Cache Hit Ratio}=\frac{\textit{Total clock cycles when the cache is hit}}{\textit{Total clock cycles for data access}} \tag{1}\]  
\[\textit{Cache Miss Ratio}=\frac{\textit{Total clock cycles when the cache is missed}}{\textit{Total clock cycles for data access}} \tag{2}\]  
Table 4 shows that the cache hit ratio in 2-way and 4-way is greater than that of the direct-mapped cache system, whereas the cache miss ratio in direct mapping is greater than the 2-way and 4-way set-associative cache system. It can be seen that the gap between a cache hit and cache miss is very small in this result. This is because of the small set of keys used for comparison. However, this gap will increase as we use large sets of keys for comparison, as shown in Tables 5-7. Table 5 shows the cache hit ratio and cache miss ratio comparison for 25 K key addresses. The hit ratios of 2-way and 4-way cache systems are 77.09% and 78.33%, whereas the hit ratio of direct-mapped cache systems is 76.32%. The cache miss ratio of the  
Figure 15: Delay cycle when a cache hit or miss occurs. direct-mapped cache system is 23.67% and the cache miss ratios of 2-way and 4-way cache systems are 22.9% and 21.67%, respectively. The differences between the cache hit ratio and cache miss ratio of the direct-mapped and 2-way cache system are 0.77% and 0.78%, and the differences between the cache hit ratio and cache miss ratio of the direct-mapped and 4-way cache system are 2.01% and 2%. Table 6 shows the cache hit ratio and cache miss ratio comparison for 50 K key addresses. The hit ratios of 2-way and 4-way cache systems are 75.27% and 76%, while the hit ratio of the direct-mapped cache system is 73.6%. The cache miss ratio of the direct-mapped cache system is 26.4% and the cache miss ratio of the 2-way and 4-way cache system is 24.73% and 24%, respectively. The difference between the hit ratio of the direct-mapped and 4-way cache system is 2.4% and the difference between the hit ratio of the direct-mapped and 2-way cache system is 1.67%. Table 7 shows the cache hit rate improved by set-associative techniques with respect to the direct-mapped cache technique. The hit rate improved by the 2-way set-associative technique with respect to the direct-mapped cache technique for 10 k, 25 k, and 50 k keys sets are 0.8%, 0.77%, and 1.67%, respectively; whereas, for these sets of keys (i.e., 10 k, 25 k, and 50 k), the hit rate improvement of the 4-way set-associative technique with respect to the direct-mapping technique is 0.92%, 2.01%, and 2.4%, respectively. Table 7 also shows that the hit rate is improved by set-associative techniques. This shows that the set-associative technique can perform better compared to direct mapping for a large set of keys. \begin{table}
\begin{tabular}{c c c c} \hline  & **Direct-Mapped** & **2-Way** & **4-Way** \\ \hline
**Cache Hit** & 535,273 & 548,156 & 565,289 \\ \hline
**Cache Miss** & 192,001 & 180,108 & 178,736 \\ \hline
**Hit Ratio** & 73.6\% & 75.27 & 76\% \\ \hline
**Miss Ratio** & 26.4\% & 24.73 & 24\% \\ \hline
**Average Access Delay** & 11.6 ns & 11.18 ns & 11 ns \\ \hline \end{tabular}
\end{table} 
Table 6: Comparison of hit and miss rates of 50 K keys. \begin{table}
\begin{tabular}{c c c c} \hline  & **Direct-Mapped** & **2-Way** & **4-Way** \\ \hline
**Cache Hit** & 117,851 & 119,490 & 119,717 \\ \hline
**Cache Miss** & 32,672 & 31,576 & 31,424 \\ \hline
**Hit Ratio** & 78.29\% & 79.09\% & 79.21\% \\ \hline
**Miss Ratio** & 21.7\% & 20.09\% & 20.8\% \\ \hline
**Average Access Delay** & 10.43 ns & 10.22 ns & 10.19 ns \\ \hline \end{tabular}
\end{table} 
Table 4: Comparison of hit and miss rates of 10 K keys.