Giter Club home page Giter Club logo

bogusdependencies's Introduction

BogusDependencies provides common code for analyzing C# compiler and MSVC C++ linker outputs to determine which inputs are not actually necessary to building the final output. These bogus dependencies can then be surfaced in tooling to feed back to developers to help reduce package and project-to-project references. This reduces the complexity and depth of the build dependency graph along with reducing file I/O and processing during the build, resulting in lower overall build time.

This repo was created for Microsoft Hackathon 2020.

C++ Bogus Dependencies

The Microsoft C++ Linker includes a flag /VERBOSE:UNUSEDLIBS that writes additional information to stdout about .lib files that were unused. A similar flag /VERBOSE:UNUSEDDELAYLOAD can point to delay-load DLL references whose code was unused.

C# Bogus Dependencies

The C# compiler team committed a feature in 2019, Used Assembly References, that allows bogus dependency detection. See the issue. Feature documentation is here.

The feature exposes a new Roslyn analyzer API, GetUsedAssemblyReferences, to allow retrieving the assemblies that were actually used in generating the compilation output. Subtracting that list from the list of compiler input assemblies results in bogus assembly inputs.

Making Use of Bogus Dependency Information

For each bogus input, mapping to the source of the input can find one of:

  • A bogus project-to-project dependency if the input is generated by another project in the build. This feedback can result in either a developer making use of the input or cutting the dependency. Applied recursively, this could mean removing dead projects and code from a repo. The fastest build time is for code that is not compiled.
  • An unneeded package reference, e.g. to a Vcpkg C++ package or NuGet .NET package. This reduces compile/link I/O and CPU but does not change the build dependency graph. If this is the last such package reference, the package could be removed as a dependency of the repo, reducing build prep time by eliminating package pull requests.
  • An unneeded C++ SDK library reference that could be cut, reducing link I/O and CPU.

Related Work

  • https://github.com/dfederm/ReferenceTrimmer wraps an MSBuild execution and compares the assemblies pulled forward by RAR (MSBuild ResolveAssemblyReferences) to those referenced from proj-to-proj and package references, and recommends removals. The work in this repo can be combined with that work to make its recommendations much more robust, as without the Roslyn feature noted above, the compiler and RAR will leave behind referenced assemblies where only const values or interfaces were used, resulting in broken builds where packages or ProjectReferences were removed unnecessarily.

  • https://github.com/KirillOsenkov/CodeCleanupTools is a multi-tool with an option to clean up unused references.

Contributing

See Contributing.md.

bogusdependencies's People

Contributors

erikmav avatar microsoftopensource avatar stan-sz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.