HOT SALE: 15% off your build times!
This was achieved by running maintainers/buildtime_report.sh on the
build directory of a meson build, then asking "why the heck is json
eating our build times", and strategically moving the json using bits
out of widely included headers.
It turns out that putting literally any metrics whatsoever into the
build had immediate and predictable results.
Results are 1382.5s frontend time -> 1175.4s frontend time, back end
time approximately invariant.
Related: #159
Change-Id: I7edea95c8536203325c8bb4dae5f32d727a21b2d
This commit is contained in:
parent
412a9c9f67
commit
edba570664
|
@ -1,4 +1,5 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <span>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "print.hh"
|
#include "print.hh"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "topo-sort.hh"
|
#include "topo-sort.hh"
|
||||||
#include "callback.hh"
|
#include "callback.hh"
|
||||||
#include "local-store.hh" // TODO remove, along with remaining downcasts
|
#include "local-store.hh" // TODO remove, along with remaining downcasts
|
||||||
|
#include "logging-json.hh"
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "common-protocol.hh"
|
#include "common-protocol.hh"
|
||||||
#include "common-protocol-impl.hh"
|
#include "common-protocol-impl.hh"
|
||||||
#include "fs-accessor.hh"
|
#include "fs-accessor.hh"
|
||||||
|
#include "json-utils.hh"
|
||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "json-utils.hh"
|
#include "json-utils.hh"
|
||||||
|
// Required for instances of to_json and from_json for ExperimentalFeature
|
||||||
|
#include "experimental-features-json.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "args/root.hh"
|
#include "args/root.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
#include "json-utils.hh"
|
#include "json-utils.hh"
|
||||||
|
#include "experimental-features-json.hh"
|
||||||
|
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
|
|
||||||
|
|
29
src/libutil/experimental-features-json.hh
Normal file
29
src/libutil/experimental-features-json.hh
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
///@file
|
||||||
|
|
||||||
|
#include "experimental-features.hh"
|
||||||
|
#include "json-utils.hh"
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute the documentation of all experimental features.
|
||||||
|
*
|
||||||
|
* See `doc/manual` for how this information is used.
|
||||||
|
*/
|
||||||
|
nlohmann::json documentExperimentalFeatures();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Semi-magic conversion to and from json.
|
||||||
|
* See the nlohmann/json readme for more details.
|
||||||
|
*/
|
||||||
|
void to_json(nlohmann::json &, const ExperimentalFeature &);
|
||||||
|
void from_json(const nlohmann::json &, ExperimentalFeature &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It is always rendered as a string
|
||||||
|
*/
|
||||||
|
template<>
|
||||||
|
struct json_avoids_null<ExperimentalFeature> : std::true_type {};
|
||||||
|
|
||||||
|
};
|
|
@ -1,4 +1,6 @@
|
||||||
#include "experimental-features.hh"
|
#include "experimental-features.hh"
|
||||||
|
// Required for instances of to_json and from_json for ExperimentalFeature
|
||||||
|
#include "experimental-features-json.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
#include "comparator.hh"
|
|
||||||
#include "error.hh"
|
#include "error.hh"
|
||||||
#include "json-utils.hh"
|
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
@ -52,13 +50,6 @@ const std::optional<ExperimentalFeature> parseExperimentalFeature(
|
||||||
*/
|
*/
|
||||||
std::string_view showExperimentalFeature(const ExperimentalFeature);
|
std::string_view showExperimentalFeature(const ExperimentalFeature);
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the documentation of all experimental features.
|
|
||||||
*
|
|
||||||
* See `doc/manual` for how this information is used.
|
|
||||||
*/
|
|
||||||
nlohmann::json documentExperimentalFeatures();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shorthand for `str << showExperimentalFeature(feature)`.
|
* Shorthand for `str << showExperimentalFeature(feature)`.
|
||||||
*/
|
*/
|
||||||
|
@ -87,17 +78,4 @@ public:
|
||||||
MissingExperimentalFeature(ExperimentalFeature missingFeature);
|
MissingExperimentalFeature(ExperimentalFeature missingFeature);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Semi-magic conversion to and from json.
|
|
||||||
* See the nlohmann/json readme for more details.
|
|
||||||
*/
|
|
||||||
void to_json(nlohmann::json &, const ExperimentalFeature &);
|
|
||||||
void from_json(const nlohmann::json &, ExperimentalFeature &);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It is always rendered as a string
|
|
||||||
*/
|
|
||||||
template<>
|
|
||||||
struct json_avoids_null<ExperimentalFeature> : std::true_type {};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
23
src/libutil/logging-json.hh
Normal file
23
src/libutil/logging-json.hh
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
///@file logging-json.hh
|
||||||
|
///
|
||||||
|
///@brief Logging functions for json specifically, split due to the cost of
|
||||||
|
///including nlohmann.
|
||||||
|
|
||||||
|
#include "logging.hh"
|
||||||
|
|
||||||
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
std::optional<nlohmann::json> parseJSONMessage(const std::string & msg);
|
||||||
|
|
||||||
|
bool handleJSONLogMessage(nlohmann::json & json,
|
||||||
|
const Activity & act, std::map<ActivityId, Activity> & activities,
|
||||||
|
bool trusted);
|
||||||
|
|
||||||
|
bool handleJSONLogMessage(const std::string & msg,
|
||||||
|
const Activity & act, std::map<ActivityId, Activity> & activities,
|
||||||
|
bool trusted);
|
||||||
|
|
||||||
|
};
|
|
@ -5,8 +5,6 @@
|
||||||
#include "error.hh"
|
#include "error.hh"
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
|
|
||||||
#include <nlohmann/json_fwd.hpp>
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -184,16 +182,6 @@ Logger * makeSimpleLogger(bool printBuildLogs = true);
|
||||||
|
|
||||||
Logger * makeJSONLogger(Logger & prevLogger);
|
Logger * makeJSONLogger(Logger & prevLogger);
|
||||||
|
|
||||||
std::optional<nlohmann::json> parseJSONMessage(const std::string & msg);
|
|
||||||
|
|
||||||
bool handleJSONLogMessage(nlohmann::json & json,
|
|
||||||
const Activity & act, std::map<ActivityId, Activity> & activities,
|
|
||||||
bool trusted);
|
|
||||||
|
|
||||||
bool handleJSONLogMessage(const std::string & msg,
|
|
||||||
const Activity & act, std::map<ActivityId, Activity> & activities,
|
|
||||||
bool trusted);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* suppress msgs > this
|
* suppress msgs > this
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,6 +50,7 @@ libutil_headers = files(
|
||||||
'error.hh',
|
'error.hh',
|
||||||
'exit.hh',
|
'exit.hh',
|
||||||
'experimental-features.hh',
|
'experimental-features.hh',
|
||||||
|
'experimental-features-json.hh',
|
||||||
'finally.hh',
|
'finally.hh',
|
||||||
'fmt.hh',
|
'fmt.hh',
|
||||||
'git.hh',
|
'git.hh',
|
||||||
|
@ -59,6 +60,7 @@ libutil_headers = files(
|
||||||
'json-impls.hh',
|
'json-impls.hh',
|
||||||
'json-utils.hh',
|
'json-utils.hh',
|
||||||
'logging.hh',
|
'logging.hh',
|
||||||
|
'logging-json.hh',
|
||||||
'lru-cache.hh',
|
'lru-cache.hh',
|
||||||
'monitor-fd.hh',
|
'monitor-fd.hh',
|
||||||
'namespaces.hh',
|
'namespaces.hh',
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "finally.hh"
|
#include "finally.hh"
|
||||||
#include "loggers.hh"
|
#include "loggers.hh"
|
||||||
#include "markdown.hh"
|
#include "markdown.hh"
|
||||||
|
#include "experimental-features-json.hh"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "debug-char.hh"
|
#include "debug-char.hh"
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
#include <ranges>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
|
|
Loading…
Reference in a new issue