Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0de33cc81b9c
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cb90e382b5b6
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jan 5, 2020

  1. Hide FunctionCallTrace constructor/destructor

    This prevents them from being inlined. On gcc 9, this reduces the
    stack size needed for
    
      nix-instantiate '<nixpkgs>' -A texlive.combined.scheme-full --dry-run
    
    from 12.9 MiB to 4.8 MiB.
    edolstra committed Jan 5, 2020
    2
    Copy the full SHA
    cb90e38 View commit details
Showing with 20 additions and 15 deletions.
  1. +1 −3 src/libexpr/eval.cc
  2. +17 −0 src/libexpr/function-trace.cc
  3. +2 −12 src/libexpr/function-trace.hh
4 changes: 1 addition & 3 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
@@ -1106,9 +1106,7 @@ void EvalState::callPrimOp(Value & fun, Value & arg, Value & v, const Pos & pos)

void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & pos)
{
std::unique_ptr<FunctionCallTrace> trace;
if (evalSettings.traceFunctionCalls)
trace = std::make_unique<FunctionCallTrace>(pos);
auto trace = evalSettings.traceFunctionCalls ? std::make_unique<FunctionCallTrace>(pos) : nullptr;

forceValue(fun, pos);

17 changes: 17 additions & 0 deletions src/libexpr/function-trace.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "function-trace.hh"

namespace nix {

FunctionCallTrace::FunctionCallTrace(const Pos & pos) : pos(pos) {
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
}

FunctionCallTrace::~FunctionCallTrace() {
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
}

}
14 changes: 2 additions & 12 deletions src/libexpr/function-trace.hh
Original file line number Diff line number Diff line change
@@ -9,17 +9,7 @@ namespace nix {
struct FunctionCallTrace
{
const Pos & pos;

FunctionCallTrace(const Pos & pos) : pos(pos) {
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
}

~FunctionCallTrace() {
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
}
FunctionCallTrace(const Pos & pos);
~FunctionCallTrace();
};
}