Skip to content

Conversation

@vittorioromeo
Copy link
Contributor

Addresses #93. Could be improved in the future, but it's already quite useful. Example output:

**** Templates that took longest to instantiate:
   602 ms: std::vformat_to<std::__format::_Sink_iter<char>> (5 times, avg 120 ms)
       1 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/__/Base/StackTrace.cpp.obj
       1 time(s): .//_deps/cpptrace-build/CMakeFiles/cpptrace-lib.dir/Unity/unity_0_cxx.cxx.obj
       1 time(s): .//test/CMakeFiles/test-sfml-system.dir/System/Time.test.cpp.obj
       1 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.obj
       1 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/__/Base/ThreadPool.cpp.obj
   601 ms: std::__format::__do_vformat_to<std::__format::_Sink_iter<char>, char... (5 times, avg 120 ms)
       1 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/__/Base/StackTrace.cpp.obj
       1 time(s): .//_deps/cpptrace-build/CMakeFiles/cpptrace-lib.dir/Unity/unity_0_cxx.cxx.obj
       1 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/__/Base/ThreadPool.cpp.obj
       1 time(s): .//test/CMakeFiles/test-sfml-system.dir/System/Time.test.cpp.obj
       1 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.obj
**** Template sets that took longest to instantiate:
   717 ms: std::formatter<$>::format<$> (117 times, avg 6 ms)
      23 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/__/Base/StackTrace.cpp.obj
      23 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/__/Base/ThreadPool.cpp.obj
      24 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.obj
      24 time(s): .//test/CMakeFiles/test-sfml-system.dir/System/Time.test.cpp.obj
      23 time(s): .//_deps/cpptrace-build/CMakeFiles/cpptrace-lib.dir/Unity/unity_0_cxx.cxx.obj
   676 ms: std::common_reference<$> (881 times, avg 0 ms)
       1 time(s): .//test/CMakeFiles/test-sfml-audio.dir/Audio/SoundBuffer.test.cpp.obj
       3 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/FileUtils.cpp.obj
       1 time(s): .//test/CMakeFiles/test-sfml-audio.dir/Audio/InputSoundFile.test.cpp.obj
       6 time(s): .//src/SFML/Network/CMakeFiles/sfml-network.dir/Http.cpp.obj
       7 time(s): .//test/CMakeFiles/test-sfml-network.dir/Network/Packet.test.cpp.obj
       6 time(s): .//test/CMakeFiles/test-sfml-graphics.dir/Graphics/Transform.test.cpp.obj
      17 time(s): .//src/SFML/Window/CMakeFiles/sfml-window.dir/SDLLayer.cpp.obj
      30 time(s): .//src/SFML/System/CMakeFiles/sfml-system.dir/Clock.cpp.obj

This PR needs work, but I'd like to get some feedback first on how to proceed. It's mostly a hack at this point.

Copy link
Contributor Author

@vittorioromeo vittorioromeo left a comment

Choose a reason for hiding this comment

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

Some questions for @aras-p

src/Analysis.cpp Outdated
// Clang Build Analyzer https://github.com/aras-p/ClangBuildAnalyzer
// SPDX-License-Identifier: Unlicense

#include <iostream>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be removed, was just for testing.

Comment on lines +91 to +92
DetailIndex file;
std::unordered_map<int, int> templateCount;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like this approach, but I need guidance on where these things should go.

Comment on lines +231 to +238
if (ev.filenameDetailIndex.idx != 0)
{
assert(ev.filenameDetailIndex.idx >= 0);
assert(ev.filenameDetailIndex.idx < static_cast<int>(nameToIndex.size()));
ev.filenameDetailIndex = detailRemap[ev.filenameDetailIndex];
assert(ev.filenameDetailIndex.idx >= 0);
assert(ev.filenameDetailIndex.idx < static_cast<int>(resultNameToIndex.size()));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a way we can avoid adding the extra field?

Comment on lines +459 to +461
// use the current json file name for the "instantiateX" event filename detail
if (event.type == BuildEventType::kInstantiateClass || event.type == BuildEventType::kInstantiateFunction)
filenameDetailPtr = curFileName;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we get more precise information other than the event filename, somehow?

@leekillough
Copy link

leekillough commented May 30, 2025

FYI, for curiosity, I tried this, but I am getting data corruption causing an infinite loop.

src/BuildEvents.cpp

701             r.Read(childCount);
702             e.children.resize(childCount);

(gdb) p childCount
$7 = 21474836480

The attached capture file was used as input. It works on main, but hangs after data corruption on this branch.

My executable used to capture was out of sync with my executable used for analysis.

@vittorioromeo
Copy link
Contributor Author

@aras-p: any interest in getting this PR improved and merged?

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.

2 participants