# Group Overhead - File size problem for hierarchical data

**URL:** <https://forum.hdfgroup.org/t/group-overhead-file-size-problem-for-hierarchical-data/9640>\
**Category:** HDF5 Library\
**Created:** [April 7, 2022, 3:27pm UTC](https://forum.hdfgroup.org/t/group-overhead-file-size-problem-for-hierarchical-data/9640 "2022-04-07T15:27:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [April 7, 2022, 4:45pm UTC](https://forum.hdfgroup.org/t/group-overhead-file-size-problem-for-hierarchical-data/9640/2 "2022-04-07T16:45:43Z")

</div>

# [group entry size](https://github.com/steven-varga/HDFGroup-mailinglist/tree/master/group-entry-size-2022-04-07)

I found the avg size to be **800 bytes** per entry, the following program generates `N = 400'000` random strings then accumulates the total space needed. Then we move on to create `N` groups, measure the disk space taken up them calculate the difference. Eyeballing it I got `700 ~ 800 bytes` per entry; did I miss something? _Project may be downloaded from this [gitHUB page](https://github.com/steven-varga/HDFGroup-mailinglist/tree/master/group-entry-size-2022-04-07)_

```auto
#include "include/h5cpp/all"

#include <string>
#include <iterator>
#include <filesystem>

int main(int argc, char **argv) {
    std::string path = "groups.h5";
    size_t N = 400'000, strings_size=0;
    auto names = h5::utils::get_test_data<std::string>(N);
    for(auto a: names) strings_size+= a.size() * sizeof(std::string::value_type);

    { // code block will enforce RAII, as we need file closed to measure size
    h5::fd_t fd = h5::create(path, H5F_ACC_TRUNC);

    h5::gr_t root{H5Gopen(fd, "/", H5P_DEFAULT)}; // using H5CPP RAII
    for(size_t n=0; n < N; n++)
        h5::gr_t{H5Gcreate(root, names[n].data(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)}; 
    } // HDF5 file is closed, grab size
    namespace fs = std::filesystem;
    size_t file_size = fs::file_size(
        fs::current_path() / fs::path(path));
    std::cout << file_size <<"-"<< strings_size <<"=" << (file_size - strings_size) / 1'000'000 << "MB\n\n";
    std::cout << "avg: " << (file_size - strings_size) / N <<"bytes/group entry\n\n";
    return 0;
}

```

**results** :

```auto
g++ -I./include -o group-test.o -std=c++17 -DFMT_HEADER_ONLY -c group-test.cpp
g++ group-test.o -lhdf5 -lz -ldl -lm -o group-test
./group-test
79466744-1748345=77MB

avg: 777bytes/group entry

```

---

_[View the full topic](https://forum.hdfgroup.org/t/group-overhead-file-size-problem-for-hierarchical-data/9640)._
