Gets the permitted size and IO bounds for a shard. A shard that starts at allKeys.begin (i.e. '') will have a permitted size of 0, since the database can contain no data.
| 144 | // Gets the permitted size and IO bounds for a shard. A shard that starts at allKeys.begin |
| 145 | // (i.e. '') will have a permitted size of 0, since the database can contain no data. |
| 146 | ShardSizeBounds getShardSizeBounds(KeyRangeRef shard, int64_t maxShardSize) { |
| 147 | ShardSizeBounds bounds; |
| 148 | |
| 149 | if (shard.begin >= keyServersKeys.begin) { |
| 150 | bounds.max.bytes = SERVER_KNOBS->KEY_SERVER_SHARD_BYTES; |
| 151 | } else { |
| 152 | bounds.max.bytes = maxShardSize; |
| 153 | } |
| 154 | |
| 155 | bounds.max.bytesPerKSecond = bounds.max.infinity; |
| 156 | bounds.max.iosPerKSecond = bounds.max.infinity; |
| 157 | bounds.max.bytesReadPerKSecond = bounds.max.infinity; |
| 158 | |
| 159 | // The first shard can have arbitrarily small size |
| 160 | if (shard.begin == allKeys.begin) { |
| 161 | bounds.min.bytes = 0; |
| 162 | } else { |
| 163 | bounds.min.bytes = maxShardSize / SERVER_KNOBS->SHARD_BYTES_RATIO; |
| 164 | } |
| 165 | |
| 166 | bounds.min.bytesPerKSecond = 0; |
| 167 | bounds.min.iosPerKSecond = 0; |
| 168 | bounds.min.bytesReadPerKSecond = 0; |
| 169 | |
| 170 | // The permitted error is 1/3 of the general-case minimum bytes (even in the special case where this is the last |
| 171 | // shard) |
| 172 | bounds.permittedError.bytes = bounds.max.bytes / SERVER_KNOBS->SHARD_BYTES_RATIO / 3; |
| 173 | bounds.permittedError.bytesPerKSecond = bounds.permittedError.infinity; |
| 174 | bounds.permittedError.iosPerKSecond = bounds.permittedError.infinity; |
| 175 | bounds.permittedError.bytesReadPerKSecond = bounds.permittedError.infinity; |
| 176 | |
| 177 | return bounds; |
| 178 | } |
| 179 | |
| 180 | int64_t getMaxShardSize(double dbSizeEstimate) { |
| 181 | return std::min((SERVER_KNOBS->MIN_SHARD_BYTES + (int64_t)std::sqrt(std::max<double>(dbSizeEstimate, 0)) * |
no outgoing calls
no test coverage detected