18
18
#include < alaska/alaska.hpp>
19
19
#include < alaska/rt/barrier.hpp>
20
20
#include " alaska/ObjectReference.hpp"
21
+ #include " alaska/SizeClass.hpp"
21
22
#include < pthread.h>
22
23
#include < stdio.h>
23
24
#include < signal.h>
@@ -42,13 +43,13 @@ static pthread_t barrier_thread;
42
43
static void *barrier_thread_func (void *) {
43
44
bool in_marking_state = true ;
44
45
45
- FILE *log_file = fopen ( " cold.csv " , " w " );
46
- // fprintf(log_file, "cold_objects\n");
46
+
47
+
47
48
while (1 ) {
48
49
auto &rt = alaska::Runtime::get ();
49
- usleep (50 * 1000 );
50
-
50
+ usleep (250 * 1000 );
51
51
// continue;
52
+
52
53
long already_invalid = 0 ;
53
54
long total_handles = 0 ;
54
55
long newly_marked = 0 ;
@@ -57,8 +58,12 @@ static void *barrier_thread_func(void *) {
57
58
// Linear Congruential Generator parameters
58
59
unsigned int seed = 123456789 ; // You can set this to any initial value
59
60
61
+
62
+ int stride = 20 ;
63
+ int offset = 0 ;
64
+
60
65
rt.with_barrier ([&]() {
61
- // printf("\033[2J\033[H");
66
+ printf (" \033 [2J\033 [H" );
62
67
// rt.handle_table.dump(stdout);
63
68
rt.heap .dump (stdout);
64
69
return ;
@@ -75,6 +80,7 @@ static void *barrier_thread_func(void *) {
75
80
};
76
81
77
82
auto should_mark = [&]() -> bool {
83
+ return true ;
78
84
// return in_marking_state;
79
85
// return in_marking_state and (random_range(0, 2) == 1);
80
86
return random_range (0 , 10 ) == 1 ;
@@ -97,22 +103,19 @@ static void *barrier_thread_func(void *) {
97
103
};
98
104
99
105
auto &slabs = rt.handle_table .get_slabs ();
100
- // printf("slabs = %d\n", slabs.size());
101
106
102
107
auto start = alaska_timestamp ();
103
108
if (slabs.size () != 0 ) {
104
109
auto *slab = slabs[random_range (0 , slabs.size () - 1 )];
105
110
mark_in_slab (slab);
106
111
}
112
+
107
113
// for (auto *slab : slabs)
108
114
// mark_in_slab(slab);
109
115
110
116
auto end = alaska_timestamp ();
111
-
112
117
auto duration = (end - start) / 1000.0 / 1000.0 ;
113
118
114
-
115
-
116
119
cold_perc = ((float )already_invalid / (float )total_handles);
117
120
if (cold_perc > 0.7 ) {
118
121
in_marking_state = false ;
@@ -122,21 +125,23 @@ static void *barrier_thread_func(void *) {
122
125
in_marking_state = true ;
123
126
}
124
127
125
- fprintf (log_file, " %f\n " , cold_perc * 100.0 );
126
- fflush (log_file);
127
- // printf(
128
- // "%d | cold objects: %12.6f%% | %8lu inv | %8lu obj | %8zu faults | %8lu added |
129
- // %12fms\n", in_marking_state, 100.0 * cold_perc, already_invalid, total_handles,
130
- // rt.handle_faults, newly_marked, duration);
131
- // printf("Compacting\n");
132
- // alaska::Runtime::get().heap.compact_sizedpages();
128
+ printf (" handle faults per second: %f\n " , rt.handle_faults .digest ());
133
129
});
134
130
}
135
131
136
132
return NULL ;
137
133
}
138
134
139
135
void __attribute__ ((constructor(102 ))) alaska_init(void ) {
136
+
137
+
138
+ printf (" /// %8s, %8s, %20s\n " , " class" , " size" , " page type" );
139
+ for (int i = 0 ; i < alaska::num_size_classes; i++) {
140
+ size_t size = alaska::class_to_size (i);
141
+ printf (" _SC(%8d, %8zu, %20s)\n " , i, size, " alaska::SizedPage" );
142
+ }
143
+
144
+ exit (-1 );
140
145
// Allocate the runtime simply by creating a new instance of it. Everywhere
141
146
// we use it, we will use alaska::Runtime::get() to get the singleton instance.
142
147
the_runtime = new alaska::Runtime ();
0 commit comments