lix/src/libexpr
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
..
primops Merge pull request #2582 from LnL7/fetchgit-refs 2019-07-02 15:44:31 +02:00
attr-path.cc Replace Unicode quotes in user-facing strings by ASCII 2017-07-30 12:32:45 +01:00
attr-path.hh Work on Values instead of Exprs 2013-09-03 13:17:51 +00:00
attr-set.cc Remove duplicate definition of allocBytes() 2018-06-12 17:49:51 +02:00
attr-set.hh libexpr: Don't create lots of temporary strings in Bindings::lexicographicOrder 2018-02-19 22:47:25 +02:00
common-eval-args.cc Refactor downloadCached() interface 2019-06-24 22:12:26 +02:00
common-eval-args.hh Fix build 2017-11-01 21:32:30 +01:00
eval-inline.hh GC_malloc -> GC_MALLOC 2018-06-12 17:49:55 +02:00
eval.cc Track function start and ends for flame graphs 2019-08-14 16:09:35 -04:00
eval.hh Track function start and ends for flame graphs 2019-08-14 16:09:35 -04:00
function-trace.hh Track function start and ends for flame graphs 2019-08-14 16:09:35 -04:00
get-drvs.cc experimental/optional -> optional 2019-03-14 14:10:52 +01:00
get-drvs.hh experimental/optional -> optional 2019-03-14 14:10:52 +01:00
json-to-value.cc json-to-value: Use strtol instead of strtoi 2018-05-26 18:43:46 -04:00
json-to-value.hh Add builtin function ‘fromJSON’ 2014-07-04 13:34:15 +02:00
lexer.l simplify handling of extra '}' 2018-10-27 00:14:51 +02:00
local.mk Remove mentions of libformat, it no longer exists 2019-01-05 14:31:29 -05:00
names.cc Add splitVersion primop. 2018-02-14 09:55:43 -05:00
names.hh Add splitVersion primop. 2018-02-14 09:55:43 -05:00
nix-expr.pc.in pkg-config files: Use c++17 2019-03-14 14:11:12 +01:00
nixexpr.cc Fix compatibility with latest boost::format 2018-03-14 19:25:09 +01:00
nixexpr.hh Revert "Throw a specific error for incomplete parse errors." 2018-05-11 11:40:50 +02:00
parser.y Refactor downloadCached() interface 2019-06-24 22:12:26 +02:00
primops.cc Allow builtins.pathExists to check the existence of /nix/store paths 2019-07-30 11:27:35 +02:00
primops.hh Make prim_exec and prim_importNative available to plugins 2018-04-09 10:26:50 -04:00
symbol-table.hh Add environment variable NIX_SHOW_SYMBOLS for dumping the symbol table 2019-04-11 23:04:13 +02:00
value-to-json.cc nix path-info: Add --json flag 2016-08-29 17:29:24 +02:00
value-to-json.hh nix path-info: Add --json flag 2016-08-29 17:29:24 +02:00
value-to-xml.cc First hit at providing support for floats in the language. 2016-01-05 00:40:40 +01:00
value-to-xml.hh Use "#pragma once" to prevent repeated header file inclusion 2012-07-18 14:59:03 -04:00
value.hh libexpr: Use int64_t for NixInt 2018-08-29 01:05:52 +02:00