Git Product home page Git Product logo

ninjatracing's Introduction

ninjatracing

Convert .ninja_log files to chrome's about:tracing format.

To view traces, either open about:tracing in chrome, or use https://www.speedscope.app/ or https://ui.perfetto.dev/.

Idea from Nick Carter, initial implementation from Richard Smith.

$ ./ninjatracing
Converts one (or several) .ninja_log files into chrome's about:tracing format

Usage:
    ninja -C $BUILDDIR
    ninjatracing $BUILDDIR/.ninja_log > trace.json

By default this will show build timing results for the most recent (possibly
incremental) build. To show build timing results for every target, whether
built in the last build or previously, use --showall. Note that this will
overlap multiple builds and will thus exaggerate build parallelism.

(When using --showall, ideally rm $BUILDDIR/.ninja_log and do a clean build.
If you don't have time for a clean build, at least run
`ninja -C $BUILDDIR -t recompact` first to remove no-longer-built targets.)

The results can be converted from .json format to .html format, for easier
loading into about:tracing, using trace2html from:
https://github.com/catapult-project/catapult/blob/master/tracing/bin/trace2html

ninjatracing's People

Contributors

atetubou avatar e4lam avatar hadrielk avatar kasper93 avatar nico avatar nocnokneo avatar petrhosek avatar randomascii avatar rgal avatar tanderson-google avatar theidexisted avatar tzik 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

ninjatracing's Issues

Batch generate trace pictures with chrome?

Random question for the great @nico: Do you know if there is a way to "automate" with ninjatracing and chrome? That is I run ninja install, then ninjatracing, and then somehow chrome from the commandline on the json and then, in the end, have a nice png of the trace?

My guess: heck no, but I thought I'd ask 😄

Failing unit test test_simple

With the current master, test_simple fails for me:

======================================================================
FAIL: test_simple (__main__.TestNinjaTracing)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./ninjatracing_test", line 41, in test_simple
    self.assertEqual(expected, dicts)
AssertionError: Lists differ: [{'args': {}, 'name': 'my_firs... != [{'args': {}, 'name': 'my_outp...

First differing element 0:
{'args': {}, 'name': 'my_first_output', 'tid': '0', 'ph': 'X', 'dur': '70000', 'pid': '42', 'ts': '50000', 'cat': 'targets'}
{'args': {}, 'name': 'my_output', 'tid': '0', 'ph': 'X', 'dur': '100000', 'pid': '42', 'ts': '100000', 'cat': 'targets'}

  [{'args': {},
+   'cat': 'targets',
+   'dur': '100000',
+   'name': 'my_output',
+   'ph': 'X',
+   'pid': '42',
+   'tid': '0',
+   'ts': '100000'},
+  {'args': {},
    'cat': 'targets',
    'dur': '70000',
    'name': 'my_first_output',
    'ph': 'X',
    'pid': '42',
-   'tid': '0',
-   'ts': '50000'},
-  {'args': {},
-   'cat': 'targets',
-   'dur': '100000',
-   'name': 'my_output',
-   'ph': 'X',
-   'pid': '42',
    'tid': '1',
-   'ts': '100000'}]
?          ^^

+   'ts': '50000'}]
?          ^


----------------------------------------------------------------------
Ran 3 tests in 0.002s

FAILED (failures=1)

Create a Version Tag

As we use your project in our CI.

Could you create a tag that links to a version with its source code?

ninjatracing should avoid chrome://tracing timer warning

When ninjatracing's results are imported into chrome://tracing there is usually a warning saying:

Import Warning: low_resolution_timer: Trace time is low resolution, trace may be unusable.

This is based on a heuristic (isTimeHighResolutionHeuristic_ in model.html) which looks at the times in the trace to see whether they look like they are all roughly aligned to the same millisecond offset. This warning is distracting and not particularly relevant for ninjatracing. It would be nice to tweak ninjatracing or chrome://tracing to avoid this warning.

Support visualization of incremental builds

In many cases it is more important to optimize incremental builds rather than full rebuilds, and ninjatracing doesn't support visualizing incremental builds in a useful way, since it appears that the timestamps in the .ninja_log file are relative to when ninja started running, so multiple ninja invocations lead to an untangleable mess.

ninjatracing could handle this reasonably well by recognizing when the completion times in the .ninja_log file run backwards. This always indicates a new build so it would be easy to generate a .json file for the last (incremental) build. I could argue that this should even be the default behavior, with an override to specify build n-1, n-2, etc.

The heuristic is not perfect because it is possible for completion times from two adjacent builds to be non-overlapping, but this should be rare.

I have a test implementation. I can make a PR if this is of interest.

Any interest in adding this to pypi?

I am currently using this project for a work task. I would appreciate versioning this and having it published on Pypi. If this is something else other people would want, I could make a pull request.

Also, why not use cmake —profiling-format and cmake —profiling-output instead of this project? I have a use case where I am building a submodule, and changing the flags is more work. However, I am curious about other use cases.

Replace `optparse` by `argparse`

ninjatracing still uses the deprecated optparse module. An alternative would be to use argparse. I recently submitted a patch to scipy where this was fixed (scipy/scipy#19030). Would you be interested in this as well?

Xcode 14 will rebuild a lot of files even there is no changes.

@zanderso

A lot of files are mark to dirty.

ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.base_flow_graph_builder.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.constant_reader.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.flow_graph_builder.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.kernel_binary_flowgraph.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.kernel_fingerprints.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.kernel_to_il.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.kernel_translation_helper.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.prologue_builder.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/frontend/libdart_compiler_jit.scope_builder.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.graph_intrinsifier.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.intrinsifier.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/jit/libdart_compiler_jit.jit_call_specializer.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.method_recognizer.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.relocation.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.stub_code_compiler.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.stub_code_compiler_arm.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.stub_code_compiler_arm64.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.stub_code_compiler_ia32.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.stub_code_compiler_riscv.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.stub_code_compiler_x64.o is dirty
ninja explain: obj/third_party/dart/runtime/vm/compiler/libdart_compiler_jit.write_barrier_elimination.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.bignum-dtoa.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.bignum.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.cached-powers.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.diy-fp.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.double-conversion.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.fast-dtoa.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.fixed-dtoa.o is dirty
ninja explain: obj/third_party/dart/runtime/third_party/double-conversion/src/libdouble_conversion.strtod.o is dirty
ninja explain: obj/third_party/libcxxabi/src/libcxxabi.cxa_exception.o is dirty
ninja explain: obj/third_party/libcxxabi/src/libcxxabi.cxa_personality.o is dirty

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.