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

build: tracy integration #3253

Merged
merged 20 commits into from
Mar 30, 2024
Merged

build: tracy integration #3253

merged 20 commits into from
Mar 30, 2024

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Sep 24, 2023

Summary

SUMMARY: Build "CMake integration for tracy"

Purpose of change

tracy

add an easy way to sample and profile BN executable by using tracy

Describe the solution

  • updated cmakefiles to integrate tracy client.
  • copy-pasted no-op macros as most build methods lack tracy
  • documented how to enable tracy and use it to profile.

Describe alternatives you've considered

using other profilers, but they all seem to be either

  • slow (callgrind) and needs tweaking
  • closed source and not free
  • must have to alter source code to insert symbols

Additional context

  • write docs on how to build tracy frontend

@github-actions github-actions bot added the src changes related to source code. label Sep 24, 2023
@scarf005 scarf005 marked this pull request as ready for review September 27, 2023 01:26
@scarf005 scarf005 requested a review from olanti-p September 27, 2023 01:26
Copy link
Contributor

@olanti-p olanti-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to follow the instructions, and it didn't work

git clone https://github.com/wolfpld/tracy.git
cd tracy
make -j 10 -C profiler/build/unix LEGACY=1 release
<...> Some arcane errors related to freetype

After some digging through tracy docs, it turned out I needed to install additional libraries first, and freetype had nothing to do with the issue.

Now that it compiled, I run tracy executable, click "connect", run the game and... nothing happens? Or am i supposed to do something else?

Also, doesn't it need source code modifications to work, or is there some way to collect samples without it (maybe at the cost of precision)?

doc/src/content/docs/en/dev/guides/tracy.md Outdated Show resolved Hide resolved
doc/src/content/docs/en/dev/guides/tracy.md Outdated Show resolved Hide resolved
@scarf005 scarf005 marked this pull request as draft October 7, 2023 12:52
@github-actions github-actions bot added the docs PRs releated to docs page label Feb 14, 2024
@scarf005 scarf005 marked this pull request as ready for review March 29, 2024 10:07
@scarf005 scarf005 requested a review from olanti-p March 29, 2024 11:14
src/CMakeLists.txt Outdated Show resolved Hide resolved
src/CMakeLists.txt Show resolved Hide resolved
src/CMakeLists.txt Show resolved Hide resolved
tools/clang-tidy-plugin/CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated
FetchContent_Declare(
tracy
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
GIT_TAG master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a fixed release, e.g. https://github.com/wolfpld/tracy/releases/tag/v0.10

  1. According to their docs, it's best to use same version on both client and server, and you wouldn't want to recompile the server each time CMake re-fetches the dependencies
  2. There are no precompiled Windows binaries for master branch, and master is incompatible with latest 0.10 release

Copy link
Member Author

@scarf005 scarf005 Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's an issue in linux; release build on v0.10 tend to fail with weird LTO errors and debug build is very slow. while it can be patched it's not ergonomic.

lto-wrapper: warning: using serial compilation of 79 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
mold: error: undefined symbol: tracy::IsaList
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans9.ltrans.o:(tracy::SourceView::RenderAsmLine(tracy::SourceView::AsmLine&, tracy::SourceView::AddrStat const&, tracy::SourceView::AddrStatData const&, tracy::Worker&, unsigned long&, int, int, tracy::View&))
mold: error: undefined symbol: tracy::MicroArchitectureNum
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans16.ltrans.o:(tracy::View::DrawImpl())>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans16.ltrans.o:(tracy::View::DrawImpl())>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans8.ltrans.o:(tracy::SourceView::RenderSymbolAsmView(tracy::SourceView::AddrStatData const&, tracy::Worker&, tracy::View&))>>> referenced 1 more times

mold: error: undefined symbol: tracy::MicroArchitectureData
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans9.ltrans.o:(tracy::SourceView::RenderAsmLine(tracy::SourceView::AsmLine&, tracy::SourceView::AddrStat const&, tracy::SourceView::AddrStatData const&, tracy::Worker&, unsigned long&, int, int, tracy::View&))
mold: error: undefined symbol: tracy::PortList
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans9.ltrans.o:(tracy::SourceView::RenderAsmLine(tracy::SourceView::AsmLine&, tracy::SourceView::AddrStat const&, tracy::SourceView::AddrStatData const&, tracy::Worker&, unsigned long&, int, int, tracy::View&))
mold: error: undefined symbol: tracy::MicroArchitectureList
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans16.ltrans.o:(tracy::View::DrawImpl())>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans16.ltrans.o:(tracy::View::DrawImpl())>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans8.ltrans.o:(tracy::SourceView::RenderSymbolAsmView(tracy::SourceView::AddrStatData const&, tracy::Worker&, tracy::View&))>>> referenced 1 more times

mold: error: undefined symbol: tracy::OpsList
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans7.ltrans.o:(tracy::SourceView::SourceView())
mold: error: undefined symbol: tracy::OpDescList
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans9.ltrans.o:(tracy::SourceView::RenderAsmLine(tracy::SourceView::AsmLine&, tracy::SourceView::AddrStat const&, tracy::SourceView::AddrStatData const&, tracy::Worker&, unsigned long&, int, int, tracy::View&))
mold: error: undefined symbol: tracy::OpsNum
>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans7.ltrans.o:(tracy::SourceView::SourceView())>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans7.ltrans.o:(tracy::SourceView::SourceView())>>> referenced by <artificial>
>>>               /tmp/ccc7pN6R.ltrans7.ltrans.o:(tracy::SourceView::SourceView())
collect2: error: ld returned 1 exit status
make[1]: *** [../../../common/unix.mk:74: Tracy-release] 오류 1
make[1]: 디렉터리 '/home/scarf/opt/tracy/profiler/build/unix' 나감make: *** [Makefile:11: release] 오류 2
make: 디렉터리 '/home/scarf/opt/tracy/profiler/build/unix' 나감

also this error wolfpld/tracy#765 is only fixed in very recent master. maybe we should conditionally link against v0.10 for windows and recent master commit for linux?

Copy link
Member Author

@scarf005 scarf005 Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workaround applied in 97517da (#3253).

Copy link
Contributor

@olanti-p olanti-p Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof.

maybe we should conditionally link against v0.10 for windows and recent master commit for linux?

Yeah, sounds reasonable. Maybe note it in documentation somewhere, in case people would like to check out exact same version when they build tracy server from source on linux.

Copy link
Member Author

@scarf005 scarf005 Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated docs with relevant info in ac291f1 (#3253).

CMakeLists.txt Outdated Show resolved Hide resolved
scarf005 and others added 2 commits March 30, 2024 19:50
Co-authored-by: Olanti <olanti-p@yandex.ru>
Co-authored-by: Olanti <olanti-p@yandex.ru>
CMakeLists.txt Outdated Show resolved Hide resolved
@scarf005 scarf005 requested a review from olanti-p March 30, 2024 11:57
@scarf005 scarf005 merged commit d603949 into cataclysmbnteam:main Mar 30, 2024
13 checks passed
@scarf005 scarf005 deleted the tracy branch March 30, 2024 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PRs releated to docs page src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants