commit 5269ed50adcdb0b6e8bb571fcef12392b09dc566
parent 6c9fea47615a529ae1587630a0d1acdc53e6f6de
Author: Kyle Milz <kyle@0x30.net>
Date: Wed, 20 Jul 2016 21:27:54 -0600
lib: send lines count differences as 32bit
Diffstat:
4 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/Test/Viewer.pm b/Test/Viewer.pm
@@ -89,8 +89,8 @@ sub get_dynamic_data {
for my $tu (@{ $self->{tus} }) {
my $num_lines = $tu->[1];
- my $buf = read_all($client, 8 * $num_lines);
- my @data_tmp = unpack("Q$num_lines", $buf);
+ my $buf = read_all($client, 4 * $num_lines);
+ my @data_tmp = unpack("L$num_lines", $buf);
$data{$tu->[0]} = \@data_tmp;
}
diff --git a/lib/runtime.c b/lib/runtime.c
@@ -188,21 +188,28 @@ send_dynamic(int fd)
struct citrun_node *w;
uint64_t *lines_ptr;
uint64_t *old_lines_ptr;
+ uint64_t diff64;
+ uint32_t diff;
int i;
int line;
- /* Write execution buffers (one 8 byte counter per source line). */
+ /* Write execution buffers. */
for (w = nodes_head, i = 0; w != NULL; w = w->next, i++) {
+ lines_ptr = w->lines_ptr;
+ old_lines_ptr = w->old_lines;
- lines_ptr = w->lines_ptr;
- old_lines_ptr = w->old_lines;
for (line = 0; line < w->size; line++) {
assert(lines_ptr[line] >= old_lines_ptr[line]);
+ diff64 = lines_ptr[line] - old_lines_ptr[line];
+
+ if (diff > UINT32_MAX)
+ diff = UINT32_MAX;
+ else
+ diff = diff64;
+ xwrite(fd, &diff, sizeof(uint32_t));
- uint64_t diff = lines_ptr[line] - old_lines_ptr[line];
/* Let's try incremental updating of old_lines. */
- old_lines_ptr[line] = lines_ptr[line];
- xwrite(fd, &diff, sizeof(uint64_t));
+ old_lines_ptr[line] += diff64;
}
}
assert(i == nodes_total);
diff --git a/src/runtime_conn.cc b/src/runtime_conn.cc
@@ -66,7 +66,7 @@ void
RuntimeProcess::read_executions()
{
for (auto &t : translation_units) {
- size_t bytes_total = t.num_lines * sizeof(uint64_t);
+ size_t bytes_total = t.num_lines * sizeof(uint32_t);
socket.read_all((uint8_t *)&t.execution_counts[0], bytes_total);
}
diff --git a/src/runtime_conn.h b/src/runtime_conn.h
@@ -9,7 +9,7 @@ struct TranslationUnit {
std::string file_name;
uint32_t num_lines;
uint32_t inst_sites;
- std::vector<uint64_t> execution_counts;
+ std::vector<uint32_t> execution_counts;
std::vector<std::string> source;
};