Optimizes the right way #4

Merged
merged 3 commits into from Aug 8, 2016

Conversation

Projects
None yet
2 participants
@walac
Contributor

walac commented Aug 8, 2016

PR #1 caused a bug that prevented file be entirely read. This PR revert those changes and makes optimization the right way by:

  • Replace standards stream with file IO, which has no locks.
  • Replace shared_ptr by unique_ptr. This avoid thread safe reference counting overhead.

walac added some commits Aug 8, 2016

Revert "Optimize file reading operation."
This reverts commit 19d8518.
This caused bustage on file reading. Using ios_base::eof() to mark end
of file is erroneous.
Replace standard IO streams by file IO.
ISO C++11 mandates standard IO streams be thread safe. The side effect
of this is that file IO through shell redirection get lock contention
performance issues. We provide command options for the user to to
specify the input and output files. In this case, we use fstream for
file IO, which doesn't suffer lock contention problems.
Replace shared_ptr by unique_ptr.
Profiling revealed shared_ptr reference count is causing performance
hits caused by atomic reference counting. We actually don't need a
shared_ptr here, unique_ptr + move semantics does the job with better
performance.

@Spagiari Spagiari merged commit ee947df into Spagiari:master Aug 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment