Sync with Nix
[?]
Feb 24, 2016, 1:04 PM
B2L4T3X63XVYJQXEDU4WT5Y4R6PMDXGC6WN2KGOMHRQILSABNQOACDependencies
- [2]
RKW3XA4UFix potential race in dispatcher wakeup - [3]
Y5LMEC35BinaryCacheStore: Respect build-use-substitutes - [4]
V2UCCYN3hydra-queue-runner: Get store mode configuration from hydra.conf - [5]
7LB6QBXYKeep track of the number of build steps that are being built - [6]
MHVIT4JYSplit hydra-queue-runner.cc more - [7]
O3NM62IZSupport multiple machines files - [8]
K5G5GZY7Guard against concurrent invocations of hydra-queue-runner - [9]
W2AOTSS6Rename class - [10]
ENXUSMSVMake concurrency more robust - [11]
ACBS7C6Qhydra-queue-runner: Detect changes to the scheduling shares - [12]
OG3Z3QGCNamespace cleanup - [13]
N2NKSKHSRefactor local binary cache code into a subclass - [14]
GJV2J5HXPool local store connections - [15]
ATJ54SPXUse PostgreSQL notifications for queue events - [16]
HJOEIMLRRefactor - [17]
46ADBTMQStart steps in order of ascending build ID - [18]
TTBLPQAJKeep track of wait time per system type - [19]
N4IROACVMove buildRemote() into State - [20]
73YR46NJhydra-queue-runner: Write directly to a binary cache - [21]
GTUZLZRHAdd an S3-backed binary cache store - [22]
YR2IM6Y5Temporarily disable machines after a connection failure - [23]
CNLNT3T4Allow only 1 thread to send a closure to a given machine at the same time - [24]
IK2UBDAURevive jobset scheduling - [25]
YZAI5GQUImplement a database connection pool - [26]
MB3TISH2Rate-limit the number of threads copying closures at the same time - [27]
24BMQDZAStart of single-process hydra-queue-runner - [28]
5AIYUMTBBasic remote building - [29]
DWFTK56EKeep track of how many threads are waiting - [30]
RND7XFNHgetQueuedBuilds(): Periodically stop to handle priority bumps - [31]
EOO4EFWDUse a single BinaryCacheStore for all threads - [32]
QSBS2ISOS3BinaryCacheStore::isValidPath(): Do a GET instead of HEAD - [33]
XLYHZUHTCache .narinfo lookups - [34]
EYR3EW6JKeep stats for the Hydra auto scaler - [35]
32HHP5CWhydra-queue-runner: Support generating a signed binary cache - [36]
SOB276BAKeep some statistics for the binary cache stores - [37]
HPJKBFZ4Handle concurrent finishing of the same build - [38]
GH4S4AWMRename file
Change contents
- file deletion: pool.hh
#pragma once#include <memory>#include <list>#include "sync.hh"/* This template class implements a simple pool manager of resourcesof some type R, such as database connections. It is used asfollows:class Connection { ... };Pool<Connection> pool;{auto conn(pool.get());conn->exec("select ...");}Here, the Connection object referenced by ‘conn’ is automaticallyreturned to the pool when ‘conn’ goes out of scope.*/template <class R>class Pool{private:struct State{unsigned int count = 0;std::list<std::shared_ptr<R>> idle;};Sync<State> state;public:class Handle{private:Pool & pool;std::shared_ptr<R> r;friend Pool;Handle(Pool & pool, std::shared_ptr<R> r) : pool(pool), r(r) { }public:Handle(Handle && h) : pool(h.pool), r(h.r) { h.r.reset(); }Handle(const Handle & l) = delete;~Handle(){auto state_(pool.state.lock());if (r) state_->idle.push_back(r);}R * operator -> () { return r.get(); }R & operator * () { return *r; }};Handle get(){{auto state_(state.lock());if (!state_->idle.empty()) {auto p = state_->idle.back();state_->idle.pop_back();return Handle(*this, p);}state_->count++;}/* Note: we don't hold the lock while creating a new instance,because creation might take a long time. */}unsigned int count(){auto state_(state.lock());return state_->count;}};return Handle(*this, factory());Pool(const Factory & factory = []() { return std::make_shared<R>(); }): factory(factory){ }Factory factory;public:typedef std::function<std::shared_ptr<R>()> Factory;#include <functional> - file deletion: sync.hh
#pragma once#include <mutex>#include <condition_variable>/* This template class ensures synchronized access to a value of typeT. It is used as follows:struct Data { int x; ... };Sync<Data> data;{auto data_(data.lock());data_->x = 123;}Here, "data" is automatically unlocked when "data_" goes out ofscope.*/class Sync{private:std::mutex mutex;T data;public:class Lock{private:Sync * s;friend Sync;Lock(Sync * s) : s(s) { s->mutex.lock(); }public:Lock(Lock && l) : s(l.s) { l.s = 0; }Lock(const Lock & l) = delete;~Lock() { if (s) s->mutex.unlock(); }T * operator -> () { return &s->data; }T & operator * () { return s->data; }/* FIXME: performance impact of condition_variable_any? */void wait(std::condition_variable_any & cv){assert(s);cv.wait(s->mutex);}};Lock lock() { return Lock(this); }};}template<class Rep, class Period, class Predicate>bool wait_for(std::condition_variable_any & cv,const std::chrono::duration<Rep, Period> & duration,Predicate pred){assert(s);return cv.wait_for(s->mutex, duration, pred);}template<class Clock, class Duration>std::cv_status wait_until(std::condition_variable_any & cv,const std::chrono::time_point<Clock, Duration> & duration){assert(s);return cv.wait_until(s->mutex, duration);Sync() { }Sync(const T & data) : data(data) { }template<class T>#include <cassert> - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 15
BinaryCacheStore::BinaryCacheStore(const StoreFactory & storeFactory,BinaryCacheStore::BinaryCacheStore(std::shared_ptr<Store> localStore, - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 17
: storeFactory(storeFactory): localStore(localStore) - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 240
auto localStore = storeFactory();if (!localStore) return; - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 243
if (!(*localStore)->isValidPath(storePath)) {if (!localStore->isValidPath(storePath)) { - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 247
ValidPathInfo info = (*localStore)->queryPathInfo(storePath);ValidPathInfo info = localStore->queryPathInfo(storePath); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 256
(*localStore)->querySubstitutablePathInfos(left, infos);localStore->querySubstitutablePathInfos(left, infos); - edit in src/hydra-queue-runner/binary-cache-store.cc at line 261
auto localStore = storeFactory(); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 266
(*localStore)->addTempRoot(storePath);if (!localStore)throw Error(format("don't know how to realise path ‘%1%’ in a binary cache") % storePath); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 269
if (!(*localStore)->isValidPath(storePath))(*localStore)->ensurePath(storePath);localStore->addTempRoot(storePath); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 271
ValidPathInfo info = (*localStore)->queryPathInfo(storePath);if (!localStore->isValidPath(storePath))localStore->ensurePath(storePath); - edit in src/hydra-queue-runner/binary-cache-store.cc at line 274
ValidPathInfo info = localStore->queryPathInfo(storePath); - edit in src/hydra-queue-runner/binary-cache-store.hh at line 15
/* While BinaryCacheStore is thread-safe, LocalStore and RemoteStorearen't. Until they are, use a factory to produce a thread-locallocal store. */typedef Pool<nix::ref<nix::Store>> StorePool;typedef std::function<StorePool::Handle()> StoreFactory; - replacement in src/hydra-queue-runner/binary-cache-store.hh at line 23
StoreFactory storeFactory;std::shared_ptr<Store> localStore; - replacement in src/hydra-queue-runner/binary-cache-store.hh at line 34
BinaryCacheStore(const StoreFactory & storeFactory,BinaryCacheStore(std::shared_ptr<Store> localStore, - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 21
: localStorePool([]() { return std::make_shared<ref<Store>>(openStore()); }) - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 48
StorePool::Handle State::getLocalStore()ref<Store> State::getLocalStore() - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 50
auto conn(localStorePool.get());return conn;return ref<Store>(_localStore); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 748
_localStore = openStore(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 752
_destStore = openStore();_destStore = _localStore; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 760
[this]() { return this->getLocalStore(); },"/home/eelco/Misc/Keys/test.nixos.org/secret","/home/eelco/Misc/Keys/test.nixos.org/public",_localStore,hydraConfig["binary_cache_secret_key_file"],hydraConfig["binary_cache_public_key_file"], - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 773
[this]() { return this->getLocalStore(); },_localStore, - replacement in src/hydra-queue-runner/local-binary-cache-store.cc at line 5
LocalBinaryCacheStore::LocalBinaryCacheStore(const StoreFactory & storeFactory,LocalBinaryCacheStore::LocalBinaryCacheStore(std::shared_ptr<Store> localStore, - replacement in src/hydra-queue-runner/local-binary-cache-store.cc at line 8
: BinaryCacheStore(storeFactory, secretKeyFile, publicKeyFile): BinaryCacheStore(localStore, secretKeyFile, publicKeyFile) - replacement in src/hydra-queue-runner/local-binary-cache-store.hh at line 15
LocalBinaryCacheStore(const StoreFactory & storeFactory,LocalBinaryCacheStore(std::shared_ptr<Store> localStore, - replacement in src/hydra-queue-runner/queue-monitor.cc at line 39
bool done = getQueuedBuilds(*conn, *localStore, destStore, lastBuildId);bool done = getQueuedBuilds(*conn, localStore, destStore, lastBuildId); - replacement in src/hydra-queue-runner/s3-binary-cache-store.cc at line 34
S3BinaryCacheStore::S3BinaryCacheStore(const StoreFactory & storeFactory,S3BinaryCacheStore::S3BinaryCacheStore(std::shared_ptr<Store> localStore, - replacement in src/hydra-queue-runner/s3-binary-cache-store.cc at line 37
: BinaryCacheStore(storeFactory, secretKeyFile, publicKeyFile): BinaryCacheStore(localStore, secretKeyFile, publicKeyFile) - replacement in src/hydra-queue-runner/s3-binary-cache-store.hh at line 23
S3BinaryCacheStore(const StoreFactory & storeFactory,S3BinaryCacheStore(std::shared_ptr<Store> localStore, - replacement in src/hydra-queue-runner/state.hh at line 83
Sync<std::map<time_t, time_t>> steps;nix::Sync<std::map<time_t, time_t>> steps; - replacement in src/hydra-queue-runner/state.hh at line 190
Sync<State> state;nix::Sync<State> state; - replacement in src/hydra-queue-runner/state.hh at line 230
Sync<ConnectInfo> connectInfo;nix::Sync<ConnectInfo> connectInfo; - replacement in src/hydra-queue-runner/state.hh at line 269
Sync<Builds> builds;nix::Sync<Builds> builds; - replacement in src/hydra-queue-runner/state.hh at line 273
Sync<Jobsets> jobsets;nix::Sync<Jobsets> jobsets; - replacement in src/hydra-queue-runner/state.hh at line 280
Sync<Steps> steps;nix::Sync<Steps> steps; - replacement in src/hydra-queue-runner/state.hh at line 284
Sync<Runnable> runnable;nix::Sync<Runnable> runnable; - replacement in src/hydra-queue-runner/state.hh at line 287
Sync<bool> dispatcherWakeup;std::condition_variable_any dispatcherWakeupCV;nix::Sync<bool> dispatcherWakeup;std::condition_variable dispatcherWakeupCV; - replacement in src/hydra-queue-runner/state.hh at line 291
Pool<Connection> dbPool;nix::Pool<Connection> dbPool; - replacement in src/hydra-queue-runner/state.hh at line 295
Sync<Machines> machines; // FIXME: use atomic_shared_ptrnix::Sync<Machines> machines; // FIXME: use atomic_shared_ptr - replacement in src/hydra-queue-runner/state.hh at line 317
Sync<std::queue<nix::Path>> logCompressorQueue;std::condition_variable_any logCompressorWakeup;nix::Sync<std::queue<nix::Path>> logCompressorQueue;std::condition_variable logCompressorWakeup; - replacement in src/hydra-queue-runner/state.hh at line 325
Sync<std::queue<NotificationItem>> notificationSenderQueue;std::condition_variable_any notificationSenderWakeup;nix::Sync<std::queue<NotificationItem>> notificationSenderQueue;std::condition_variable notificationSenderWakeup; - replacement in src/hydra-queue-runner/state.hh at line 339
Sync<std::map<std::string, MachineType>> machineTypes;nix::Sync<std::map<std::string, MachineType>> machineTypes; - replacement in src/hydra-queue-runner/state.hh at line 353
/* Pool of local stores. */nix::StorePool localStorePool;/* Destination store. */std::shared_ptr<nix::Store> _localStore; - replacement in src/hydra-queue-runner/state.hh at line 363
nix::StorePool::Handle getLocalStore();nix::ref<nix::Store> getLocalStore(); - replacement in src/hydra-queue-runner/token-server.hh at line 17
std::condition_variable_any wakeup;std::condition_variable wakeup;