Fix(jit): optimize call_indirect with fast-path type check (#4369)#4613
Fix(jit): optimize call_indirect with fast-path type check (#4369)#4613Harsh-6291 wants to merge 7 commits intoWasmEdge:masterfrom
Conversation
…4369) Signed-off-by: harsh6921 <[email protected]>
lib/executor/engine/proxy.cpp
Outdated
| bool IsMatch = false; | ||
| if (FuncInst->getModule()) { | ||
| if (FuncInst->getModule() == ModInst) { | ||
| IsMatch = (*ExpDefType.getTypeIndex() == FuncInst->getTypeIndex()); |
There was a problem hiding this comment.
This will fail in the case of the type index not the same but type matched.
There was a problem hiding this comment.
@q82419 i have made little change now it handle this case
There was a problem hiding this comment.
Please add the comment to clearly describe the reason of this if-statement.
Signed-off-by: harsh6921 <[email protected]>
153da93 to
3472ece
Compare
|
Since this PR is for the issue about performance, please perf and show the result of difference. |
Signed-off-by: harsh6921 <[email protected]>
Signed-off-by: harsh6921 <[email protected]>
|
hey @q82419 I've verified the performance gains using a benchmark of 10 million iterations. Before these changes, indirect calls were significantly slower, taking about 0.354 seconds due to the repeated structural type matching. With the new optimization enabled, the time for those same 10 million indirect calls dropped to just 0.083 seconds. For comparison, a direct call takes about 0.110 seconds in the same environment, so indirect calls are now effectively as fast as direct ones, successfully eliminating the overhead we were seeing. |
lib/executor/engine/proxy.cpp
Outdated
| if (FuncInst->getModule()) { | ||
| // Check if the function type matches the expected type with a two-step | ||
| // approach: | ||
| // 1. Fast path: If the function instance is in the same module instance, we |
There was a problem hiding this comment.
Move this comment to the if-statement.
| } else { | ||
| // Independent host module instance case. Matching the composite type | ||
| // directly. | ||
| IsMatch = AST::TypeMatcher::matchType( |
Signed-off-by: harsh6921 <[email protected]>
|
hey @q82419 i have adjusted the comments |
What does this PR do?
What are the changes?
Conclusion
Closing Issue