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

flatbuffer builder reuse #1422

Merged
merged 3 commits into from
Jul 4, 2024
Merged

Conversation

Lynnworld
Copy link
Contributor

use flatbuffer Builder Clear() , so it can reuse it's inner buf .

void | Clear () // Reset all the state in this FlatBufferBuilder so it can be reused to construct another buffer.

https://flatbuffers.dev/classflatbuffers_1_1_flat_buffer_builder.html#ae94b94ba71ea0aeb2d9a98c43b713412

Copy link
Member

@ibc ibc left a comment

Choose a reason for hiding this comment

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

Thanks a lot. Just a cosmetic request.

worker/src/Channel/ChannelRequest.cpp Outdated Show resolved Hide resolved
@jmillan
Copy link
Member

jmillan commented Jul 4, 2024

Currently we use Reset() which calls Clear() plus deallocates the buffer. So indeed yes, calling Clear() is just enough and does not require to reallocate the buffer on the next call.

But this PR should only replace Reset() by Clear(). It's not necessary to move the builder from being an instance member to a thread local variable.

@Lynnworld
Copy link
Contributor Author

current Channel socket will new ChannelRequest every time , so try to reuse request instead of thread_local builder ?

@jmillan
Copy link
Member

jmillan commented Jul 4, 2024

current Channel socket will new ChannelRequest every time , so try to reuse request instead of thread_local builder ?

Correct, that's orthogonal to Reset() replacement described in the PR description, but it's true, we can reuse the FlatBufferBuilder for every request since all responses are synchronous at the moment.

@jmillan
Copy link
Member

jmillan commented Jul 4, 2024

Please run the linter npm run lint:worker

@ibc
Copy link
Member

ibc commented Jul 4, 2024

Thanks, merging.

@ibc ibc merged commit 2f30a84 into versatica:v3 Jul 4, 2024
41 checks passed
@Lynnworld
Copy link
Contributor Author

oops, I'll make a new PR later for ChannelRequest and ChannelNotification reuse , and remove threal_local static . @jmillan @ibc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants