Skip to content

Commit

Permalink
10 bit change plus some added debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
wjblanke authored and hoffmang9 committed Aug 21, 2020
1 parent 5c1a7c5 commit 761394f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/plotter_disk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace fs = ghc::filesystem;
// Other constants can be found in pos_constants.hpp

// Distance between matching entries is stored in the offset
const uint32_t kOffsetSize = 9;
const uint32_t kOffsetSize = 10;

// Number of buckets to use for SortOnDisk.
const uint32_t kNumSortBuckets = 16;
Expand Down Expand Up @@ -173,6 +173,8 @@ class DiskPlotter {

std::cout << "Approximate working space used (without final file): " <<
static_cast<double>(res.plot_table_begin_pointers[9])/(1024*1024*1024) << " GiB" << std::endl;
std::cout << "Actual working space used (without final file): " <<
static_cast<double>(tmp1_disk.GetWriteMax())/(1024*1024*1024) << " GiB" << std::endl;
std::cout << "Final File size: " <<
static_cast<double>(res.final_table_begin_pointers[11])/(1024*1024*1024) << " GiB" << std::endl;
all_phases.PrintElapsed("Total time =");
Expand Down Expand Up @@ -210,6 +212,9 @@ class DiskPlotter {
else {
std::cout << "Copied final file from " << tmp_2_filename << " to " << final_2_filename << std::endl;
bCopied=true;

bool removed_2 = fs::remove(tmp_2_filename);
std::cout << "Removed temp2 file " << tmp_2_filename << "? " << removed_2 << std::endl;
}
}
if(bCopied && (!bRenamed)) {
Expand All @@ -232,9 +237,6 @@ class DiskPlotter {
#endif
}
} while (!bRenamed);

bool removed_2 = fs::remove(tmp_2_filename);
std::cout << "Removed temp2 file " << tmp_2_filename << "? " << removed_2 << std::endl;
}

static uint32_t GetMaxEntrySize(uint8_t k, uint8_t table_index, bool phase_1_size) {
Expand Down
12 changes: 10 additions & 2 deletions src/sort_on_disk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FileDisk : public Disk {
amtread = fread(reinterpret_cast<char*>(memcache), sizeof(uint8_t), length, f_);
readPos=begin + amtread;
if(amtread != length) {
std::cout << "Only read " << amtread << " of " << length << " bytes from " << filename_ << ". Error " << ferror(f_) << ". Retrying in five minutes." << std::endl;
std::cout << "Only read " << amtread << " of " << length << " bytes at offset " << begin << " from " << filename_ << "with length " << writeMax << ". Error " << ferror(f_) << ". Retrying in five minutes." << std::endl;
#ifdef WIN32
Sleep(5 * 60000);
#else
Expand All @@ -135,8 +135,10 @@ class FileDisk : public Disk {
}
amtwritten = fwrite(reinterpret_cast<const char*>(memcache), sizeof(uint8_t), length, f_);
writePos=begin+amtwritten;
if(writePos > writeMax)
writeMax = writePos;
if(amtwritten != length) {
std::cout << "Only wrote " << amtwritten << " of " << length << " bytes to " << filename_ << ". Error " << ferror(f_) << ". Retrying in five minutes." << std::endl;
std::cout << "Only wrote " << amtwritten << " of " << length << " bytes at offset " << begin << " to " << filename_ << "with length " << writeMax << ". Error " << ferror(f_) << ". Retrying in five minutes." << std::endl;
#ifdef WIN32
Sleep(5 * 60000);
#else
Expand All @@ -150,9 +152,15 @@ class FileDisk : public Disk {
return filename_;
}

inline uint64_t GetWriteMax() const noexcept {
return writeMax;
}


private:
uint64_t readPos=0;
uint64_t writePos=0;
uint64_t writeMax=0;
bool bReading=true;

std::string filename_;
Expand Down

0 comments on commit 761394f

Please sign in to comment.