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

bump tracy to wolfpld/tracy@5479a42 #19801

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dezhiAmd
Copy link

@dezhiAmd dezhiAmd commented Jan 24, 2025

  1. Affter bump tracy to wolfpld/tracy@5479a42, the trace captured must be opened by the profiler built from iree\third_party\tracy

Here is the instructions on how to build it on windows:

  • Copy python.exe to python3.exe (they should be in the same folder like c:\python312)
    
  • Go to iree\\third_party\\tracy, run below two commands
    
      cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release
      cmake --build profiler/build --parallel --config Release
    

After that your profiler version is 0.11.2

  1. Tracy-csvexport can export gpu-zones to csv file
  • Go to iree\\third_party\\tracy, run below two commands
    
      cmake -B csvexport/build -S profiler -DCMAKE_BUILD_TYPE=Release
      cmake --build csvexport/build --parallel --config Release
    

After that run tracy-csvexport like:
tracy-csvexport -g test.tracy > test.csv

@dezhiAmd dezhiAmd marked this pull request as ready for review January 24, 2025 00:31
Copy link
Member

Choose a reason for hiding this comment

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

Clarifying the PR title:

v0.11.1 would be https://github.com/wolfpld/tracy/releases/tag/v0.11.1 (wolfpld/tracy@5d542dc)

This is changing the commit to wolfpld/tracy@5479a42, which is the latest on main and has not yet been bundled into a stable release. See the rolling patch notes: https://github.com/wolfpld/tracy/blob/5479a42ef9346b64e6d1b860ae58aa8abdb0c7f6/NEWS#L5-L56

Updating to a commit that is not yet part of a stable release is okay, but please note that in the PR text. It would also be good to call out if this unreleased version is binary-compatible with v0.11.1, or else our developers would need to build from source vs being able to download prebuilt binaries on Windows from https://github.com/wolfpld/tracy/releases/tag/v0.11.1.

Copy link
Member

Choose a reason for hiding this comment

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

Also note that our developers can still build the standalone Tracy tools (profiler GUI, csv export tool, etc.) from the original Tracy source, without us needing to update the submodule version here, unless there has been a breaking change to the client/server protocol. Staying current and giving easy access to the code via the submodule is nice though.

Copy link
Author

Choose a reason for hiding this comment

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

Indeed, there is a breaking change to the client/server protocol. That is what I see when using profiler (v0.11.1) to capture current IREE trace

Copy link
Member

@ScottTodd ScottTodd Jan 24, 2025

Choose a reason for hiding this comment

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

Looks like some changes will be needed on our end for this: https://github.com/iree-org/iree/actions/runs/12940755493/job/36095982640?pr=19801#step:9:1832

  [396/571] Building CXX object runtime/src/iree/hal/drivers/vulkan/CMakeFiles/iree_hal_drivers_vulkan_dynamic_symbols.objects.dir/dynamic_symbols.cc.o
  [397/571] Building CXX object tracy/CMakeFiles/IREETracyServer.dir/__/__/__/third_party/tracy/server/TracyTextureCompression.cpp.o
  FAILED: tracy/CMakeFiles/IREETracyServer.dir/__/__/__/third_party/tracy/server/TracyTextureCompression.cpp.o
  ccache /usr/bin/clang++  -I/home/runner/_work/iree/iree/build_tools/third_party/tracy/../../../third_party/tracy/imgui -I/usr/include/capstone -I/usr/include/capstone/capstone -O3 -DNDEBUG -std=gnu++17 -fPIC -Wno-unused-result -MD -MT tracy/CMakeFiles/IREETracyServer.dir/__/__/__/third_party/tracy/server/TracyTextureCompression.cpp.o -MF tracy/CMakeFiles/IREETracyServer.dir/__/__/__/third_party/tracy/server/TracyTextureCompression.cpp.o.d -o tracy/CMakeFiles/IREETracyServer.dir/__/__/__/third_party/tracy/server/TracyTextureCompression.cpp.o -c /home/runner/_work/iree/iree/third_party/tracy/server/TracyTextureCompression.cpp
  In file included from /home/runner/_work/iree/iree/third_party/tracy/server/TracyTextureCompression.cpp:3:
  In file included from /home/runner/_work/iree/iree/third_party/tracy/server/TracyEvent.hpp:12:
  In file included from /home/runner/_work/iree/iree/third_party/tracy/server/TracySortedVector.hpp:4:
  /home/runner/_work/iree/iree/third_party/tracy/server/TracySort.hpp:7:12: fatal error: 'ppqsort.h' file not found
      7 | #  include <ppqsort.h>
        |            ^~~~~~~~~~~

Maybe in https://github.com/iree-org/iree/blob/main/build_tools/third_party/tracy/CMakeLists.txt ?

See also the release note callout for

  • Parallel sorting is now performed with PPQSort (which removes potential
    dependency on TBB).

Hopefully we don't need to install that on our build systems. If so, we could swap TBB for PPQ?

Copy link
Member

Choose a reason for hiding this comment

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

I'd look around here:

Looks like a source dependency on https://github.com/GabTux/PPQSort. Maybe we'd want to FetchContent that (or use a submodule like we already do for Tracy).

Copy link
Author

@dezhiAmd dezhiAmd Jan 24, 2025

Choose a reason for hiding this comment

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

