Skip to content

Сreate a tail call diagnoser - #573

Merged
adamsitnik merged 11 commits into
dotnet:masterfrom
0xGeorgii:сreate-a-tail-call-diagnoser
Dec 4, 2017

Hidden character warning

The head ref may contain hidden characters: "\u0441reate-a-tail-call-diagnoser"
Merged

adamsitnik merged 11 commits into
dotnet:masterfrom
0xGeorgii:сreate-a-tail-call-diagnoser

Conversation

@0xGeorgii

Copy link
Copy Markdown
Contributor

Added diagnoser for JIT Tail Call Events, based on JIT Inlining Events diagnoser.

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@GeorgePlotnikov you have done a great job. However, I am not sure if this enough to cover also F# case. As far as I know, C# compiler does not generate IL opcode for the tail call. But some JITs can do the tail call optimization. This is covered with your example.

However, when it comes to F#, the F# compiler emits the tail call optimization code or simply replaces the code with a simple jump in place(goto the beginning of the method).

Could you also make some research about F# edge cases and cover them? Please let me know if you are interested in doing this.

{

}
/// <summary>

This comment was marked as spam.

};
}

private bool ShouldPrintEventInfo(Tuple<string, string> namespaces) => !filterByNamespace || namespaces.Item1.StartsWith(expectedNamespace) || namespaces.Item2.StartsWith(expectedNamespace);

This comment was marked as spam.

}

[Benchmark]
public Diagnostics.Windows.TailCallDiagnoser TypeFromCustomDeoendency1()

This comment was marked as spam.

@0xGeorgii

Copy link
Copy Markdown
Contributor Author

@adamsitnik thank you very much for your comments, I'll take them into consideration to update the branch. Regarding the F# the case, I'm interested in it, no doubts. If you have some ideas where shall I start the research I would appreciate you a lot.

@adamsitnik

Copy link
Copy Markdown
Member

@GeorgePlotnikov this blog post gives a good introduction. However I don't have any link to a post which shows what decisions can be made by the F# compiler.

@dsyme maybe you could provide us some hints for start?

@dotnet dotnet deleted a comment from dnfclas Nov 1, 2017
@0xGeorgii

Copy link
Copy Markdown
Contributor Author

@adamsitnik added F# support and example to the F# sample project with various kinds of recursion calls.

}

/// <summary>
/// creates the new TailCallDiagnoser instace

This comment was marked as spam.

@AndreyAkinshin AndreyAkinshin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@GeorgePlotnikov, could you write an integration test for this diagnoser?

@0xGeorgii

Copy link
Copy Markdown
Contributor Author

@AndreyAkinshin seems @adamsitnik refused the previously written integration test, because of it was the same as for inline diagnoser, so it was removed by the second commit.

@AndreyAkinshin

Copy link
Copy Markdown
Member

@GeorgePlotnikov if I understand correctly, the original test just checked that we can do some basic diagnostics stuff. But we need a test which checks the diagnoser output (with lines like Caller, Callee, Tail prefix, Tail call type, and so on). It will help to verify that diagnoser is still working in case of any changes. Right now I have to check it manually before each release, but it will be better to make it automatic and increase the coverage.
The total test suite duration is still an issue, but we have to find another way to solve it.
@adamsitnik what do you think?

@0xGeorgii

Copy link
Copy Markdown
Contributor Author

@AndreyAkinshin you mean something like BenchmarkDotNet.IntegrationTests.MemoryDiagnoserTests? I think what you are talking about should look like that. Does it make sense?

@adamsitnik

Copy link
Copy Markdown
Member

you mean something like BenchmarkDotNet.IntegrationTests.MemoryDiagnoserTests?

yes, something similar. Run some benchmark, with the new diagnoser and check the output of the diagnoser (info about methods reported to the output).

refused the previously written integration test, because of it was the same as for inline diagnoser

your previous test was just checking if we can have a benchmark, which returns new diagnoser. It was not using the diagnoser. AnyValueCanBeReturned test verifies that we build the right code for all possible use cases of benchmarks (returning different types)

@0xGeorgii

Copy link
Copy Markdown
Contributor Author

@AndreyAkinshin , @adamsitnik thank you guys for the review. I'll add the test.

@0xGeorgii 0xGeorgii mentioned this pull request Nov 21, 2017
@0xGeorgii

Copy link
Copy Markdown
Contributor Author

@AndreyAkinshin, @adamsitnik hi guys, I've just added the integration test, please review

}

private IConfig CreateConfig(Jit jit, Platform platform, Runtime runtime, TailCallDiagnoser diagnoser) => ManualConfig.CreateEmpty()
.With(Job.ShortRun.With(jit).With(platform).With(runtime))

This comment was marked as spam.

This comment was marked as spam.

namespace BenchmarkDotNet.IntegrationTests
{
#if NET46
public class TailCallDiagnoserTests : BenchmarkTestExecutor

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@AndreyAkinshin

Copy link
Copy Markdown
Member

@GeorgePlotnikov, could you also add some information about this diagnoser in our documentation (the docs folder)? It would be nice to say a few words about what is it, when it can be useful, show a few benchmark examples (e.g. on C# and F#), and show an example of the diagnoser output.

@0xGeorgii

Copy link
Copy Markdown
Contributor Author

Applied the request review comments to the integration test and pulled the request to update the documentation

@adamsitnik
adamsitnik merged commit c1a4b20 into dotnet:master Dec 4, 2017
@AndreyAkinshin AndreyAkinshin added this to the v0.10.12 milestone Dec 4, 2017
@0xGeorgii
0xGeorgii deleted the сreate-a-tail-call-diagnoser branch December 4, 2017 22:15
alinasmirnova pushed a commit to alinasmirnova/BenchmarkDotNet that referenced this pull request Sep 22, 2018
* create a tail call diagnoser

* added newline at the end of file

* updated to support F#

* fix proj references

* rename local variables for unification

* fix typo

* added intergration test for the TailCallDiagnoser

* chaged directives regarding the project

* fixed warnings

* refactored

* applied the review comments
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.

5 participants