Skip to content

Conversation

@Schmluk
Copy link
Contributor

@Schmluk Schmluk commented Dec 5, 2025

  • Adds estimation of memory usage of the DSG
  • Estimation of attribute data usage is still a bit biased as it uses the serialization as proxy, might fix in the future if needed.
  • Adds utest (mostly for sanity checking, it might be a bit brittle / system dependent).

@marcusabate This should expose all of the data / interfaces you need if you want to create more detailed memory analyses. You can look through the individual implementations if you want to see how the different memory is counted.

Copy link
Collaborator

@nathanhhughes nathanhhughes left a comment

Choose a reason for hiding this comment

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

LGTM! Some suggestions on the unit tests to make them a little bit more change-proof, but not super important

Comment on lines 262 to 263
EXPECT_LT(ratio, 2.0);
EXPECT_GT(ratio, 1.9);
Copy link
Collaborator

Choose a reason for hiding this comment

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

(minor) I'd maybe make this just EXPECT_GT(ratio, 1.0) to avoid having to update the unit test if we update how we compute memory (e.g., if we exactly compute the node attributes memory requirements)

Comment on lines +181 to +186
expected_size += 458;
EXPECT_EQ(graph.memoryUsage(), expected_size);

// Add a partitioned layer.
graph.addLayer(2, 1, "test_layer_partition");
expected_size += 120;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does adding a partition add more memory than just the layer? I'd maybe expect a couple more bytes for the longer name, but not ~300 bytes

Copy link
Contributor Author

@Schmluk Schmluk Dec 11, 2025

Choose a reason for hiding this comment

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

The non-partition layer actually adds more, I assume it's a matter of the ordering (maybe the first layer initializes data-tracking structures etc?). Otherwise I don't have a great idea why they should be different, I was also surprised that it is that much 😆

for (size_t i = 0; i < 100; ++i) {
edge_container.insert(i, i + 1, std::make_unique<EdgeAttributes>(i * 0.1));
}
expected_size += 100 * 100;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be good to resuse memoryUsage for the EdgeAttributes to avoid the tests failing if the edge attribute struct changes (which should work correctly because you tested that previously)


TEST(MemoryUsage, NodeAttributes) {
NodeAttributes attrs;
size_t expected_size = 47;
Copy link
Collaborator

Choose a reason for hiding this comment

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

idk how to make this robust to the attributes changing, so this is probably fine, but worth thinking about in the future

meta_contents["type"] = "Test node";
meta_contents["value"] = 123;
attrs.metadata.set(meta_contents);
expected_size = 109;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we do 47 + meta_contents.memoryUsage() so this is easier to update if the attribute definition changes

@Schmluk Schmluk merged commit 5faeab2 into develop Dec 12, 2025
9 of 10 checks passed
@Schmluk Schmluk deleted the feature/memory_tracking branch December 12, 2025 07:29
nathanhhughes pushed a commit that referenced this pull request Jan 12, 2026
* first implementation of memory tracking

* minor cleanup

* clean up utest with review feedback and fix meta data double counting
Schmluk added a commit that referenced this pull request Jan 13, 2026
* first implementation of memory tracking

* minor cleanup

* clean up utest with review feedback and fix meta data double counting
Schmluk added a commit that referenced this pull request Jan 25, 2026
* first implementation of memory tracking

* minor cleanup

* clean up utest with review feedback and fix meta data double counting
Schmluk added a commit that referenced this pull request Jan 25, 2026
* first implementation of memory tracking

* minor cleanup

* clean up utest with review feedback and fix meta data double counting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants