Git Product home page Git Product logo

cscpersistentworker's Introduction

CSC Persistent Worker Support

Bazel has the concept of Persistent Workers. This is a compiler that supports a client/server model of interaction. The client requests some files to be compiled and server replies with a response. This type of system is useful when the server benefits from "warming up" its just-in-time compilation or other caches. Additionally on platforms like Windows where creating a process is expensive, it is profitable to avoid creating a new process.

The C# compiler has support for this mode of operation. MSBuild, the .NET build system, will create a VBCSCompiler.exe server to handle all compilation requests (intead of execing a csc.exe process for every compilation request). The C# compiler, csc also supports a /shared flag that will attempt to start the compiler server and use it for the compilation.

How to support persistent workers in Bazel

There are 3 obvious paths forward for adding support for persistent workers to rules_dotnet:

  1. Create a wrapper that just calls csc.exe with the /shared argument.
  2. Write persistent worker that knows how to start VBCSCompiler.exe, based on on the open source code in the Roslyn repo.
  3. Request that the upstream csc.exe add support for the --persistent_worker flag.

The first one is simple enough to implement and has some performance benefits. This repo implements that approach.

The second and third options would have more performance benefits, as they would not need to exec any process to handle a build request. Option number 2 would be more involved, as the build server protocol is not officially documented or exposed as an API. It is an implementation detail of csc.exe. It goes as far as to embed the Git commit hash of the complier into the protocol. It appears that AFASResearch/rules_dotnet takes this approach.

Other levels of build servers

The dotnet build command has a similar MSBuild server feature. Note that this is distinct from the msbuild -nodeReuse feature.

cscpersistentworker's People

Contributors

austinwise avatar

Watchers

 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.