@@ -135,10 +135,9 @@ struct Config {
135
135
};
136
136
137
137
// fill the CAS with random data of specified tree depth and children numbers.
138
- static void fillData (ObjectStore &CAS, const Config &Conf) {
138
+ static void fillData (ObjectStore &CAS, ActionCache &AC, const Config &Conf) {
139
139
ExitOnError ExitOnErr (" llvm-cas-test fill data: " );
140
140
DefaultThreadPool ThreadPool (hardware_concurrency ());
141
- std::atomic<uint64_t > NumCreated = 0 ;
142
141
for (size_t I = 0 ; I != Conf.NumShards ; ++I) {
143
142
ThreadPool.async ([&] {
144
143
std::vector<ObjectRef> Refs;
@@ -163,8 +162,11 @@ static void fillData(ObjectStore &CAS, const Config &Conf) {
163
162
auto Ref = ExitOnErr (CAS.store (Parent, Data));
164
163
Created.push_back (Ref);
165
164
}
166
- ++NumCreated;
167
165
}
166
+ // Put a self mapping in action cache to avoid cache poisoning.
167
+ if (!Created.empty ())
168
+ ExitOnErr (
169
+ AC.put (CAS.getID (Created.back ()), CAS.getID (Created.back ())));
168
170
Refs.swap (Created);
169
171
}
170
172
});
@@ -179,7 +181,7 @@ static int genData() {
179
181
Conf.init ();
180
182
181
183
auto DB = ExitOnErr (cas::createOnDiskUnifiedCASDatabases (CASPath));
182
- fillData (*DB.first , Conf);
184
+ fillData (*DB.first , *DB. second , Conf);
183
185
184
186
return 0 ;
185
187
}
@@ -203,10 +205,11 @@ static int runOneTest(const char *Argv0) {
203
205
}
204
206
205
207
auto DB = ExitOnErr (cas::createOnDiskUnifiedCASDatabases (CASPath));
206
- auto &CAS = DB.first ;
208
+ auto &CAS = *DB.first ;
209
+ auto &AC = *DB.second ;
207
210
208
211
// Size limit in MB.
209
- ExitOnErr (CAS-> setSizeLimit (SizeLimit * 1024 * 1024 ));
212
+ ExitOnErr (CAS. setSizeLimit (SizeLimit * 1024 * 1024 ));
210
213
if (Conf.Settings & Fork) {
211
214
// fill data using sub processes.
212
215
std::string MainExe = sys::fs::getMainExecutable (Argv0, &CASPath);
@@ -236,12 +239,12 @@ static int runOneTest(const char *Argv0) {
236
239
237
240
} else {
238
241
// in-process fill data.
239
- fillData (* CAS, Conf);
242
+ fillData (CAS, AC , Conf);
240
243
}
241
244
242
245
// validate and prune in the end.
243
- ExitOnErr (CAS-> validate (true ));
244
- ExitOnErr (CAS-> pruneStorageData ());
246
+ ExitOnErr (CAS. validate (true ));
247
+ ExitOnErr (CAS. pruneStorageData ());
245
248
246
249
return 0 ;
247
250
}
0 commit comments