Skip to content

Commit

Permalink
Add simple progress percentage display
Browse files Browse the repository at this point in the history
  • Loading branch information
aqk authored and hoffmang9 committed Mar 25, 2021
1 parent 2f88912 commit 768ea53
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/phase1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "sort_manager.hpp"
#include "threading.hpp"
#include "util.hpp"
#include "progress.hpp"

struct THREADDATA {
int index;
Expand Down Expand Up @@ -742,6 +743,7 @@ std::vector<uint64_t> RunPhase1(

prevtableentries = globals.right_writer_count;
table_timer.PrintElapsed("Forward propagation table time:");
progress(1, table_index, 6);
}
table_sizes[0] = 0;
globals.R_sort_manager.reset();
Expand Down
2 changes: 2 additions & 0 deletions src/phase2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "sort_manager.hpp"
#include "bitfield.hpp"
#include "bitfield_index.hpp"
#include "progress.hpp"

struct Phase2Results
{
Expand Down Expand Up @@ -237,6 +238,7 @@ Phase2Results RunPhase2(
if (table_index != 7) {
tmp_1_disks[table_index].Truncate(0);
}
progress(2, 8 - table_index, 6);
}

// lazy-compact table 1 based on current_bitfield
Expand Down
2 changes: 2 additions & 0 deletions src/phase3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "exceptions.hpp"
#include "pos_constants.hpp"
#include "sort_manager.hpp"
#include "progress.hpp"

// Results of phase 3. These are passed into Phase 4, so the checkpoint tables
// can be properly built.
Expand Down Expand Up @@ -488,6 +489,7 @@ Phase3Results RunPhase3(

left_disk.FreeMemory();
right_disk.FreeMemory();
progress(3, table_index, 6);
}

L_sort_manager->FreeMemory();
Expand Down
8 changes: 8 additions & 0 deletions src/phase4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "phase3.hpp"
#include "pos_constants.hpp"
#include "util.hpp"
#include "progress.hpp"

// Writes the checkpoint tables. The purpose of these tables, is to store a list of ~2^k values
// of size k (the proof of space outputs from table 7), in a way where they can be looked up for
Expand Down Expand Up @@ -79,6 +80,8 @@ void RunPhase4(uint8_t k, uint8_t pos_size, FileDisk &tmp2_disk, Phase3Results &
std::cout << "\tStarting to write C1 and C3 tables" << std::endl;

ParkBits to_write_p7;
const int max_phase4_progress_updates = 16;
const int progress_update_increment = res.final_entries_written / max_phase4_progress_updates;

// We read each table7 entry, which is sorted by f7, but we don't need f7 anymore. Instead,
// we will just store pos6, and the deltas in table C3, and checkpoints in tables C1 and C2.
Expand Down Expand Up @@ -133,6 +136,9 @@ void RunPhase4(uint8_t k, uint8_t pos_size, FileDisk &tmp2_disk, Phase3Results &
}
prev_y = entry_y;
}
if (f7_position % progress_update_increment == 0) {
progress(4, f7_position, res.final_entries_written);
}
}
Encoding::ANSFree(kC3R);
res.table7_sm.reset();
Expand Down Expand Up @@ -194,5 +200,7 @@ void RunPhase4(uint8_t k, uint8_t pos_size, FileDisk &tmp2_disk, Phase3Results &
std::cout << ": 0x" << res.final_table_begin_pointers[i] << std::endl;
}
std::cout << std::dec;
progress(4, res.final_entries_written, res.final_entries_written);

}
#endif // SRC_CPP_PHASE4_HPP
11 changes: 11 additions & 0 deletions src/progress.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef SRC_CPP_PROGRESS_HPP_
#define SRC_CPP_PROGRESS_HPP_

#include <iostream>

void progress(int phase, int n, int max_n) {
float p = (100.0 / 4) * ((phase - 1.0) + (1.0 * n / max_n));
std::cout << "Progress: " << p << std::endl;
}

#endif // SRC_CPP_PROGRESS_HPP

0 comments on commit 768ea53

Please sign in to comment.