codealike / arrayslice Goto Github PK
View Code? Open in Web Editor NEWArraySlice allows to build shared memory array views without performance impact. It uses IL manipulation to achieve the fastest implementation.
License: MIT License
ArraySlice allows to build shared memory array views without performance impact. It uses IL manipulation to achieve the fastest implementation.
License: MIT License
The implementation of unsafe optimization implies accessing fields on first use, create the local variables and let the optimization method to do its work.
Allowing the use of fields while unsafe in the general case (because of multithreading) should be allowed via the use of an attribute.
Currently the uses inside lambda expressions is a big unknown. It should work but we should do a throughly testing phase on those.
Running PEverify on the output of this https://github.com/Fody/FodyAddinSamples/tree/master/ArraySlicesSample
Results in
Error 4 Fody: PEVerify of the assembly failed.
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
[IL]: Error: [C:\Code\Fody\FodyAddinSamples\ArraySlicesSample\bin\Debug\ArraySlicesSample.dll : AsyncErrorHandlerSample::Run][offset 0x0000005A] Unable to resolve token.
1 Error(s) Verifying C:\Code\Fody\FodyAddinSamples\ArraySlicesSample\bin\Debug\ArraySlicesSample.dll
ArraySlicesSample
Control via class, method, indexer attribute if the corresponding code should be optimized.
public enum OptimizationMode
{
None,
Safe,
Unsafe
}
Sometimes optimization will introduce more instructions (preparation phase) than the ones than the times accessors are used, therefore penalizing on performance.
Examples like:
ArraySlice should be able to find that out, and do not optimize the method is there is no net win in performance.
Currently ArraySliceBehaviorAttribute is supported only at the method level. It would be interesting to extend it to handle extended scopes like Assembly and Class.
Class will override Assembly
Method will override Class and Assembly.
When we have:
public readonly ArraySlice Field;
We can be sure that noone will modify it therefore it is safe to optimize its use.
This optimization will allow to optimize for the case where offsets start at 0 and therefore it wont be necesarry to add the offset to the stack.
The proper way to handle this is duplicating the method code and have 2 MSIL paths. One that will handle the (Offset == 0) condition and another one that will handle the (Offset != 0) condition. The concept itself is more or less the same used at optimizing compilers to handle Loop Unrolling.
Fody Version 2 is out and you will need to do an update for your addin to be usable with it
Specifically:
Please ping me if u need help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.