CN101349983B - Method and device for measuring disk effective cache capacity - Google Patents
Method and device for measuring disk effective cache capacity Download PDFInfo
- Publication number
- CN101349983B CN101349983B CN2008101195247A CN200810119524A CN101349983B CN 101349983 B CN101349983 B CN 101349983B CN 2008101195247 A CN2008101195247 A CN 2008101195247A CN 200810119524 A CN200810119524 A CN 200810119524A CN 101349983 B CN101349983 B CN 101349983B
- Authority
- CN
- China
- Prior art keywords
- value
- average throughput
- capacity
- average
- read
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 42
- 238000004364 calculation method Methods 0.000 claims description 18
- 238000005259 measurement Methods 0.000 claims description 4
- 230000007423 decrease Effects 0.000 abstract description 19
- 238000012360 testing method Methods 0.000 description 15
- 238000010586 diagram Methods 0.000 description 12
- 125000004122 cyclic group Chemical group 0.000 description 4
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Landscapes
- Debugging And Monitoring (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
本发明公开了一种磁盘有效缓存(Cache)容量的测量方法及装置,其中方法包括:A、按照预先设定的次数H,循环读取M个固定大小的数据块H次,计算本次循环的平均吞吐量;B、将M按照一定步长增大,判断M是否小于预先设定的最大值N,如果是,则重复执行上述步骤A;如果否,则执行步骤C;C、判断所述平均吞吐量是否出现下降并维持稳定,如果是,则获取平均吞吐量出现下降时的M值,计算有效缓存容量为M个所述数据块的大小。本发明提出的方法和装置能够测量出磁盘Cache的有效Cache容量。
The invention discloses a method and device for measuring the effective cache (Cache) capacity of a disk, wherein the method includes: A. According to a preset number of times H, cyclically read M data blocks of a fixed size H times, and calculate the current cycle B. Increase M according to a certain step size, and judge whether M is smaller than the preset maximum value N. If yes, repeat the above step A; if not, execute step C; C. Whether the average throughput decreases and remains stable, and if so, obtain the M value when the average throughput decreases, and calculate the effective cache capacity as the size of M data blocks. The method and device proposed by the invention can measure the effective cache capacity of the disk cache.
Description
技术领域technical field
本发明涉及测量技术,特别涉及一种磁盘有效缓存(Cache)容量的测量方法。The invention relates to measurement technology, in particular to a method for measuring the effective cache (Cache) capacity of a disk.
背景技术Background technique
现有技术为了提高中央处理器(CPU)对物理磁盘的读写速度,通常会在CPU和物理磁盘之间设置磁盘Cache,以减少CPU对物理磁盘的直接访问次数。这样,如果CPU需要从物理磁盘读取的数据缓存在磁盘Cache中,则CPU可直接从磁盘Cache中读取;如果CPU需要向物理磁盘中写数据,有两种方法,其中一种方法,也是普遍采用的方法,CPU只需将数据写入至Cache即可返回写成功消息,从而无需CPU等待物理磁盘的机械臂移动寻址过程;另外一种方法是要等待数据完全写入磁盘后才返回写成功消息,这种方法效率比较低。In the prior art, in order to increase the reading and writing speed of a central processing unit (CPU) to a physical disk, a disk cache is usually set between the CPU and the physical disk to reduce the number of direct accesses to the physical disk by the CPU. In this way, if the CPU needs to cache the data read from the physical disk in the disk Cache, the CPU can directly read from the disk Cache; if the CPU needs to write data to the physical disk, there are two methods, one of which is also In the commonly used method, the CPU only needs to write the data to the Cache to return the write success message, so that the CPU does not need to wait for the physical disk's mechanical arm to move the addressing process; another method is to wait for the data to be completely written to the disk before returning Write a success message, this method is relatively inefficient.
其中,根据替换算法,当磁盘Cache不能再容纳更多的数据时,如果物理磁盘中的数据需要被读入至该磁盘Cache、或CPU需要向该磁盘Cache中再写入数据,则需要利用预设的调度算法替换磁盘Cache中已有的某些数据。Among them, according to the replacement algorithm, when the disk Cache can no longer accommodate more data, if the data in the physical disk needs to be read into the disk Cache, or the CPU needs to rewrite data to the disk Cache, it is necessary to use the pre-set The preset scheduling algorithm replaces some existing data in the disk cache.
如此一来,由于CPU无需等待物理磁盘通过其机械臂移动的寻址过程,因而大大加快了CPU对物理磁盘的读写速度。In this way, since the CPU does not need to wait for the addressing process of the physical disk to move through its mechanical arm, the read and write speed of the CPU to the physical disk is greatly accelerated.
实际应用中,CPU对物理磁盘的读取速度取决于磁盘Cache的访问速度,而磁盘Cache的访问速度则取决于该磁盘Cache中能够真正被利用到的存储空间容量,即有效Cache容量。In practical applications, the reading speed of the CPU to the physical disk depends on the access speed of the disk cache, and the access speed of the disk cache depends on the capacity of the storage space that can actually be used in the disk cache, that is, the effective cache capacity.
但由于现有各种调度算法的局限性,磁盘Cache的实际容量一般不能100%得到利用,即有效Cache容量一般不能达到该磁盘Cache的最大容量,因而使得实际容量较大的磁盘Cache,有可能由于其有效Cache容量较低而无法有效提高CPU对物理磁盘的读取速度。However, due to the limitations of various existing scheduling algorithms, the actual capacity of the disk Cache generally cannot be utilized 100%, that is, the effective Cache capacity generally cannot reach the maximum capacity of the disk Cache, thus making it possible for a disk Cache with a larger actual capacity to Due to its low effective Cache capacity, it cannot effectively improve the reading speed of the CPU to the physical disk.
由此可知,在选择磁盘Cache时,不但要考虑其标称容量的大小,更为重要地还要考虑磁盘Cache的有效Cache容量大小。It can be seen that, when selecting a disk cache, not only its nominal capacity must be considered, but more importantly, the effective cache capacity of the disk cache must also be considered.
然而,现有技术中却没有能够测量有效Cache容量大小的方案,从而不能更好根据有效Cache容量大小选择磁盘。However, in the prior art, there is no solution capable of measuring the size of the effective cache capacity, so that the disk cannot be better selected according to the size of the effective cache capacity.
发明内容Contents of the invention
有鉴于此,本发明提供了一种磁盘有效Cache容量的测量方法,能够测量磁盘Cache的有效Cache容量。In view of this, the present invention provides a method for measuring the effective cache capacity of the disk, which can measure the effective cache capacity of the disk cache.
本发明还提供一种磁盘有效Cache容量的测量装置,能够测量磁盘Cache的有效Cache容量。The invention also provides a measuring device for the effective Cache capacity of the disk, capable of measuring the effective Cache capacity of the disk Cache.
本发明的技术方案是这样实现的:Technical scheme of the present invention is realized like this:
本发明提供的一种磁盘有效Cache容量的测量方法,包括:A kind of measuring method of disk effective Cache capacity provided by the invention comprises:
A、按照预先设定的次数H,循环读取M个固定大小的数据块H次,计算本次循环的平均吞吐量;所述H大于0;A. Read M data blocks of fixed size H times in a cycle according to the preset number H, and calculate the average throughput of this cycle; said H is greater than 0;
B、将M按照一定步长增大,判断M是否小于预先设定的最大值N,如果是,则重复执行上述步骤A;如果否,则执行步骤C;所述N大于所述磁盘的厂家所标称的缓存容量除以数据块大小后向上取整的值;所述M的初始值为1,所述M增大的步长为1;B. Increase M according to a certain step size, judge whether M is less than the preset maximum value N, if yes, then repeat the above step A; if not, then perform step C; said N is greater than the manufacturer of the magnetic disk The nominal cache capacity is divided by the data block size and rounded up; the initial value of M is 1, and the step size of M is 1;
C、判断所述平均吞吐量是否出现下降并维持稳定,如果是,则获取平均吞吐量出现下降时的M值,计算有效缓存容量为所述平均吞吐量出现下降时的M值与数据块大小的积。C. Judging whether the average throughput drops and remains stable, if so, obtain the M value when the average throughput drops, and calculate the effective cache capacity as the M value and the data block size when the average throughput drops product.
本发明还提供一种磁盘有效Cache容量的测量装置,包括:The present invention also provides a kind of measuring device of disk effective Cache capacity, comprising:
读取模块,用于循环读取M个固定大小的数据块H次,所述H为预先设定的次数;The reading module is used to cyclically read M data blocks of a fixed size H times, and the H is a preset number of times;
平均吞吐量计算模块,用于计算读取模块循环读取的平均吞吐量;The average throughput calculation module is used to calculate the average throughput of the reading module's cyclic reading;
判断模块,用于判断所述读取模块所读取的数据块的个数M是否小于预先设定的最大值N,如果是,则按照一定步长增大M值,指示读取模块重新循环读取数据块,所述数据块的个数为增大后的M值;如果否,则指示有效缓存容量计算模块进行计算;A judging module, configured to judge whether the number M of data blocks read by the reading module is less than a preset maximum value N, if so, increase the value of M according to a certain step size, and instruct the reading module to recycle Read the data block, the number of the data block is the increased M value; if not, then instruct the effective cache capacity calculation module to calculate;
有效缓存容量计算模块,用于在接收到判断模块的指示后,获取平均吞吐量计算模块所计算的所有平均吞吐量,判断所述平均吞吐量是否出现下降并维持稳定,如果是,则获取平均吞吐量出现下降时的M值,计算有效缓存容量为所述平均吞吐量出现下降时的M值与数据块大小的积;The effective buffer capacity calculation module is used to obtain all the average throughput calculated by the average throughput calculation module after receiving the instruction of the judgment module, and judge whether the average throughput has declined and remains stable, and if so, obtain the average throughput. The M value when the throughput drops, and the effective cache capacity is calculated as the product of the M value and the data block size when the average throughput drops;
所述H大于0;所述N大于所述磁盘的厂家所标称的缓存容量除以数据块大小后向上取整的值;所述M的初始值为1,所述M增大的步长为1。The H is greater than 0; the N is greater than the nominal cache capacity of the disk manufacturer divided by the data block size and rounded up; the initial value of M is 1, and the step size of M increases is 1.
由上述技术方案可见,本发明提出的方法和装置,通过循环读取多个连续的数据块,逐渐增大数据块的块数,使得吞吐量显著下降之后维持稳定,确定吞吐量开始下降时读取数据块的块数,根据该下降点的块数和数据块的大小,能够确定出磁盘有效Cache容量。It can be seen from the above technical solution that the method and device proposed by the present invention gradually increase the number of data blocks by cyclically reading a plurality of continuous data blocks, so that the throughput remains stable after a significant decline, and when the throughput begins to decline, the read The number of data blocks is taken, and the effective cache capacity of the disk can be determined according to the number of blocks at the drop point and the size of the data block.
附图说明Description of drawings
图1为本发明实施例吞吐量的变化曲线示意图;FIG. 1 is a schematic diagram of a variation curve of throughput in an embodiment of the present invention;
图2为本发明实施例平均吞吐量的均值和标准方差曲线示意图;Fig. 2 is a schematic diagram of the mean value and standard deviation curve of the average throughput of the embodiment of the present invention;
图3为本发明实施例测量磁盘有效Cache容量的方法流程图;Fig. 3 is the flow chart of the method for measuring disk effective Cache capacity according to an embodiment of the present invention;
图4为应用本发明方法测试磁盘A的有效Cache容量的第一结果示意图;Fig. 4 is the first result schematic diagram of applying the method of the present invention to test the effective Cache capacity of disk A;
图5为应用本发明方法测试磁盘A的有效Cache容量的第二结果示意图;Fig. 5 is the second result schematic diagram of applying the method of the present invention to test the effective Cache capacity of disk A;
图6为应用本发明方法测试磁盘B的有效Cache容量的第一结果示意图;Fig. 6 is the first result schematic diagram of applying the method of the present invention to test the effective Cache capacity of disk B;
图7为应用本发明方法测试磁盘B的有效Cache容量的第二结果示意图。FIG. 7 is a schematic diagram of the second result of testing the effective Cache capacity of disk B by applying the method of the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案及优点更加清楚明白,以下参照附图并举实施例,对本发明进一步详细说明。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and examples.
本发明实施例提出一种磁盘有效缓存容量的测量方法,包括:The embodiment of the present invention proposes a method for measuring the effective cache capacity of a disk, including:
A、按照预先设定的次数H,循环读取M个固定大小的数据块H次,计算本次循环的平均吞吐量;A. According to the preset number of times H, read M data blocks of fixed size H times in a loop, and calculate the average throughput of this loop;
B、将M按照一定步长增大,判断M是否小于预先设定的最大值N,如果是,则重复执行上述步骤A;如果否,则执行步骤C;B. Increase M according to a certain step size, and judge whether M is smaller than the preset maximum value N, if yes, repeat the above step A; if not, then execute step C;
C、判断所述平均吞吐量是否出现下降并维持稳定,如果是,则获取平均吞吐量出现下降时的M值,计算有效缓存容量为平均吞吐量出现下降时的M值与数据块大小的积。C. Judging whether the average throughput drops and remains stable, if so, obtain the M value when the average throughput drops, and calculate the effective cache capacity as the product of the M value when the average throughput drops and the data block size .
前面提到,读取数据时,系统首先检查请求的数据是否在Cache中,如果在Cache中,则直接从Cache中读取;如果不在Cache中,则从磁盘中读取,并将读取的数据保留在Cache中,在下次读取该数据时则直接从Cache读取即可。本发明正是利用了这一特点,循环读取一个大文件的M个数据块,直到M足够大时,使Cache失效,读取的吞吐量会随着M值的增大而显著下降并最终趋于稳定,吞吐量出现下降时的M值就是有效Cache大小的计算点。如图1所示,图1为本发明实施例吞吐量的变化曲线示意图。在图1中,吞吐量随着M的增大而出现下降并维持平稳,下降点B就是有效Cache大小的计算点,即:As mentioned earlier, when reading data, the system first checks whether the requested data is in the Cache, if it is in the Cache, it will be read directly from the Cache; if it is not in the Cache, it will be read from the disk, and the read The data is kept in the Cache, and the next time the data is read, it can be read directly from the Cache. The present invention utilizes this feature just to read M data blocks of a large file in a loop until M is large enough to make the Cache invalid, and the read throughput will significantly decrease with the increase of the M value and finally It tends to be stable and the M value when the throughput drops is the calculation point of the effective cache size. As shown in FIG. 1 , FIG. 1 is a schematic diagram of a variation curve of throughput according to an embodiment of the present invention. In Figure 1, the throughput decreases and remains stable with the increase of M, and the drop point B is the calculation point of the effective cache size, that is:
有效Cache大小=数据块大小×B点的数据块个数Effective cache size = data block size × number of data blocks at point B
以下结合上述方法具体介绍:The following is a specific introduction in combination with the above methods:
步骤A中,初次读取时,应使M的初始值足够小,以保证M个数据块的总量小于有效Cache的容量。在第一次执行读取M个数据块时,一般会发生强制性失效,因为第一次读取的数据块一般不会在Cache中。此时需要从磁盘读取数据块,并保存到Cache中。之后循环执行循环读取M个数据块时,在所读数据块总大小小于有效cache的情况下,由于第一次读取的M个数据块已经被保存在Cache中,后续的数据块都会命中,可以直接从Cache中读取,此时计算出的平均吞吐量相当于直接从Cache读取的吞吐量,吞吐量比较高。In step A, when reading for the first time, the initial value of M should be made small enough to ensure that the total amount of M data blocks is less than the capacity of the effective Cache. When M data blocks are read for the first time, a mandatory invalidation generally occurs, because the data blocks read for the first time are generally not in the Cache. At this time, the data block needs to be read from the disk and stored in the Cache. Afterwards, when looping to read M data blocks, if the total size of the read data blocks is smaller than the effective cache, since the M data blocks read for the first time have been saved in the Cache, subsequent data blocks will hit , can be read directly from the Cache, and the calculated average throughput at this time is equivalent to the throughput of reading directly from the Cache, and the throughput is relatively high.
在步骤A中循环读取H次后计算平均吞吐量,其目的是为了消除测试中少数误差数据的影响。H的值应足够大。The average throughput is calculated after looping H times in step A, the purpose of which is to eliminate the influence of a small number of error data in the test. The value of H should be large enough.
步骤B中,增大M值的主要目的是使读取的数据块从小到大最终超过有效cache的大小。M按照一定步长逐渐增大,其目的是使测量精度更高,修改M增大的步长可以确定不同的测量精度。本发明实施例中,取步长为1。In step B, the main purpose of increasing the value of M is to make the read data blocks from small to large eventually exceed the size of the effective cache. M is gradually increased according to a certain step size, the purpose of which is to make the measurement accuracy higher, and different measurement accuracy can be determined by modifying the step size of M increase. In the embodiment of the present invention, the step size is taken as 1.
如果通过修改M的值,使每次循环读取的数据块的总量超过了有效cache的大小,则循环读取过程中,就会发生数据块替换的情况。例如:为了将数据块B读入cache,根据替换算法,前面已经被读入的数据块A会被替换出去,当再次读取该数据块A时发生数据块缺失的情况,则再次发生数据块替换,可能会将数据块C替换出去,这样不断地替换、缺失,导致几乎所有的数据块都需要直接从磁盘进行读取,cache所做的工作就是不停的替换,却很少命中。这种情况下计算的平均吞吐量,相当于直接从磁盘读取的吞吐量,吞吐量很低。If the total amount of data blocks read in each cycle exceeds the size of the effective cache by modifying the value of M, data block replacement will occur during the cycle read process. For example: in order to read data block B into the cache, according to the replacement algorithm, the previously read data block A will be replaced. When the data block A is read again and the data block is missing, the data block will be generated again. Replacement may replace data block C, which is constantly replaced and missing, resulting in almost all data blocks needing to be read directly from the disk. The work of the cache is to replace continuously, but rarely hits. The average throughput calculated in this case is equivalent to the throughput of reading directly from the disk, and the throughput is very low.
判断平均吞吐量是否显著下降以及多次下降的结果是否维持稳定有两种方法实现:①根据输出的平均吞吐量的结果绘制曲线,直接观察是否显著下降并维持稳定,该方法简单,适用于测试结果数据比较规范的情况。②根据测试结果,对于每个输出的平均吞吐量,计算前连续X个平均吞吐量(包括当前平均吞吐量)的均值和标准方差,并绘制两个对应曲线。如图2,图2为本发明实施例平均吞吐量的均值和标准方差曲线示意图。在Cache不失效的情况下,计算的均值比较高,并且数值相差不大,即标准方差值比较小;如果在某一点B,Cache失效,则该点前连续X个值(包括该点)的平均值就会下降,并且标准方差值会显著提升,即吞吐量差异增大。如果按照该方法,在C点以后,连续输出X个结果的均值在下降后维持在一个比较低的值并且最终趋于平缓,而标准方差值在显著提升后又逐渐下降,最终趋于平缓,并最终维持在一个比较低的值范围内,可认为是稳定状态,那么B点就是Cache失效的对应点,并且认为曲线下降后维持稳定。B点的对应的数据块个数与数据块大小的积即等于有效Cache的容量。There are two ways to judge whether the average throughput drops significantly and whether the results of multiple drops remain stable: ① draw a curve according to the output average throughput results, and directly observe whether it drops significantly and remains stable. This method is simple and suitable for testing The resulting data is relatively standardized. ②According to the test results, for the average throughput of each output, calculate the mean and standard deviation of the previous X consecutive average throughput (including the current average throughput), and draw two corresponding curves. As shown in FIG. 2 , FIG. 2 is a schematic diagram of the mean value and standard deviation curve of the average throughput of the embodiment of the present invention. In the case that the Cache does not fail, the calculated average is relatively high, and the value difference is not large, that is, the standard deviation value is relatively small; if at a certain point B, the Cache fails, then there are X consecutive values before this point (including this point) The mean value of will drop, and the standard deviation value will increase significantly, that is, the throughput variance will increase. According to this method, after point C, the mean value of the continuous output X results maintains a relatively low value after a decline and eventually flattens out, while the standard deviation value gradually decreases after a significant increase, and finally flattens out , and finally maintained in a relatively low value range, which can be considered as a stable state, then point B is the corresponding point of Cache failure, and it is considered that the curve remains stable after falling. The product of the number of data blocks corresponding to point B and the size of the data block is equal to the capacity of the effective Cache.
另外,最大值N可以根据厂家标称的Cache大小来进行计算,具体为:In addition, the maximum value N can be calculated according to the manufacturer's nominal cache size, specifically:
其中,符号表示向上取整,其含义是取不小于某数的最小整数;n为自然数,加n的目的是使得N的值大于磁盘厂家标称的Cache容量除以数据块大小后向上取整的值,则N个数据块的容量必然大于有效Cache容量,当M增大到N时,一定会引起Cache失效。 Among them, the symbol Indicates rounding up, and its meaning is to take the smallest integer not less than a certain number; n is a natural number, and the purpose of adding n is to make the value of N larger than the disk manufacturer’s nominal cache capacity divided by the data block size and then rounding up. Then the capacity of N data blocks must be greater than the effective Cache capacity, and when M increases to N, it will definitely cause Cache failure.
当无法获知厂家标称的Cache大小时,N的值可以根据市场主流Cache的容量进行计算。如果M增大到预先设定的N时,平均吞吐量仍未出现下降并维持稳定,说明预先设置的N值不够大,则按照预先设定的速度增大N值,比如将N值增大到原先的2倍,继续执行循环读取并计算平均吞吐量的步骤,直至平均吞吐量出现下降并维持稳定时,获取平均吞吐量出现下降时的M值,计算出有效Cache的容量为平均吞吐量出现下降时的M值与数据块大小的积。When the manufacturer's nominal cache size cannot be known, the value of N can be calculated based on the capacity of mainstream caches in the market. If M increases to the preset N, the average throughput does not decline and remains stable, indicating that the preset N value is not large enough, then increase the N value at a preset speed, such as increasing the N value To double the original, continue to perform the steps of cyclic reading and calculating the average throughput until the average throughput drops and remains stable, obtain the M value when the average throughput drops, and calculate the effective Cache capacity as the average throughput The product of the M value and the data block size when the volume drops.
以下举具体的实施例进行介绍,参见图3,图3为本发明实施例测量有效Cache容量的方法流程图。包括:Specific embodiments are given below for introduction, referring to FIG. 3 , which is a flowchart of a method for measuring effective Cache capacity according to an embodiment of the present invention. include:
步骤301:设置读取数据块的最大值N,设置循环读取的次数H,设置读取数据块个数的初始值为1,即M的初始值为1。其中,N的设置方式与上述方式相同,在此不赘。H的值要求足够大,以保证计算出的平均吞吐量尽量精确。Step 301: Set the maximum value N of read data blocks, set the number of read cycles H, and set the initial value of the number of read data blocks to 1, that is, the initial value of M is 1. Wherein, the setting method of N is the same as the above method, which will not be repeated here. The value of H needs to be large enough to ensure that the calculated average throughput is as accurate as possible.
步骤302:循环读取M个数据块H次,计算本次循环的平均吞吐量。增大M的值,本实施例中,可以设定M增大的步长为1,即M=M+1。Step 302: cyclically read M data blocks H times, and calculate the average throughput of this cycle. To increase the value of M, in this embodiment, the step size of M can be set to be 1, that is, M=M+1.
步骤303:判断M是否小于预先设置的N,如果是,则执行步骤302;否则,执行步骤304。Step 303: Judging whether M is smaller than the preset N, if yes, execute
步骤304:判断每次循环计算出的平均吞吐量是否出现下降并维持稳定,本实施例中,判断的方式可以为:根据均值和标准方差进行判断。如果出现下降并维持稳定,则执行步骤305。如果预先设定的N是根据厂家标称的Cache容量计算得出的,则平均吞吐量一定会出现下降并维持稳定。但是,如果预先设定的N是根据市场主流的Cache容量计算得出的,则当M增大到N时,M个数据块的总长度可能还未超过有效Cache容量,此时不会出现平均吞吐量下降的现象。当判断出平均吞吐量未出现下降并维持稳定时,执行步骤306。Step 304: Judging whether the average throughput calculated in each cycle decreases and remains stable. In this embodiment, the judging method may be: judging according to the mean value and standard deviation. If there is a drop and remains stable, go to step 305 . If the preset N is calculated based on the manufacturer's nominal cache capacity, the average throughput will definitely decrease and remain stable. However, if the preset N is calculated based on the mainstream Cache capacity in the market, when M increases to N, the total length of M data blocks may not exceed the effective Cache capacity, and there will be no average A drop in throughput. When it is determined that the average throughput does not decrease and remains stable,
步骤305:计算有效Cache容量=平均吞吐量出现下降时M的值×数据块大小,结束本流程。Step 305: Calculate the effective Cache capacity=the value of M when the average throughput decreases×the data block size, and end this process.
步骤306:加速增大N值,本实施例中使N增大到原来的2倍,即N=N×2,并使M再增加1,继续执行步骤302。Step 306: Accelerate the increase of the value of N. In this embodiment, N is doubled, ie, N=N×2, and M is increased by 1, and step 302 is continued.
此后可以多次增大N值,直至平均吞吐量未出现下降并维持稳定后,计算有效Cache容量。After that, you can increase the value of N multiple times until the average throughput does not decrease and remains stable, then calculate the effective cache capacity.
此外,本发明提出的方法中,采用时钟周期作为计时单位,计时精确,误差小。在每个M值设置结束后开始计时,当前M值所有读取循环结束后计时结束,计算本次循环的平均吞吐量。In addition, in the method proposed by the present invention, the clock cycle is used as the timing unit, so the timing is accurate and the error is small. The timing starts after each M value is set, and the timing ends after all reading cycles of the current M value are completed, and the average throughput of this cycle is calculated.
以下应用本发明提出的方法对磁盘有效Cache进行测试,测试环境为:CPU3.0GHz,千兆网卡,两块均为147G的SCSI磁盘,其中磁盘A为厂家1生产,标称Cache为8M,磁盘B为厂家2生产,标称Cache为8M,在WINDOWSSERVER 2003进行了测试。其中,读取的数据块大小为64K。The following application method proposed by the present invention tests the effective Cache of the disk. The test environment is: CPU3.0GHz, Gigabit network card, two SCSI disks that are 147G, wherein disk A is produced by
首先对磁盘A的有效Cache容量进行测试。参见图4,图4为应用本发明方法测试磁盘A的有效Cache容量的第一结果示意图。图4中,X轴为读取的数据块数,Y轴为平均吞吐量,单位为MB/S。由图4可见,数据块数为82时,平均吞吐量开始下降,此后逐渐维持稳定。First, test the effective cache capacity of disk A. Referring to FIG. 4 , FIG. 4 is a schematic diagram of the first result of testing the effective Cache capacity of disk A by applying the method of the present invention. In Figure 4, the X-axis is the number of data blocks read, and the Y-axis is the average throughput in MB/S. It can be seen from Figure 4 that when the number of data blocks is 82, the average throughput begins to decline, and then gradually remains stable.
再根据图4的结果计算平均吞吐量的均值和标准方差,如图5所示,图5为应用本发明方法测试磁盘A的有效Cache容量的第二结果示意图。在5中,X轴为均值的序列号,位于上方的曲线表示取连续10个平均吞吐量计算出的均值,位于下方的曲线表示平均吞吐量的标准方差。由图5可见,当计算第73个均值时,平均吞吐量的均值开始下降,此后逐渐维持稳定;并且当计算出第73个均值时,平均吞吐量的标准方差开始增大,增大到最高值时下降并维持很小值。由于当出现第10个平均吞吐量时,才能计算第1个均值;故第73个均值的时刻对应第82个平均吞吐量,此时读取的数据块数也为82。可见,验证结果与图4的结果相同。Then calculate the mean value and standard deviation of the average throughput according to the results in FIG. 4 , as shown in FIG. 5 , which is a schematic diagram of the second result of applying the method of the present invention to test the effective Cache capacity of disk A. In 5, the X-axis is the serial number of the mean value, the upper curve represents the mean value calculated by taking 10 consecutive average throughputs, and the lower curve represents the standard deviation of the average throughput. It can be seen from Figure 5 that when the 73rd mean value is calculated, the mean value of the average throughput begins to decrease, and then gradually remains stable; and when the 73rd mean value is calculated, the standard deviation of the average throughput begins to increase and reaches the highest value decrease and maintain a small value. Since the first average value can only be calculated when the 10th average throughput occurs; therefore, the moment of the 73rd average value corresponds to the 82nd average throughput, and the number of data blocks read at this time is also 82. It can be seen that the verification result is the same as that in Figure 4.
由此,可以计算出磁盘A的有效Cache容量=64K×82=5.125MFrom this, it can be calculated that the effective cache capacity of disk A=64K×82=5.125M
之后对磁盘B的有效Cache容量进行测试。图6为应用本发明方法测试磁盘B的有效Cache容量的第一结果示意图。图7为应用本发明方法测试磁盘B的有效Cache容量的第二结果示意图。图6和图7均表明数据块个数为19时,平均吞吐量开始下降,此后逐渐维持稳定。由此,可以计算出磁盘B的有效Cache容量=64K×19=1.826MThen test the effective cache capacity of disk B. FIG. 6 is a schematic diagram of the first result of testing the effective Cache capacity of disk B by applying the method of the present invention. FIG. 7 is a schematic diagram of the second result of testing the effective Cache capacity of disk B by applying the method of the present invention. Both Figure 6 and Figure 7 show that when the number of data blocks is 19, the average throughput begins to decline, and then gradually remains stable. From this, it can be calculated that the effective cache capacity of disk B=64K×19=1.826M
本发明实施例还提出一种磁盘有效缓存容量的测量装置,包括:The embodiment of the present invention also proposes a device for measuring the effective cache capacity of a disk, including:
读取模块,用于循环读取M个固定大小的数据块H次,所述H为预先设定的次数;The reading module is used to cyclically read M data blocks of a fixed size H times, and the H is a preset number of times;
平均吞吐量计算模块,用于计算读取模块循环读取的平均吞吐量;The average throughput calculation module is used to calculate the average throughput of the reading module's cyclic reading;
判断模块,用于判断所述读取模块所读取的数据块的个数M是否小于预先设定的最大值N,如果是,则按照一定步长增大M值,指示读取模块重新循环读取数据块,所述数据块的个数为增大后的M值;如果否,则指示有效缓存容量计算模块进行计算;A judging module, configured to judge whether the number M of data blocks read by the reading module is less than a preset maximum value N, if so, increase the value of M according to a certain step size, and instruct the reading module to recycle Read the data block, the number of the data block is the increased M value; if not, then instruct the effective cache capacity calculation module to calculate;
有效缓存容量计算模块,用于在接收到判断模块的指示后,获取平均吞吐量计算模块所计算的所有平均吞吐量,判断所述平均吞吐量是否出现下降并维持稳定,如果是,则获取平均吞吐量出现下降时的M值,计算有效缓存容量为所述平均吞吐量出现下降时的M值与数据块大小的积。The effective buffer capacity calculation module is used to obtain all the average throughput calculated by the average throughput calculation module after receiving the instruction of the judgment module, and judge whether the average throughput has declined and remains stable, and if so, obtain the average throughput. For the M value when the throughput drops, the effective cache capacity is calculated as the product of the M value when the average throughput drops and the data block size.
上述有效缓存容量计算模块还用于,计算连续多个平均吞吐量的均值和标准方差,根据所述均值和标准方差判断平均吞吐量是否出现下降并维持稳定。The above-mentioned effective cache capacity calculation module is also used to calculate the average value and standard deviation of a plurality of consecutive average throughputs, and judge whether the average throughput decreases and remains stable according to the average value and standard deviation.
上述判断模块还用于,当有效缓存容量计算模块判断出平均吞吐量没有出现下降并维持稳定时,按照预先设定的速度增大N值,判断所述读取模块所读取的数据块的个数M是否小于增大后的N值,如果是,则指示读取模块重新执行循环读取,如果否,则指示有效缓存容量计算模块进行计算。The above judging module is also used for, when the effective cache capacity computing module judges that the average throughput has not declined and remains stable, increasing the N value at a preset speed to judge the data block read by the reading module Whether the number M is smaller than the increased N value, if yes, instruct the reading module to re-execute cyclic reading, if not, instruct the effective cache capacity calculation module to perform calculation.
上述装置中,所述N大于所述缓存厂家所标称的缓存容量除以所述数据块大小后向上取整的值。In the above device, the N is greater than the value rounded up after dividing the cache capacity advertised by the cache manufacturer by the size of the data block.
综上可见,本发明实施例提出的磁盘有效Cache容量的测量方法和装置,以块为单位,循环从一个大的文件中读取多个数据块,逐渐增加连续读取的数据块的块数,直到吞吐量显著下降,并且连续多次下降之后维持稳定后,确定吞吐量开始下降时读取数据块的块数,根据该下降点的块数和数据块的大小,能够确定出磁盘有效Cache容量。其计算结果可以作为评价磁盘Cache算法的参考。In summary, the method and device for measuring the effective cache capacity of a disk proposed by the embodiments of the present invention take blocks as units, read multiple data blocks from a large file in a loop, and gradually increase the number of continuously read data blocks , until the throughput drops significantly and remains stable after several consecutive drops, determine the number of data blocks read when the throughput starts to drop, and determine the effective cache of the disk according to the number of blocks at the drop point and the size of the data block capacity. The calculation results can be used as a reference for evaluating disk cache algorithms.
以上所述仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内,所作的任何修改、等同替换以及改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims (6)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN2008101195247A CN101349983B (en) | 2008-09-02 | 2008-09-02 | Method and device for measuring disk effective cache capacity |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN2008101195247A CN101349983B (en) | 2008-09-02 | 2008-09-02 | Method and device for measuring disk effective cache capacity |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN101349983A CN101349983A (en) | 2009-01-21 |
| CN101349983B true CN101349983B (en) | 2010-06-09 |
Family
ID=40268786
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN2008101195247A Expired - Fee Related CN101349983B (en) | 2008-09-02 | 2008-09-02 | Method and device for measuring disk effective cache capacity |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN101349983B (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119046077B (en) * | 2024-11-03 | 2025-04-08 | 北京麟卓信息科技有限公司 | A GPU cache multi-level capacity and extreme capacity testing method based on bidirectional approximation |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1492397A (en) * | 2002-10-21 | 2004-04-28 | 深圳易拓科技有限公司 | Method for optimizing magnetic disc storage capacity |
| CN1666257A (en) * | 2002-12-12 | 2005-09-07 | 富士通株式会社 | Magnetic disk device having a data recording area provided separately for each device |
-
2008
- 2008-09-02 CN CN2008101195247A patent/CN101349983B/en not_active Expired - Fee Related
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1492397A (en) * | 2002-10-21 | 2004-04-28 | 深圳易拓科技有限公司 | Method for optimizing magnetic disc storage capacity |
| CN1666257A (en) * | 2002-12-12 | 2005-09-07 | 富士通株式会社 | Magnetic disk device having a data recording area provided separately for each device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN101349983A (en) | 2009-01-21 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110532200B (en) | A memory system based on hybrid memory architecture | |
| US5594886A (en) | Pseudo-LRU cache memory replacement method and apparatus utilizing nodes | |
| CN110795363B (en) | Hot page prediction method and paging method for storage medium | |
| US10320695B2 (en) | Message aggregation, combining and compression for efficient data communications in GPU-based clusters | |
| CN109952565B (en) | memory access technology | |
| US20200026427A1 (en) | System and method for handling data storage on storage devices | |
| CN110175086B (en) | Memory device, semiconductor system, and wear leveling apparatus | |
| US20140372673A1 (en) | Information processing apparatus, control circuit, and control method | |
| CN105095104B (en) | Data buffer storage processing method and processing device | |
| CN107506139B (en) | A write request optimization device for phase change memory | |
| US9300716B2 (en) | Modelling dependencies in data traffic | |
| CN101349983B (en) | Method and device for measuring disk effective cache capacity | |
| CN119446238B (en) | Storage testing method and storage testing equipment | |
| WO2017045500A1 (en) | Storage array management method and apparatus | |
| CN118502677B (en) | Memory read re-table optimization method and device, readable storage medium and electronic equipment | |
| CN118550759B (en) | Flash memory reliability optimization method and related device based on data internal migration | |
| US10949359B2 (en) | Optimizing cache performance with probabilistic model | |
| CN107943415B (en) | Method and system for finding free clusters based on FAT file system | |
| CN110674170A (en) | Data caching method, device, device and medium based on reverse order reading of linked list | |
| CN109710547A (en) | A Design and Implementation Method of Buffer Memory Management in Industrial Internet of Things | |
| CN115033180A (en) | Cache replacement method and system of SMR-SSD hybrid storage system based on locality awareness | |
| CN113094220A (en) | Memory configuration method and device, computer equipment and readable storage medium | |
| CN115357444A (en) | A kind of test method of storage cache capacity | |
| JP5850724B2 (en) | Data processing apparatus and control method thereof | |
| TW201702859A (en) | Memory controller including a write performance storage circuit, a write counting circuit and a mapping circuit |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant | ||
| ASS | Succession or assignment of patent right |
Owner name: CHINA POTEVIO CO., LTD. Free format text: FORMER OWNER: PUTIAN IT TECH INST CO., LTD. Effective date: 20130916 |
|
| C41 | Transfer of patent application or patent right or utility model | ||
| TR01 | Transfer of patent right |
Effective date of registration: 20130916 Address after: 100080, No. two, 2 street, Zhongguancun science and Technology Park, Beijing, Haidian District Patentee after: CHINA POTEVIO CO.,LTD. Address before: 100080 Beijing, Haidian, North Street, No. two, No. 6, No. Patentee before: PETEVIO INSTITUTE OF TECHNOLOGY Co.,Ltd. |
|
| ASS | Succession or assignment of patent right |
Owner name: PUTIAN IT TECH INST CO., LTD. Free format text: FORMER OWNER: CHINA POTEVIO CO., LTD. Effective date: 20131202 |
|
| C41 | Transfer of patent application or patent right or utility model | ||
| TR01 | Transfer of patent right |
Effective date of registration: 20131202 Address after: 100080 Beijing, Haidian, North Street, No. two, No. 6, No. Patentee after: PETEVIO INSTITUTE OF TECHNOLOGY Co.,Ltd. Address before: 100080, No. two, 2 street, Zhongguancun science and Technology Park, Beijing, Haidian District Patentee before: CHINA POTEVIO CO.,LTD. |
|
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20100609 Termination date: 20210902 |
|
| CF01 | Termination of patent right due to non-payment of annual fee |