@@ -32,12 +32,14 @@ auto ClockMs() -> uint64_t {
32
32
return static_cast <uint64_t >(tm.tv_sec * 1000 ) + static_cast <uint64_t >(tm.tv_usec / 1000 );
33
33
}
34
34
35
- static const size_t BUSTUB_READ_THREAD = 4 ;
36
- static const size_t BUSTUB_WRITE_THREAD = 2 ;
35
+ static const size_t BUSTUB_READ_THREAD = 5 ;
36
+ static const size_t BUSTUB_WRITE_THREAD = 3 ;
37
37
static const size_t LRU_K_SIZE = 4 ;
38
- static const size_t BUSTUB_BPM_SIZE = 256 ;
39
- static const size_t TOTAL_KEYS = 100000 ;
38
+ static const size_t BUSTUB_BPM_SIZE = 2048 ;
39
+ static const size_t TOTAL_KEYS = 200000 ;
40
40
static const size_t KEY_MODIFY_RANGE = 2048 ;
41
+ static const size_t HTABLE_HEADER_DEPTH = 7 ;
42
+ static const size_t HTABLE_DIRECTORY_DEPTH = 9 ;
41
43
42
44
struct HTableTotalMetrics {
43
45
uint64_t write_cnt_{0 };
@@ -110,6 +112,9 @@ auto KeyWillVanish(size_t key) -> bool { return key % 7 == 0; }
110
112
// These keys will be overwritten to a new value
111
113
auto KeyWillChange (size_t key) -> bool { return key % 5 == 0 ; }
112
114
115
+ // These keys will not be present
116
+ auto KeyWillNeverBeInserted (size_t key) -> bool { return key % 3 == 0 ; }
117
+
113
118
// NOLINTNEXTLINE
114
119
auto main (int argc, char **argv) -> int {
115
120
using bustub::AccessType;
@@ -143,15 +148,18 @@ auto main(int argc, char **argv) -> int {
143
148
bustub::GenericComparator<8 > comparator (key_schema.get ());
144
149
145
150
bustub::DiskExtendibleHashTable<bustub::GenericKey<8 >, bustub::RID, bustub::GenericComparator<8 >> index (
146
- " foo_pk" , bpm.get (), comparator, bustub::HashFunction<bustub::GenericKey<8 >>());
151
+ " foo_pk" , bpm.get (), comparator, bustub::HashFunction<bustub::GenericKey<8 >>(), HTABLE_HEADER_DEPTH,
152
+ HTABLE_DIRECTORY_DEPTH);
147
153
148
154
for (size_t key = 0 ; key < TOTAL_KEYS; key++) {
149
- bustub::GenericKey<8 > index_key;
150
- bustub::RID rid;
151
- uint32_t value = key;
152
- rid.Set (value, value);
153
- index_key.SetFromInteger (key);
154
- index.Insert (index_key, rid, nullptr );
155
+ if (!KeyWillNeverBeInserted (key)) {
156
+ bustub::GenericKey<8 > index_key;
157
+ bustub::RID rid;
158
+ uint32_t value = key;
159
+ rid.Set (value, value);
160
+ index_key.SetFromInteger (key);
161
+ index.Insert (index_key, rid, nullptr );
162
+ }
155
163
}
156
164
157
165
fmt::print (stderr, " [info] benchmark start\n " );
@@ -183,12 +191,12 @@ auto main(int argc, char **argv) -> int {
183
191
index_key.SetFromInteger (key);
184
192
index.GetValue (index_key, &rids);
185
193
186
- if (!KeyWillVanish (key) && rids.empty ()) {
194
+ if (!KeyWillVanish (key) && ! KeyWillNeverBeInserted (key) && rids.empty ()) {
187
195
std::string msg = fmt::format (" key not found: {}" , key);
188
196
throw std::runtime_error (msg);
189
197
}
190
198
191
- if (!KeyWillVanish (key) && !KeyWillChange (key)) {
199
+ if (!KeyWillVanish (key) && !KeyWillNeverBeInserted (key) && ! KeyWillChange (key)) {
192
200
if (rids.size () != 1 ) {
193
201
std::string msg = fmt::format (" key not found: {}" , key);
194
202
throw std::runtime_error (msg);
@@ -257,7 +265,7 @@ auto main(int argc, char **argv) -> int {
257
265
for (auto &thread : threads) {
258
266
thread.join ();
259
267
}
260
-
268
+ index. VerifyIntegrity ();
261
269
total_metrics.Report ();
262
270
263
271
return 0 ;
0 commit comments