]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: when starting the sampling profiler, the data needs to be cleared
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 6 May 2016 17:56:13 +0000 (19:56 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Fri, 6 May 2016 17:56:13 +0000 (19:56 +0200)
basis/tools/profiler/sampling/sampling-tests.factor
vm/sampling_profiler.cpp

index 91fe547c35c4cdefe6de38f01fc9e39a43dd95bd..51a948b56f1ee2aa87b474be907fae43fa6b8be8 100644 (file)
@@ -1,6 +1,6 @@
-USING: byte-arrays calendar kernel math memory namespaces
-random threads tools.profiler.sampling
-tools.profiler.sampling.private tools.test sequences ;
+USING: byte-arrays calendar kernel math memory namespaces parser
+random sequences threads tools.profiler.sampling
+tools.profiler.sampling.private tools.test ;
 IN: tools.profiler.sampling.tests
 
 ! Make sure the profiler doesn't blow up the VM
@@ -16,3 +16,11 @@ TUPLE: boom ;
 
 f raw-profile-data set-global
 gc
+
+{ t 0 } [
+    ! Seed the samples data
+    [ "resource:basis/tools/memory/memory.factor" run-file ] profile
+    (get-samples) length 0 >
+    ! Should clear it
+    [ ] profile (get-samples) length
+] unit-test
index dc6def6ed2352047b39174ca9eb10b3a234558ef..90152f5db6f4c8c4ab0699823d617352fad1fb74 100644 (file)
@@ -71,8 +71,11 @@ void factor_vm::start_sampling_profiler(fixnum rate) {
   samples_per_second = rate;
   safepoint.sample_counts.clear();
   // Release the memory consumed by colleting samples.
+  samples.clear();
   samples.shrink_to_fit();
+  sample_callstacks.clear();
   sample_callstacks.shrink_to_fit();
+
   samples.reserve(10 * rate);
   sample_callstacks.reserve(100 * rate);
   atomic::store(&sampling_profiler_p, true);