Giter VIP home page Giter VIP logo

tune's Introduction

Build Status

Tune

The Ultimate .NET Experiment

Example Tune screenshot

The Ultimate .NET Experiment (Tune) as its purpose is to learn .NET internals and performance tuning by experiments with C# code. The main way of working with this tool is as follows:

  • write a sample, valid C# script which contains at least one class with public method taking a single string parameter. It will be executed by hitting Run button. This script can contain as many additional methods and classes as you wish. Just remember that first public method from the first public class will be executed (with single parameter taken from the input box below the script). You may also choose whether you want to build in Debug or Release mode (note: currently it is only x64 bit compilation). There are three predefined examples under File menu.
  • after clicking Run button, the script will be compiled and executed. Additionally, it will be decompiled both to IL (Intermediate Language) and assembly code in the corresponding tabs.
  • all the time Tune is running (including time during script execution) a graph with GC data is being drawn. It shows information about generation sizes and GC occurrences (illustrated as vertical lines with the number below indicating which generation has been triggered).

Note: As it is currently in very early 0.3 version, it can be treated as Proof Of Concept with many, many features still missing. But it is usable enough to have some fun with it already.

Overall architecture

Tune is built from a few very interesting pieces, which will be probably much more clearer to show on the following diagram than to describe in words:

Tune architecture

As you can see, it is using parts of SharpDevelop (ICSharpCode) and Mono.Cecil libraries to decompile IL. To decompile into ASM it is using ClrMd to find method address location in the memory and then use SharpDisasm (which is a libudis86 C library port). It additionally uses dbghelp.dll to resolve native symbols. ETW data are being processed by the TraceEvent library.

Building

Requirements:

  • Visual Studio 2017

Additional info and examples:

tune's People

Contributors

azure-pipelines[bot] avatar kkokosa avatar pawlos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tune's Issues

Error in DiagnosticAssembly.Execute(string argument)

I try execute sample code from Open file and I get error:

Merge operation failed return code 0x2

Script execution failed: System.ApplicationException: Merge operation failed return code 0x2
w Microsoft.Diagnostics.Tracing.Session.TraceEventSession.Merge(String[] inputETLFileNames, String outputETLFileName, TraceEventMergeOptions options)
w Microsoft.Diagnostics.Tracing.Session.TraceEventSession.MergeInPlace(String etlFileName, TextWriter log)
w Tune.Core.Collectors.ClrEtwCollector.Stop() w C:\TestAndOtherStuff\TUNE\Tune.Core\Collectors\ClrEtwCollector.cs:wiersz 62
w Tune.Core.Collectors.ClrEtwCollector.Dispose() w C:\TestAndOtherStuff\TUNE\Tune.Core\Collectors\ClrEtwCollector.cs:wiersz 159
w Tune.Core.DiagnosticAssembly.Execute(String argument) w C:\TestAndOtherStuff\TUNE\Tune.Core\DiagnosticAssembly.cs:wiersz 75

Integrate with AppVeyor

Integrate CI/CD pipeline with AppVeyor to create releases automatically. It requires #2 issue resolving to not depend on any commercial libraries.

TypeLoadException when try run test example

I've donwloaded realese version of app from https://1drv.ms/u/s!ApZOZuEUCC2DjZhc0vmj9P-6JCmqOQ. When I tried to execute sample code and I get the error:

Message:
Method 'get_ReferenceDirectiveMap' in type 'Microsoft.CodeAnalysis.CSharp.CSharpCompilation' from assembly 'Microsoft.CodeAnalysis.CSharp, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

StackTrace:
at Tune.Core.DiagnosticEngine.Compile(String script, DiagnosticAssemblyMode mode, DiagnosticAssembyPlatform platform)
at Tune.UI.MainView.RunAsync(Object parameters) in C:\Projects\Tune\Tune.UI\MainView.cs:line 224
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

Making memory snapshots

Making possible to take memory snapshots during script run and/or invoke it explicitly from the script by any kind of Script.DumpMemory() method.

