From 7836134343b274a6e97ca19f7b10aea354072c82 Mon Sep 17 00:00:00 2001 From: Thierry Treyer Date: Thu, 5 Oct 2023 11:12:44 -0700 Subject: [PATCH] Fix exclusive_size for F14VectorSet --- test/integration/folly_f14_vector_set.toml | 8 ++++---- types/f14_vector_set.toml | 24 ++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/test/integration/folly_f14_vector_set.toml b/test/integration/folly_f14_vector_set.toml index 98f7670..3ffad84 100644 --- a/test/integration/folly_f14_vector_set.toml +++ b/test/integration/folly_f14_vector_set.toml @@ -76,8 +76,8 @@ definitions = ''' "staticSize":96, "exclusiveSize": 0, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 24, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 24, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 24, "length": 7, "capacity": 7}, - {"name":"m4", "staticSize":24, "exclusiveSize": 24, "length": 9, "capacity": 9} + {"name":"m1", "staticSize":24, "exclusiveSize": 60, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 64, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 76, "length": 7, "capacity": 7}, + {"name":"m4", "staticSize":24, "exclusiveSize": 84, "length": 9, "capacity": 9} ]}]''' diff --git a/types/f14_vector_set.toml b/types/f14_vector_set.toml index 772bf95..e94b8b9 100644 --- a/types/f14_vector_set.toml +++ b/types/f14_vector_set.toml @@ -66,11 +66,9 @@ struct TypeHandler> { """ traversal_func = """ -// TODO: This implementation enables the traversal of the container, -// but doesn't report the memory footprint accurately. -// Revisit this implementation and fix memory footprint reporting. auto tail = returnArg - .write((uintptr_t)&container) + .write((uintptr_t)container.getAllocatedMemorySize()) + .write((uintptr_t)container.bucket_count()) .write(container.size()); for (auto &&entry: container) { @@ -86,16 +84,26 @@ return tail.finish(); type = "types::st::VarInt" func = "el.pointer = std::get(d.val).value;" +[[codegen.processor]] +type = "types::st::VarInt" +func = """ +el.container_stats.emplace(result::Element::ContainerStats { + .capacity = std::get(d.val).value, +}); +""" + [[codegen.processor]] type = """ types::st::List::type> """ func = """ +auto allocationSize = el.pointer.value(); +el.pointer.reset(); + auto list = std::get(d.val); -el.container_stats.emplace(result::Element::ContainerStats { - .capacity = list.length, - .length = list.length, -}); +el.container_stats->length = list.length; + +el.exclusive_size += allocationSize - list.length * sizeof(T0); static constexpr auto childField = make_field("[]"); for (size_t i = 0; i < list.length; i++)