Adds finer-grain GC
authorPeizhao Ou <peizhaoo@uci.edu>
Thu, 1 Feb 2018 21:24:52 +0000 (13:24 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Thu, 1 Feb 2018 21:24:52 +0000 (13:24 -0800)
.gitignore
test/junction_driver.cpp

index adf8787..66d4795 100644 (file)
@@ -2,3 +2,7 @@
 CMakeLists.txt.user
 *~
 *.log
+*.o
+*.bc
+junction_driver
+stress-*
index 68ef214..62b9d62 100644 (file)
@@ -11,22 +11,25 @@ namespace {
 
 const unsigned s_nInsertPercentage = 10;
 const char* kTestName = "InsDelFind";
+// Run GC after "kGCFrequency" operations.
+const size_t kGCFrequency = 3000;
+
+const size_t kCrudeMapSize = 10000;
+const size_t kCrudePassCount = 40000;
+const char* kCrudeBenchmarkName = "JunctionMapCrude";
+
 const size_t kGrampaMapSize = 20000;
 const size_t kGrampaPassCount = 30000;
 const char* kGrampaBenchmarkName = "JunctionMapGrampa";
 
-const size_t kLinearMapSize = 25000;
-const size_t kLinearPassCount = 30000;
+const size_t kLinearMapSize = 20000;
+const size_t kLinearPassCount = 70000;
 const char* kLinearBenchmarkName = "JunctionMapLinear";
 
-const size_t kLeapfrogMapSize = 25000;
-const size_t kLeapfrogPassCount = 30000;
+const size_t kLeapfrogMapSize = 20000;
+const size_t kLeapfrogPassCount = 75000;
 const char* kLeapfrogBenchmarkName = "JunctionMapLeapfrog";
 
-const size_t kCrudeMapSize = 10000;
-const size_t kCrudePassCount = 120000;
-const char* kCrudeBenchmarkName = "JunctionMapCrude";
-
 } // namespace
 
 typedef junction::ConcurrentMap_Grampa<size_t, size_t> GrampaMap;
@@ -41,6 +44,7 @@ void run_crude_map(size_t map_size, size_t pass_count, const char* bench_name) {
 
     size_t nInsertedNum = 0;
     size_t nFindSuccess = 0;
+    size_t nOperations = 0;
     // Seems like the crude map won't resize, so better have a large enough
     // capacity.
     std::unique_ptr<Map> map(new Map(map_size * 32));
@@ -69,9 +73,13 @@ void run_crude_map(size_t map_size, size_t pass_count, const char* bench_name) {
 //                    std::cout << "Erased" << i << "\n";
                 }
             }
-            junction::DefaultQSBR.update(qsbrContext);
+            if (++nOperations > kGCFrequency) {
+              junction::DefaultQSBR.update(qsbrContext);
+              nOperations = 0;
+            }
         }
     }
+    junction::DefaultQSBR.update(qsbrContext);
     auto finish_time = std::chrono::system_clock::now();
     auto dur = finish_time - start_time;
     auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
@@ -95,6 +103,7 @@ void run_test(size_t map_size, size_t pass_count, const char* bench_name) {
 
     size_t nInsertedNum = 0;
     size_t nFindSuccess = 0;
+    size_t nOperations = 0;
     std::unique_ptr<Map> map(new Map());
     auto qsbrContext = junction::DefaultQSBR.createContext();
     for (size_t count = 0; count < pass_count; count++) {
@@ -126,7 +135,10 @@ void run_test(size_t map_size, size_t pass_count, const char* bench_name) {
 //                    std::cout << "Erased" << i << "\n";
                 }
             }
-            junction::DefaultQSBR.update(qsbrContext);
+            if (++nOperations > kGCFrequency) {
+                junction::DefaultQSBR.update(qsbrContext);
+                nOperations = 0;
+            }
         }
     }
     auto finish_time = std::chrono::system_clock::now();
@@ -146,9 +158,9 @@ void run_test(size_t map_size, size_t pass_count, const char* bench_name) {
 }
 
 int main() {
-    run_crude_map<CrudeMap>(kCrudeMapSize, kCrudePassCount, kCrudeBenchmarkName);
-    run_test<LeapfrogMap>(kLeapfrogMapSize, kLeapfrogPassCount, kLeapfrogBenchmarkName);
     run_test<LinearMap>(kLinearMapSize, kLinearPassCount, kLinearBenchmarkName);
+    run_test<LeapfrogMap>(kLeapfrogMapSize, kLeapfrogPassCount, kLeapfrogBenchmarkName);
     run_test<GrampaMap>(kGrampaMapSize, kGrampaPassCount, kGrampaBenchmarkName);
+    run_crude_map<CrudeMap>(kCrudeMapSize, kCrudePassCount, kCrudeBenchmarkName);
     return 0;
 }