MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TestCompaction

Function TestCompaction

tensorflow/core/kernels/embedding_variable_ops_test.cc:1180–1237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1178}
1179
1180void TestCompaction() {
1181 std::string temp_dir = testing::TmpDir();
1182 auto feat_desc = new embedding::FeatureDescriptor<float>(
1183 1, 1, ev_allocator(), embedding::StorageType::DRAM_SSDHASH,
1184 true, true, {false, 0});
1185 auto hashmap = new SSDHashKV<int64, float>(
1186 temp_dir, feat_desc);
1187 feat_desc->InitSlotInfo(0, 124, {nullptr, 1});
1188 hashmap->Init();
1189 ASSERT_EQ(hashmap->Size(), 0);
1190 std::vector<int64> ids;
1191 for (int i = 0; i < 262144; i++) {
1192 ids.emplace_back(i);
1193 }
1194 auto t1 = std::thread(SingleCommit, hashmap, ids, 3);
1195 t1.join();
1196 ids.clear();
1197 for (int i = 0; i < 131073; i++) {
1198 ids.emplace_back(i);
1199 }
1200 t1 = std::thread(SingleCommit, hashmap, ids, 1);
1201 t1.join();
1202 ids.clear();
1203 sleep(1);
1204 void* val = nullptr;
1205 for (int i = 131073; i < 262144; i++) {
1206 hashmap->Lookup(i, &val);
1207 float* v = (float*)val;
1208 for (int j = 0; j < 124; j++){
1209 ASSERT_EQ(v[j], i+3);
1210 }
1211 }
1212 for (int i = 131073; i < 262144; i++) {
1213 ids.emplace_back(i);
1214 }
1215 t1 = std::thread(SingleCommit, hashmap, ids, 2);
1216 t1.join();
1217 ids.clear();
1218 ids.emplace_back(262155);
1219 t1 = std::thread(SingleCommit, hashmap, ids, 0);
1220 t1.join();
1221 sleep(1);
1222 for (int i = 0; i < 131073; i++) {
1223 hashmap->Lookup(i, &val);
1224 float* v = (float*)val;
1225 for (int j = 0; j < 124; j++){
1226 ASSERT_EQ(v[j], i + 1);
1227 }
1228 }
1229 for (int i = 131073; i < 262144; i++) {
1230 hashmap->Lookup(i, &val);
1231 float* v = (float*)val;
1232 for (int j = 0; j < 124; j++){
1233 ASSERT_EQ(v[j], i + 2);
1234 }
1235 }
1236 delete hashmap;
1237}

Callers 1

TESTFunction · 0.85

Calls 10

TmpDirFunction · 0.85
ev_allocatorFunction · 0.85
sleepFunction · 0.85
InitSlotInfoMethod · 0.45
InitMethod · 0.45
SizeMethod · 0.45
emplace_backMethod · 0.45
joinMethod · 0.45
clearMethod · 0.45
LookupMethod · 0.45

Tested by

no test coverage detected