提交 5871ca9c 编写于 作者: D DoMyJob

Add expendRatioM to extend M to cover more items in one table.

This is for un-even distribution hash, some entries may
have more items than the others, this expending makes
those items in same range table, so that we have less
opportunity to access overflow region.
Signed-off-by: NDoMyJob <46307927+DoMyJob@users.noreply.github.com>
上级 5ceb3d2f
......@@ -163,24 +163,11 @@ func FinalizeConfig(config *Options) (*Options, error) {
// calc M, N, D
c, d, n, m := config.TotalVolumn, (uint64)(config.DataBlockSize), (uint64)(config.IndexTableRows), (uint64)(config.IndexTableCols)
// range len array: N size array of uint16, i.e. [uint16, uint16, ...(N)]
// rangeLenSize := (uint64)(unsafe.Sizeof((uint16)(0)))
// index table item [Hash (32bytes) | OffsetIdx (uint32)]
// indexTableEntrySize := (uint64)(unsafe.Sizeof(common.Hash{})) + (uint64)(unsafe.Sizeof((uint32)(0)))
// Total disk allocation:
// --------+-------------------+-----------------------------+------------+----------------+
// [Header]|[ RangeTableSizes ]|[ HashTable ]|[ Data ]|[ BitMap ]
// --------+-------------------+-----------------------------+------------+----------------+
// h + rangeLenSize * n + indexTableEntrySize* n * m + n * d * m + (m * n + 7)/ 8
// --------+-------------------+-----------------------------+------------+----------------+
m = c / (n * d)
if m < 4 || m >= MaxRangeCoverage {
// m can not == MAX_RANGE_COVERAGE because max uint16 is (MAX_RANGE_COVERAGE - 1)
// otherwise we shoud keep +1 in mind when calc the index table size, which seems a little bit tricky.
return nil, ErrConfigM
}
config.IndexTableCols = (uint32)(m)
config.IndexTableCols = uint32((float32)(m) * expendRatioM)
if config.IndexTableRows > MaxRangeNumber || !ytfs.IsPowerOfTwo((uint64)(config.IndexTableRows)) {
return nil, ErrConfigN
......
......@@ -2,5 +2,6 @@ package opt
// properties for internal use.
const (
DebugPrint bool = true
DebugPrint bool = false
expendRatioM float32 = 1.2
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册