Giter Site home page Giter Site logo

whiteblackgoose / codegenanalysis Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 0.0 258 KB

Library for obtaining and analyzing the codegen of JIT for .NET. Can be used for both tests (assertions) and making reports (benchmarks).

License: MIT License

C# 100.00%
codegen dotnet jit performance performance-analysis

codegenanalysis's Introduction

codegenanalysis's People

Contributors

whiteblackgoose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

codegenanalysis's Issues

Support chained fowarding via `CASubject`

A method with CAAnalyze that forwards disassembling to another via CASubject will only reach the first forwarded method. If that target method contains another CASubject, it will be ignored. In other words, recursive method forwarding is not supported.

RunAsBDN

To use [Benchmark] and [GlobalSetup] things by name

CodegenAnalyzers

CodegenAnalyzers.GetBranches(CodegenInfo ci) -> IEnumerable<int>
CodegenAnalyzers.GetCalls(CodegenInfo ci) -> IEnumerable<int>
CodegenAnalyzers.GetLoops(CodegenInfo ci) -> IEnumerable<(int Start, int End)>
CodegenAnalyzers.GetStaticallyAllocatedStackMemory(CodegenInfo ci) -> int?

`CASubjectAttribute`

To allow investigating inner methods, e. g.

[CAAnalyze(5)]
[CASubject("CallA")]
public void SomeMethod(int a)
{
    CallA(CallB(a));
}

The full arguments are

string methodName, Type[] typeArgs, Type[] parameterTypes

Where methodName is

  1. Method
  2. SomeType.Method
  3. SomeNamespace.SomeType.Method

Highlight problematic lines

E. g. for CodegenDoesNotHaveBranches it could look like this:

  27382   mov rax, rdx
> 27385   test rax, rax
  27387   jz 27382
  29233   call aaaa
> 23928   cmp rdx, rax
  20393   jg 29033

Three libs?

Codegen

That one is just the core. It has the CodegenInfo object, and everything to get it.

var ci =  CodegenInfoResolver.GetCodegen(() => Add(4, 5));
Console.WriteLine(ci);

Codegen.Assertions

That one is a test suite: it has multiple assertions to verify the behaviour of JIT.

AssertCodegen.BranchesLessThan(5, () => Add(3, 5));

Codegen.Benchmarks

This one will build a report based on a codegen.

CodegenBenchmarkRunner.Run<Bench>();

class Bench
{
    [Benchmark]
    [Input(3, 5)]
    public void Add(int a, int b) => a + b;

    [Benchmark]
    [Input(3, 5, 6)]
    public void Add(int a, int b, int c) => a + b + c;
}

Output:

Method Code size Branches Calls Stack allocated memory Backward jumps (loops)
SomeMethod 43 B 3 - - 2
OtherMethod 164 B 7 11 164 B -

(and prints the codegen)

AutoBest tier

Instead of hard-coded one, this one will detect the runtime version and adjust the tier to the best (with TC it will be tier1, otherwise default)

NRE

Line 125 in benchmark runner. Should produce something...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.