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

[Logging] Bring back the stack size optimization #7756

Merged
merged 3 commits into from
Mar 28, 2021
Merged

[Logging] Bring back the stack size optimization #7756

merged 3 commits into from
Mar 28, 2021

Conversation

junrushao
Copy link
Member

This PR brings back the stack size optimization:

It also brings back the error message showing those numbers used in comparison "(1 vs 2)" when CHECK_XX fails.

Some tricks:

  • Make the transient object LogFatal an empty class, storing data on TLS so that it doesn't occupy stack space
  • Forcefully disallow inlining on some functions that could potentially use stack space
  • Replace the (slightly more) heavy-weighted "std::string" with "const char *" in the constructor of LogFatal

I tested the stack size in the following setting:

  • Compiler: GCC 5.5
  • OS: Ubuntu 18.04
  • Function: tvm::relay::AutoSchedulerLayoutRewriter::VisitExpr_(const tvm::relay::CallNode*)
  • CXX Flag: "-fstack-usage -g"

The stack usage drops from 1392 to 496 with the aforementioned tricks.

CC @comaniac @tkonolige @tqchen. Please let me know if it solves #7729. Thanks in advance!

@tqchen tqchen merged commit 18fa495 into apache:main Mar 28, 2021
@tqchen
Copy link
Member

tqchen commented Mar 28, 2021

Thanks @junrushao1994 !

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

Successfully merging this pull request may close these issues.

[Bug] Line backtrace results in stack overflow
2 participants