Je ne me souviens pas MDR LOL

This commit is contained in:
Félix Baylac-Jacqué 2019-10-05 15:50:22 +02:00
parent d851f24dde
commit caa867df74
4 changed files with 30 additions and 13 deletions

View File

@ -43,6 +43,7 @@
<arg choice='plain'><option>--expr</option></arg>
<arg choice='plain'><option>-E</option></arg>
</group>
<arg choice='plain'><option>--profile</option></arg>
<arg choice='plain' rep='repeat'><replaceable>files</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
@ -162,6 +163,19 @@ input.</para>
</varlistentry>
<varlistentry><term><option>--profile</option></term>
<listitem><para>When used with <option>--eval</option>, perform
evaluation in read/write mode so nix language features that
require it will still work (at the cost of needing to do
instantiation of every evaluated derivation). If this option is
not enabled, there may be uninstantiated store paths in the final
output.</para>
</listitem>
</varlistentry>
</variablelist>
<variablelist condition="manpage">

View File

@ -10,6 +10,7 @@
#include <map>
#include <unordered_map>
#include <array>
namespace nix {
@ -329,20 +330,20 @@ typedef int LineNumber;
struct ProfFuncOcc {
CompressedFuncId funcId;
CompressedFileId fileId;
}
struct ProfCostOcc {
ProfFuncOcc funcOcc;
int selfCost;
Array<ProfFuncCall> calledFunctions;
}
};
struct ProfFuncCall {
CompressedFuncId calledFunc;
CompressedFileId calledFile;
LineNumber calledFuncLineNb;
int cost;
}
};
struct ProfCostOcc {
ProfFuncOcc funcOcc;
int selfCost;
std::array<ProfFuncCall, 100> calledFunctions;
};
class ProfilerState {
@ -351,7 +352,7 @@ public:
void saveCost(ProfCostOcc& occCost);
private:
Array<ProfCostOcc> stackedMeasurements;
std::array<ProfCostOcc, 100> stackedMeasurements;
string funcName;
/* We index every func and file to leverage Callgrind's string compression.
See section "3.1.6.<2E>Subposition Compression" section from [callgrindSpec]. */
@ -359,7 +360,7 @@ private:
std::map<CompressedFileId,FileName> fileMap;
CompressedFuncId currentFuncId;
CompressedFileId currentFileId;
}
};
/* Return a string representing the type of the value `v'. */
string showType(const Value & v);
@ -401,8 +402,6 @@ struct EvalSettings : Config
Setting<bool> traceFunctionCalls{this, false, "trace-function-calls",
"Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)"};
Setting<bool> profileEvaluation(this, false, "profile-function-calls",
"Generates a callgraph profile summary which you can interpret using kcachegrind.");
};
extern EvalSettings evalSettings;

View File

@ -353,8 +353,10 @@ public:
Setting<Paths> pluginFiles{this, {}, "plugin-files",
"Plugins to dynamically load at nix initialization time."};
};
Setting<bool> profileEvaluation{this, false, "profile-function-calls",
"Generates a callgraph profile summary which you can interpret using kcachegrind."};
};
// FIXME: don't use a global variable.
extern Settings settings;

View File

@ -140,6 +140,8 @@ static int _main(int argc, char * * argv)
repair = Repair;
else if (*arg == "--dry-run")
settings.readOnlyMode = true;
else if (*arg == "--profile")
settings.profileEvaluation = true;
else if (*arg != "" && arg->at(0) == '-')
return false;
else