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

Simplify API by decreasing a number of entry points #957

Merged
merged 14 commits into from
Jan 2, 2025

Conversation

foxtran
Copy link
Contributor

@foxtran foxtran commented Dec 27, 2024

I have removed most of TRACY_HAS_CALLSTACK in C/C++ public headers with implementing related constexpr (if possible) checks in functions' implementations.

I have also set TRACY_CALLSTACK to zero if it is not set. It is set to zero, stack will not be collected. I hope compiler will be able to determine that corresponding branches are always false and remove related code.

Note: only C/C++ headers are updated. I did not touch other APIs which can be also reduced in the same way.

Fixes #954

@wolfpld
Copy link
Owner

wolfpld commented Dec 27, 2024

Can you show disassembly of the code that would use functions you have changed? I don't really want the if depth > 0 check to be present, if it's known at compile time it's not needed.

@foxtran
Copy link
Contributor Author

foxtran commented Dec 27, 2024

I do not know how to show it in a good way...

Anyway, there is a relatively simple example: https://godbolt.org/z/5h7jz5dzz

I have inserted exit(depth) calls into public/client/TracyScoped.hpp in two branches. As you can see, it will generate an extremely simple code that will only pass 0 or 5 (I set these depths) into exit call with -O3 optimization level. With -DCMAKE_BUILD_TYPE=Debug, TRACY_CALLSTACK=0 will get a cost but starting from -O1 it will work with a simple asm :)

@foxtran foxtran changed the title DRAFT: Simplify API by decreasing entry points Simplify API by decreasing a number of entry points Dec 27, 2024
@foxtran foxtran force-pushed the feature/merge-calls-callstack branch from 7e9aa97 to 31eeb84 Compare January 2, 2025 10:27
@wolfpld wolfpld merged commit 8b0b234 into wolfpld:master Jan 2, 2025
6 checks passed
@foxtran foxtran deleted the feature/merge-calls-callstack branch January 2, 2025 11:51
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.

Simplify API by merging callstack / no callstack functions
2 participants