Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tbv2: implement folly::IOBuf #437

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions types/folly_iobuf_type.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,34 @@ void getSizeType(const %1% &container, size_t& returnArg)
SAVE_SIZE(fullCapacity);
}
"""

traversal_func = """
// We calculate the length of all IOBufs in the chain manually.
// IOBuf has built-in computeChainCapacity()/computeChainLength()
// functions which do this for us. But dead code optimization in TAO
// caused these functions to be removed which causes relocation
// errors.

std::size_t fullLength = container.length();
std::size_t fullCapacity = container.capacity();
for (const folly::IOBuf* current = container.next(); current != &container;
current = current->next()) {
fullLength += current->length();
fullCapacity += current->capacity();
}

return returnArg.write(fullCapacity).write(fullLength);
"""

[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
el.container_stats.emplace(result::Element::ContainerStats{ .capacity = std::get<ParsedData::VarInt>(d.val).value });
el.exclusive_size += el.container_stats->capacity;
"""

[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
el.container_stats->length = std::get<ParsedData::VarInt>(d.val).value;
"""