nix-gh/doc/manual/command-ref
Graham Christensen ee9c988a1b
Track function start and ends for flame graphs
With this patch, and this file I called `log.py`:

    #!/usr/bin/env nix-shell
    #!nix-shell -i python3 -p python3 --pure

    import sys
    from pprint import pprint

    stack = []
    timestack = []

    for line in open(sys.argv[1]):
        components = line.strip().split(" ", 2)
        if components[0] != "function-trace":
            continue

        direction = components[1]
        components = components[2].rsplit(" ", 2)

        loc = components[0]
        _at = components[1]
        time = int(components[2])

        if direction == "entered":
            stack.append(loc)
            timestack.append(time)
        elif direction == "exited":
            dur = time - timestack.pop()
            vst = ";".join(stack)
            print(f"{vst} {dur}")
            stack.pop()

and:

    nix-instantiate --trace-function-calls -vvvv ../nixpkgs/pkgs/top-level/release.nix -A unstable > log.matthewbauer 2>&1
    ./log.py ./log.matthewbauer > log.matthewbauer.folded
    flamegraph.pl --title matthewbauer-post-pr log.matthewbauer.folded > log.matthewbauer.folded.svg

I can make flame graphs like: http://gsc.io/log.matthewbauer.folded.svg

---

Includes test cases around function call failures and tryEval. Uses
RAII so the finish is always called at the end of the function.
2019-08-14 16:09:35 -04:00
..
command-ref.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
conf-file.xml Track function start and ends for flame graphs 2019-08-14 16:09:35 -04:00
env-common.xml docs: describe $IN_NIX_SHELL values (#2796) 2019-05-17 09:50:42 +02:00
files.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
main-commands.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
nix-build.xml Remove docs on removed --drv-link and --add-drv-link options 2018-02-01 16:40:58 +01:00
nix-channel.xml nix-channel: Don't fetch binary-cache-url 2019-06-25 13:27:16 +02:00
nix-collect-garbage.xml nix-collect-garbage: little doc fix 2018-04-30 09:36:46 -07:00
nix-copy-closure.xml Don't look for a "pv" program, or mention it in the manual source 2019-01-07 16:40:19 -05:00
nix-daemon.xml Fix references to version.txt 2014-09-16 14:57:45 +02:00
nix-env.xml Merge pull request #767 from mogorman/garbage_collect_keep_last_few 2018-05-31 10:00:21 +02:00
nix-hash.xml Escape left angle brackets in XML documentation 2017-12-09 15:31:03 +00:00
nix-instantiate.xml Clarify nix-instantiate --read-write-mode 2018-12-14 09:36:40 +01:00
nix-prefetch-url.xml man page (nix-prefetch-url): Add some missing options 2017-07-07 22:11:46 +02:00
nix-shell.xml Update instructions for Haskell script using nix-shell interpreter 2019-01-18 10:50:54 +10:00
nix-store.xml Merge pull request #2779 from LnL7/build-exit-codes 2019-07-02 17:37:49 +02:00
opt-common-syn.xml doc: Adds --quiet to the common options. 2018-04-20 16:34:06 -04:00
opt-common.xml docs: Mention --max-jobs 0 to build remotely only 2019-03-31 03:57:45 +02:00
opt-inst-syn.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
utilities.xml Nuke nix-push. 2016-08-10 11:13:11 -04:00