Remove Debugging Tools for Windows dependency on build

As Tune requires symsrv.dll and dbghelp.dll files from Debugging Tools for Windows, building it requires them to be installed (and xcopies them as a post-build event currently). This is both inconvenient for developers wanting to contribute (or just build and look around) and for continuous integration possibilities (and in fact stops issue #20).

The solution would to be include those two files. Unfortunately, this will require maintaining it now (by taking care of updating to newer version), but I do not see better workaround.

Check if current process is elevated

By using TraceEventSession.IsElevated() check whether current process has rights to configure and use ETW sessions. Warning should be provided to the user if it is not.

Reorganize solution

Solution should be layered into UI, core engine and other auxiliary projects.

Switch platform of build cause error

When I try handle bug from #12 I find another bug. When I switch from x64 to x86 I get:
System.BadImageFormatException: Nie można załadować pliku lub zestawu „assemblyName_636456428965025197, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”. Ten zestaw został skompilowany dla innego procesora.
w System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
w System.Reflection.Assembly.Load(Byte[] rawAssembly)
w Tune.Core.DiagnosticAssembly..ctor(DiagnosticEngine engine, String assemblyName, CSharpCompilation compilation) w C:\TestAndOtherStuff\TUNE\Tune.Core\DiagnosticAssembly.cs:wiersz 47
w Tune.Core.DiagnosticEngine.Compile(String script, DiagnosticAssemblyMode mode, DiagnosticAssembyPlatform platform) w C:\TestAndOtherStuff\TUNE\Tune.Core\DiagnosticEngine.cs:wiersz 46
w Tune.UI.MVVM.ViewModels.MainViewModel.d__96.MoveNext() w C:j\TestAndOtherStuff\TUNE\Tune.UI.ViewModels\ViewModels\MainViewModel.cs:wiersz 281

Somewhere AssemblyPlatform is not get properly?

Cannot use System.Linq

When I'm trying test code that depend on System.Linq I'm getting error:

[02:16:29.522] Running started.
[02:16:29.800] Script parsed.
[02:16:29.853] Script compilation into assembly assemblyName_636777153898003530.
[02:16:31.283] Script compilation failed: (3,14): error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
(21,20): error CS0103: The name 'Enumerable' does not exist in the current context
(31,31): error CS1061: 'List<Test>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'List<Test>' could be found (are you missing a using directive or an assembly reference?)
(37,31): error CS1061: 'List<Test>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'List<Test>' could be found (are you missing a using directive or an assembly reference?).
[02:16:31.291] System.NullReferenceException: Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.
   w Tune.Core.DiagnosticAssembly.Execute(String argument) w D:\a\1\s\src\Tune.Core\DiagnosticAssembly.cs:wiersz 54
   w Tune.UI.MVVM.ViewModels.MainViewModel.<RunAsync>d__96.MoveNext() w D:\a\1\s\src\Tune.UI.ViewModels\ViewModels\MainViewModel.cs:wiersz 285
[02:16:31.295] Running ended with success False

Crash at startup

@kkokosa Konrad, I posted a comment here, but since there is no response within two days I opened an issue.

Tune 0.2 from your OneDrive is crashing at startup with the following error:

System.UnauthorizedAccessException
in Microsoft.Diagnostics.Tracing.Session.TraceEventSession.InsureStarted(EVENT_TRACE_PROPERTIES*)
in Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableProvider(System.Guid, Microsoft.Diagnostics.Tracing.TraceEventLevel, UInt64, Microsoft.Diagnostics.Tracing.Session.TraceEventProviderOptions)
in Tune.UI.MainView.ThreadCallback(System.Object)
in System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
in System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
in System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
in System.Threading.ThreadPoolWorkQueue.Dispatch()

I'm under Windows 10 (x64).

I would like to use this tool for my .NET experiments since I can't find a good alternative to it. 😅

Management of script references

Currently, script references only mscorlib while it would be very nice to have possibly to reference any additional assembly.

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.