platoneko opened a new issue, #11698: URL: https://github.com/apache/doris/issues/11698
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and found no similar issues. ### Description The current `Status` implementation is to save all data to a fixed size (2KB) array on stack. This will lead to too large function stack space and may not be friendly to data locality (unnecessary page faults, TLB utilization, cacheline prefetching, etc.). Another problem is when RVO(return value optimization) fails (there are many if-else branches in current codes, and the compiler may often be unable to do RVO), the move ctor cannot be used, causing the error message in `Status` to be copied layer by layer in the function call stack. Doris moving the `Status` data from heap to stack can be traced back to https://github.com/apache/doris/pull/8117. This PR is designed to avoid dynamic memory allocation. However, in practice, we often construct error messages through `fmt::format`(see `Status::ErrorFmt`), so we cannot avoid dynamic memory allocation in fact. If we separate the status code and err msg in `Status`: 1. The error msg constructed by `fmt::format` can be directly moved to `Status`. 2. When RVO fails, the compiler will use move ctor to pass Status to function caller to reduce the copy cost. ### Solution _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org