Skip to content

Commit 37b25bb

Browse files
ttreyerJakeHillion
authored andcommitted
Fix exclusive_size for F14NodeSet
1 parent 7836134 commit 37b25bb

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

test/integration/folly_f14_node_set.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ definitions = '''
7676
"staticSize":96,
7777
"exclusiveSize": 0,
7878
"members":[
79-
{"name":"m1", "staticSize":24, "exclusiveSize": 24, "length": 3, "capacity": 3},
80-
{"name":"m2", "staticSize":24, "exclusiveSize": 24, "length": 5, "capacity": 5},
81-
{"name":"m3", "staticSize":24, "exclusiveSize": 24, "length": 7, "capacity": 7},
82-
{"name":"m4", "staticSize":24, "exclusiveSize": 24, "length": 9, "capacity": 9}
79+
{"name":"m1", "staticSize":24, "exclusiveSize": 72, "length": 3, "capacity": 3},
80+
{"name":"m2", "staticSize":24, "exclusiveSize": 88, "length": 5, "capacity": 5},
81+
{"name":"m3", "staticSize":24, "exclusiveSize": 104, "length": 7, "capacity": 7},
82+
{"name":"m4", "staticSize":24, "exclusiveSize": 120, "length": 9, "capacity": 9}
8383
]}]'''

types/f14_node_set.toml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
6666
"""
6767

6868
traversal_func = """
69-
// TODO: This implementation enables the traversal of the container,
70-
// but doesn't report the memory footprint accurately.
71-
// Revisit this implementation and fix memory footprint reporting.
7269
auto tail = returnArg
73-
.write((uintptr_t)&container)
70+
.write((uintptr_t)container.getAllocatedMemorySize())
71+
.write((uintptr_t)container.bucket_count())
7472
.write(container.size());
7573
7674
for (auto &&entry: container) {
@@ -86,16 +84,26 @@ return tail.finish();
8684
type = "types::st::VarInt<DB>"
8785
func = "el.pointer = std::get<ParsedData::VarInt>(d.val).value;"
8886

87+
[[codegen.processor]]
88+
type = "types::st::VarInt<DB>"
89+
func = """
90+
el.container_stats.emplace(result::Element::ContainerStats {
91+
.capacity = std::get<ParsedData::VarInt>(d.val).value,
92+
});
93+
"""
94+
8995
[[codegen.processor]]
9096
type = """
9197
types::st::List<DB, typename TypeHandler<DB, T0>::type>
9298
"""
9399
func = """
100+
auto allocationSize = el.pointer.value();
101+
el.pointer.reset();
102+
94103
auto list = std::get<ParsedData::List>(d.val);
95-
el.container_stats.emplace(result::Element::ContainerStats {
96-
.capacity = list.length,
97-
.length = list.length,
98-
});
104+
el.container_stats->length = list.length;
105+
106+
el.exclusive_size += allocationSize - list.length * sizeof(T0);
99107
100108
static constexpr auto childField = make_field<DB, T0>("[]");
101109
for (size_t i = 0; i < list.length; i++)

0 commit comments

Comments
 (0)