I am looking for how CMake files in tracy automatically downloaded all dependencies into folders like this:
C:\develop\tracy_src\profiler\build\.cpm-cache\capstone\c68db851083fcffa27a786090cedcce4c4f28330\include\capstone;
C:\develop\tracy_src\profiler\build\.cpm-cache\capstone\c68db851083fcffa27a786090cedcce4c4f28330\include;
C:\develop\tracy_src\profiler\build\.cpm-cache\ppqsort\b30541008a1455585354665a90f3f90ebc8d637e\include;
C:\develop\tracy_src\profiler\build\_deps\ppqsort-build\PackageProjectInclude;
C:\develop\tracy_src\profiler\build\.cpm-cache\imgui\64e6627cd30cedd5fb11399ce199c6bc4c3cecaf;
C:\develop\tracy_src\profiler\build\_deps\freetype-build\include;
C:\develop\tracy_src\profiler\build\.cpm-cache\freetype\e30ced2c97047bd2dfa8aa235a47683755a48043\include;
C:\develop\tracy_src\profiler\build\.cpm-cache\glfw\9fc60ad2c810b92f74235a589a9a0edee75bc2d3\include;

Copy link
Member

Choose a reason for hiding this comment

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

See the files I linked. We maintain our own CMake file for the Tracy server since depending on Tracy's CMake project would bring extra baggage along (more history there on #17488). I suspect that using FetchContent for PPQSort would make sense. We have a few examples in the repo of how that can be done.

It sounds like we can also drop TBB from our dockerfiles and docs (https://iree.dev/developers/performance/profiling-with-tracy/#linux) thanks to wolfpld/tracy@1c1faef, once this lands.

Copy link
Author

Choose a reason for hiding this comment

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

A change is applied to build_tools/third_party/tracy/CMakeLists.txt.
Much appreciated the help. And you are correct, we do not need TBB anymore.
A follow up PR might be needed to update the document and the submodules.

@dezhiAmd dezhiAmd changed the title bump tracy to 0.11.1 bump tracy to wolfpld/tracy@5479a42 Jan 24, 2025
@dezhiAmd dezhiAmd requested a review from ScottTodd January 26, 2025 19:41
Comment on lines +25 to +27
include(${TRACY_SOURCE_DIR}/cmake/config.cmake)
include(${TRACY_SOURCE_DIR}/cmake/vendor.cmake)
include(${TRACY_SOURCE_DIR}/cmake/server.cmake)
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you entirely rewrote this file to be a fork of the upstream CMake file at https://github.com/wolfpld/tracy/blob/master/capture/CMakeLists.txt. When I looked at these files while working on #17488, I decided against such an inclusion because of files like https://github.com/wolfpld/tracy/blob/master/cmake/config.cmake and https://github.com/wolfpld/tracy/blob/master/cmake/vendor.cmake setting CMake settings and downloading packages that could affect the rest of the project. These might be scoped to the current directory and below, but introducing that complexity/risk didn't seem worth it to me.

There are now at least two things this PR is doing:

  1. Reworking the CMake file to copy upstream
  2. Updating the commit/version used

I'd focus on just one of those at a time.

For the build reworking, we could make another attempt to directly use the upstream CMake files without forking then further change how IREE_BUILD_TRACY is used and how we bundle the capture server into releases with code here:

option(IREE_BUILD_TRACY "Enables building the 'iree-tracy-capture' CLI tool and includes it in runtime Python bindings." OFF)

iree/CMakeLists.txt

Lines 973 to 981 in 9a34131

if(IREE_BUILD_TRACY)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux")
message(WARNING "Building Tracy (IREE_BUILD_TRACY) on non-Darwin/Linux is unsupported and may fail below.")
endif()
add_subdirectory(build_tools/third_party/tracy ${CMAKE_CURRENT_BINARY_DIR}/tracy)
if(NOT TARGET IREETracyCaptureServer)
message(SEND_ERROR "Could not build Tracy. Either unset IREE_BUILD_TRACY or look for missing dependencies above and install them.")
endif()
endif()
if(IREE_BUILD_TRACY)
message(STATUS "Bundling Tracy CLI tools with Python API")
set(_TRACY_ENABLED ON)
list(APPEND _EXTRA_INSTALL_TOOL_TARGETS "IREETracyCaptureServer")
endif()

iree/runtime/setup.py

Lines 436 to 437 in 9a34131

if ENABLE_TRACY_TOOLS:
cmake_args.append("-DIREE_BUILD_TRACY=ON")

iree/runtime/setup.py

Lines 84 to 86 in 9a34131

ENABLE_TRACY_TOOLS = getenv_bool(
"IREE_RUNTIME_BUILD_TRACY_TOOLS", "@IREE_RUNTIME_BUILD_TRACY_TOOLS@"
)
export IREE_RUNTIME_BUILD_TRACY_TOOLS=ON

We could also stop distributing iree-tracy-capture and always point users to the upstream instructions. I'm not sure how much use we're getting out of our own packaging of the tool. Or, if we want to keep distributing it but not carry all that build system plumbing code, we could have that setup.py file run a standalone cmake build for Tracy and then copy the output file over.

There are a few directions we could go, and I don't have a clear preference right now. If you can keep this update PR incremental (without changing the entire CMake setup), that would be much easier for now.

# Server library
#-------------------------------------------------------------------------------
include(${TRACY_SOURCE_DIR}/cmake/config.cmake)
include(${TRACY_SOURCE_DIR}/cmake/vendor.cmake)
Copy link
Member

Choose a reason for hiding this comment

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

To troubleshoot errors like https://github.com/iree-org/iree/actions/runs/12968320277/job/36176956225?pr=19801#step:9:1526,

Copy link
Collaborator

@benvanik benvanik left a comment

Choose a reason for hiding this comment

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

We should drop the cmake changes here - bumping tracy should be independent from rewriting our build. We're losing functionality with these changes and not gaining much: if a user wants to do an upstream build then they shouldn't be using our cmake so matching the upstream cmake does not provide value in and of itself.

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.

3 participants