Skip to content

Conversation

@mihaisebea
Copy link

Unfortunately is not easy to create a simple reproducible case.
It seems that SpecializationID is 0.
I will try to look more into this.

@MetanoKid MetanoKid added bug Something isn't working enhancement New feature or request external library Related to a external library labels Sep 4, 2020
@MetanoKid
Copy link
Owner

Hi Mihai, thank you for another fix!

I guess the PR can be approved, but I'd like to have some more info on the issue before merging it.
Can you please answer these questions?

  • When you collected the trace, which MSVC version was the project compiled with?
  • Can you check whether those Unknown templates timeElapsed under the default time to be ignored in the BuildTimeline.json report? I think it's 10ms right now. If it is, it means we'd have this same issue in the timeline report if we passed the timeline_ignore_templates_under argument and it might mean it's a bug in the compiler. Otherwise that'd be an issue in this report.

Thanks 👍

@MetanoKid MetanoKid added this to the v1.0.1 milestone Sep 4, 2020
@mihaisebea
Copy link
Author

mihaisebea commented Sep 6, 2020

Hi @MetanoKid
I used Visual Studio 2019 16.7.2
Seems the default is indeed 10ms but I have templates that take well over 500ms.

As far as i'm debugging this, in this function:

void TemplateInstantiationsAnalyzer::OnTemplateInstantiation(const CppBI::Activities::TemplateInstantiation& templateInstantiation)
{

there are plenty instantiations that have PrimaryTemplateSymbolKey and SpecializationSymbolKey 0 (zero)
And this is what the event looks like.
image

Copy link
Owner

@MetanoKid MetanoKid left a comment

Choose a reason for hiding this comment

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

Hi Mihai!

I'm afraid GitHub doesn't notify when a comment gets updated and I didn't come back to you sooner. I really apologize.

In the meantime, I tried compiling Unreal Engine from source (because it's a huge project with a lot of templates) in Visual Studio 16.5.2 and 16.7.3, but I wasn't able to reproduce the issue you mention.
However, I tried forcing it by stopping vcperf in the middle of a compilation instead of waiting for it to finish, and that helped me reproduce it.

Long story short, TemplateInstantiation activities are recorded as templates get compiled, but they contain an identifier for that template (PrimaryTemplateSymbolKey and SpecializationSymbolKey, as reported by the SDK) and not its string representation. To get that info, we must wait for SymbolName events to happen.

Indeed, if these SymbolName events don't get emitted, we'll have these entries in the timeline report, which is what I expected when I asked you about it:
image

Because the SDK didn't emit the expected SymbolName events, we can't really know which template they refer to.
With that in mind, please check my suggestion in the inline comment and tell me what you think about it.

Thank you for your time and interest once again 🙂

Comment on lines 48 to +57
auto itSpecializationTemplateName = m_symbolNames.find(pair.second.Specialization);
assert(itSpecializationTemplateName != m_symbolNames.end());

if (itSpecializationTemplateName != m_symbolNames.end())
{
templateName = itSpecializationTemplateName->second;
}
else
{
templateName = "Unknown";
}
Copy link
Owner

Choose a reason for hiding this comment

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

How about not registering the Unknown template name at all and switching to this?

auto itSpecializationTemplateName = m_symbolNames.find(pair.second.Specialization);
if (itSpecializationTemplateName == m_symbolNames.end())
{
    // a TemplateInstantiation activity has been recorded but its related SymbolName hasn't been emitted
    // we can't know which template it refers to, so we can only skip it
    continue;
}

After all, it won't be correctly registered in the BuildTimeline.json report either.
And this way users won't have an entry listed Unknown with the accumulated time of (probably) unrelated templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request external library Related to a external library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants