trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject [trafficserver] branch master updated: Add comment for vol init
Date Fri, 09 Mar 2018 17:02:07 GMT
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new bee96b7  Add comment for vol init
bee96b7 is described below

commit bee96b77bade58d98de4a3bb936a148de1188c01
Author: scw00 <scw00@apache.org>
AuthorDate: Fri Mar 9 09:41:28 2018 +0800

    Add comment for vol init
---
 iocore/cache/Cache.cc | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 98e44b7..ccf2926 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -1181,10 +1181,16 @@ Vol::db_check(bool /* fix ATS_UNUSED */)
 static void
 vol_init_data_internal(Vol *d)
 {
-  d->buckets  = ((d->len - (d->start - d->skip)) / cache_config_min_average_object_size)
/ DIR_DEPTH;
-  d->segments = (d->buckets + (((1 << 16) - 1) / DIR_DEPTH)) / ((1 << 16)
/ DIR_DEPTH);
-  d->buckets  = (d->buckets + d->segments - 1) / d->segments;
-  d->start    = d->skip + 2 * vol_dirlen(d);
+  // step1: calculate the number of entries.
+  off_t total_entries = (d->len - (d->start - d->skip)) / cache_config_min_average_object_size;
+  // step2: calculate the number of buckets
+  off_t total_buckets = total_entries / DIR_DEPTH;
+  // step3: calculate the number of segments, no semgent has more than 16384 buckets
+  d->segments = (total_buckets + (((1 << 16) - 1) / DIR_DEPTH)) / ((1 << 16)
/ DIR_DEPTH);
+  // step4: divide total_buckets into segments on average.
+  d->buckets = (total_buckets + d->segments - 1) / d->segments;
+  // step5: set the start pointer.
+  d->start = d->skip + 2 * vol_dirlen(d);
 }
 
 static void

-- 
To stop receiving notification emails like this one, please contact
bcall@apache.org.

Mime
View raw message