Skip to content

Commit a006f45

Browse files
committed
add some temp debugging to the barrier
1 parent dfc6d8b commit a006f45

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

runtime/rt/init.cpp

+22-17
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <alaska/alaska.hpp>
1919
#include <alaska/rt/barrier.hpp>
2020
#include "alaska/ObjectReference.hpp"
21+
#include "alaska/SizeClass.hpp"
2122
#include <pthread.h>
2223
#include <stdio.h>
2324
#include <signal.h>
@@ -42,13 +43,13 @@ static pthread_t barrier_thread;
4243
static void *barrier_thread_func(void *) {
4344
bool in_marking_state = true;
4445

45-
FILE *log_file = fopen("cold.csv", "w");
46-
// fprintf(log_file, "cold_objects\n");
46+
47+
4748
while (1) {
4849
auto &rt = alaska::Runtime::get();
49-
usleep(50 * 1000);
50-
50+
usleep(250 * 1000);
5151
// continue;
52+
5253
long already_invalid = 0;
5354
long total_handles = 0;
5455
long newly_marked = 0;
@@ -57,8 +58,12 @@ static void *barrier_thread_func(void *) {
5758
// Linear Congruential Generator parameters
5859
unsigned int seed = 123456789; // You can set this to any initial value
5960

61+
62+
int stride = 20;
63+
int offset = 0;
64+
6065
rt.with_barrier([&]() {
61-
// printf("\033[2J\033[H");
66+
printf("\033[2J\033[H");
6267
// rt.handle_table.dump(stdout);
6368
rt.heap.dump(stdout);
6469
return;
@@ -75,6 +80,7 @@ static void *barrier_thread_func(void *) {
7580
};
7681

7782
auto should_mark = [&]() -> bool {
83+
return true;
7884
// return in_marking_state;
7985
// return in_marking_state and (random_range(0, 2) == 1);
8086
return random_range(0, 10) == 1;
@@ -97,22 +103,19 @@ static void *barrier_thread_func(void *) {
97103
};
98104

99105
auto &slabs = rt.handle_table.get_slabs();
100-
// printf("slabs = %d\n", slabs.size());
101106

102107
auto start = alaska_timestamp();
103108
if (slabs.size() != 0) {
104109
auto *slab = slabs[random_range(0, slabs.size() - 1)];
105110
mark_in_slab(slab);
106111
}
112+
107113
// for (auto *slab : slabs)
108114
// mark_in_slab(slab);
109115

110116
auto end = alaska_timestamp();
111-
112117
auto duration = (end - start) / 1000.0 / 1000.0;
113118

114-
115-
116119
cold_perc = ((float)already_invalid / (float)total_handles);
117120
if (cold_perc > 0.7) {
118121
in_marking_state = false;
@@ -122,21 +125,23 @@ static void *barrier_thread_func(void *) {
122125
in_marking_state = true;
123126
}
124127

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());
133129
});
134130
}
135131

136132
return NULL;
137133
}
138134

139135
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);
140145
// Allocate the runtime simply by creating a new instance of it. Everywhere
141146
// we use it, we will use alaska::Runtime::get() to get the singleton instance.
142147
the_runtime = new alaska::Runtime();

0 commit comments

Comments
 (0)