Giter VIP home page Giter VIP logo

nin's Introduction

nin

Go Reference codecov

Little nin' is ninja's little sibling.

Nin is an experimental fork of ninja translated in Go.

Installation

Install go1.17 or later.

go install github.com/maruel/nin/cmd/nin@latest

Use nin where you would have used ninja (or create a symlink).

Are you serious?

Yeah.

The reason it's possible at all is because ninja is well written and has a reasonable amount of unit tests.

Why?

  • The parser can be used as a library
    • This opens the door to a lot of opportunity and a real ecosystem
  • Refactoring Go >> refactoring C++
    • As I made progress, I saw opportunities for simplification
  • Making the code concurrent (e.g. making the parser parallel) is easier
  • Plans to have it be stateful and/or do RPCs and change fundamental parts
    • E.g. call directly the RBE backend instead of shelling out reclient?
  • It's easier to keep the performance promise in check, and keep it maintainable
    • Go has native benchmarking
    • Go has native CPU and memory profiling
    • Go has native code coverage
    • Go has native documentation
  • Since it's GC, and the program runs as a one shot, we can just disable GC and save a significant amount of memory management (read: CPU) overhead.

I'll write a better roadmap if the project doesn't crash and burn.

Some people did advent of code 2021, I did a brain teaser instead.

Concerns

  • Go's slice and string bound checking slow things down, I'll have to micro optimize a bit.
  • Go's function calls are more expensive and the Go compiler inlines less often than the C++ compiler. I'll reduce the number of function calls.
  • Go's Windows layer is likely slower than raw C++, so I'll probably call raw syscall functions on Windows.
  • Staying up to date changes done upstream, especially to the file format and correctness checks.

Current state

  • Manifest (build.ninja) parsing: 5% faster on average! ๐Ÿ“‰
  • Latency: nin is in the same ballpark (-5%) for building ninja itself.
  • CPU usage: about 15% higher, has to be optimized.
  • 16 test cases out of 394 (5%) have to be fixed. git grep Skip..TODO | wc -l versus git grep "^func Test" | wc -l.
  • Closely tracking upstream as-is.
  • Flag parsing is not 100% compatible yet.

See PERF.md to learn how to measure performance yourself, since I know myself enough that I will forget to update the stats above and it will get better over time.

ninja

Ninja is a small build system with a focus on speed. https://ninja-build.org/

See the manual or doc/manual.asciidoc included in the distribution for background and more details.

nin's People

Contributors

atetubou avatar bradking avatar colincross avatar doctorlove avatar evanj avatar evmar avatar fanael avatar hi-angel avatar iwadon avatar jhasse avatar jonesmz avatar kwesolowski avatar maruel avatar mathstuf avatar maximuska avatar mikesep avatar neheb avatar nico avatar nicolasdespres avatar nocnokneo avatar pcc avatar qhuo avatar qulogic avatar rgeary1 avatar riannucci avatar scivision avatar sergeyn avatar sgraham avatar syntheticpp avatar tfarina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nin's Issues

Make execution faster

While the parser is significantly faster than upstream ninja, the execution part is slower. It's fine because I hadn't spent any time at all to optimize this. This issue is to remind myself (or others?) to optimize that part too.

Build work on Windows

The code is essentially all there but I probably messed up something during the translation, I just need to debug. I already have an open source chromium checkout on my personal Windows 10 machine to tests.

Handle SIGINT properly

It's not really hard. I just need to plumb all the things into a context.Context for a clean shutdown.

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.