Skip to content

Increase read buffer to reduce total syscalls #2772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/libpugiutil/src/pugixml_loc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void loc_data::build_loc_data() {

std::ptrdiff_t offset = 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think we should make a defined constant with a comment for this magic number though, e.g.
#define VTR_LARGE_BUF 1048576 // Read large files like the arch.xml with large buffers for speed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a comment on why too.

char buffer[1024];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use same defined constant (put in some header, with a comment, or in as a -D make/cmake variable with a comment)

char buffer[1048576];
std::size_t size;

while ((size = fread(buffer, 1, sizeof(buffer), f)) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion libs/libvtrutil/src/vtr_digest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ std::string secure_digest_stream(std::istream& is) {
//Read the stream in chunks and calculate the SHA256 digest
picosha2::hash256_one_by_one hasher;

std::array<char, 1024> buf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use defined constant.

std::array<char, 1048576> buf;
while (!is.eof()) {
//Process a chunk
is.read(buf.data(), buf.size());
Expand Down
Loading