Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Conversation

@Quark-X10
Copy link
Contributor

Description

Two methods are added to the File interface : one to get the file disk size through H5Fget_filesize and the currently tracked unused space through H5Fget_freespace.
These can be useful when using a persistant unused space tracking strategy to decide when to trigger repacks after data multiple addition and deletion of data.

Unit tests have been written, however it may be irrelevant since the disk size may vary depending on the hdf5 library version.

How to test this?

cmake ..
make -j8
make test

Test System

  • OS: Ubuntu 22.04.2 LTS (WSL)
  • Compiler: gcc 11.3.0
  • Dependency versions: hdf5 1.10.7

@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Merging #764 (a8e82a5) into master (4573fd3) will increase coverage by 0.07%.
The diff coverage is 91.30%.

@@            Coverage Diff             @@
##           master     #764      +/-   ##
==========================================
+ Coverage   83.62%   83.70%   +0.07%     
==========================================
  Files          66       66              
  Lines        4496     4542      +46     
==========================================
+ Hits         3760     3802      +42     
- Misses        736      740       +4     
Impacted Files Coverage Δ
include/highfive/H5File.hpp 100.00% <ø> (ø)
include/highfive/bits/H5File_misc.hpp 90.66% <66.66%> (-4.58%) ⬇️
tests/unit/tests_high_five_base.cpp 99.66% <100.00%> (+<0.01%) ⬆️

Copy link
Collaborator

@1uc 1uc left a comment

Choose a reason for hiding this comment

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

Very nice, thank you! There's a few things I'd suggest changing. If you can take care of them that would be appreciated, if not we can do it.

}

/// \brief Get the disk size of this file in bytes
size_t getDiskSize() const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a wrapper for the function H5Fget_filesize. Could we use getFileSize instead?



{
File file(file_name_untracked, File::ReadWrite | File::Create | File::Truncate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI this can be reduced down to:

File file(file_name_untracked, File::Truncate);

It's consistent with the rest of the file so there's no reason to change it.

}

#if H5_VERSION_GE(1, 10, 1)
TEST_CASE("FileSizeAndUnusedSpace") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please split the test in two. One for the untracked file and one for the tracked variant.

}
}

#if H5_VERSION_GE(1, 10, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The reason it's needed it so set the file space strategy. The newly wrapped functions were introduced in HDF5 1.6.x and don't need guards.

File file(file_name_tracked, File::ReadWrite);
CHECK(file.getDiskSize() == tracked_file_size);
CHECK(file.getUnusedSpace() == tracked_unused_space);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

As you already said, these will fail. Since we're not testing if HDF5 is correct, it might be enough to check that:

  • the file size is >0.
  • the free space is == 0 (when applicable).
  • the free space is > 0 and < file_size (when applicable).

@1uc
Copy link
Collaborator

1uc commented May 30, 2023

Thank you for the PR, I'll merge it into a feature branch and apply the changes I mentioned.

@1uc 1uc changed the base branch from master to fileSize May 30, 2023 07:28
@1uc 1uc merged commit 3b9e19e into BlueBrain:fileSize May 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants