Skip to content

Conversation

@PiotrSikora
Copy link
Member

Signed-off-by: Piotr Sikora [email protected]

@PiotrSikora PiotrSikora requested a review from mathetake May 11, 2021 07:14
@PiotrSikora
Copy link
Member Author

@mathetake could you take a look if this change (moving all bytecode processing from WasmVMs into WasmBase) makes sense? I think it's directionally correct, but it could use another set of eyes before I start rewriting tests.

@mathetake
Copy link
Contributor

just had a look and yeah this change makes sense to me. Thanks!

Copy link
Member Author

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

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

@mathetake PTAL, I left some comments to point out the API changes that might be worth discussing.

Envoy PR: envoyproxy/envoy#16430


bool initialize(const std::string &code, bool allow_precompiled = false);
bool load(const std::string &code, bool allow_precompiled = false);
bool initialize();
Copy link
Member Author

Choose a reason for hiding this comment

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

WasmBase::initialize(module, ...) is split into WasmBase::load(module, ...) and WasmBase::initialize(), and only the latter is called in clones (even in case of non-cloneable runtimes, since the base WasmBase is supposed to do all necessary pre-processing of the bytecode).

*/
virtual bool load(const std::string &code, bool allow_precompiled) = 0;
virtual bool load(std::string_view module, bool is_precompiled,
std::unordered_map<uint32_t, std::string> function_names) = 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

WasmVm::load() now takes either stripped or precompiled module, and function names index (i.e. .wasm file is preprocessed in WasmBase).

Copy link
Contributor

Choose a reason for hiding this comment

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

this seems premature optimization but we could share a single function_names map and pass here by reference to it so that we don't copy it to all the thread local VMs..

@PiotrSikora PiotrSikora marked this pull request as ready for review May 11, 2021 09:21
Copy link
Contributor

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

looks good, thanks! I left some nits.

*/
virtual bool load(const std::string &code, bool allow_precompiled) = 0;
virtual bool load(std::string_view module, bool is_precompiled,
std::unordered_map<uint32_t, std::string> function_names) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems premature optimization but we could share a single function_names map and pass here by reference to it so that we don't copy it to all the thread local VMs..

Copy link
Contributor

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

Thanks!

@PiotrSikora PiotrSikora merged commit 8ccb826 into proxy-wasm:master May 12, 2021
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.

2 participants