Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Investigate increased contract instrumentation costs #8611

Closed
athei opened this issue Apr 13, 2021 · 5 comments · Fixed by #8655
Closed

Investigate increased contract instrumentation costs #8611

athei opened this issue Apr 13, 2021 · 5 comments · Fixed by #8655
Labels
I3-bug The node fails to follow expected behavior. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Comments

@athei
Copy link
Member

athei commented Apr 13, 2021

The weight for contract instrumentation per byte increased by a factor of 20x. I am not sure why and when this happened.

This regression should be bisected and corrected.

@athei athei added I3-bug The node fails to follow expected behavior. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Apr 13, 2021
@athei
Copy link
Member Author

athei commented Apr 14, 2021

After some investigation I found out the following:

  • The regression only exists in the wasm runtime but not in the native runtime.
  • It was introduces by this PR.

This would suggest that the regression is somehow related to the initialization of the RuntimeLogger. However the pwasm-utils which do the instrumentation do not contain code to emit log messages. Also, building the benchmarks with disable-logging does not remove the regression.

I analyzed the PR but cannot find anything that could have causes this regression. Maybe @bkchr has an idea.

@bkchr
Copy link
Member

bkchr commented Apr 14, 2021

So reverting the commit fixes your problem?

@athei
Copy link
Member Author

athei commented Apr 14, 2021

I did a bisect and this was the first commit that had the regression.

@athei
Copy link
Member Author

athei commented Apr 16, 2021

I tracked down the culprit. The regression is gone when I remove the trace! statements in this file. Those are tight loops and it makes total sense to see such a slowdown when those are not compiled out.

Specifying disable-logging does not help. This feature does not activate log/release_max_level_off which could explain the problem. However, even if I add this to sp-io the regression is still there. It seems that the tracing code is not properly removed. Maybe the log feature is not properly propagated (maybe something with the new resolver).

@athei
Copy link
Member Author

athei commented Apr 19, 2021

The issue is being solved by deactivating logging when a runtime is being build for benchmarking (see linked PR).

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I3-bug The node fails to follow expected behavior. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Projects
Status: Done
2 participants