Merge remote-tracking branch 'origin/master' into binary-cache

This commit is contained in:
Eelco Dolstra 2016-02-17 11:54:59 +01:00
commit ce5790285a
7 changed files with 41 additions and 11 deletions

View file

@ -235,7 +235,14 @@ void State::buildRemote(ref<Store> destStore,
mc1.reset(); mc1.reset();
MaintainCount mc2(nrStepsCopyingTo); MaintainCount mc2(nrStepsCopyingTo);
printMsg(lvlDebug, format("sending closure of %1% to %2%") % step->drvPath % machine->sshName); printMsg(lvlDebug, format("sending closure of %1% to %2%") % step->drvPath % machine->sshName);
auto now1 = std::chrono::steady_clock::now();
copyClosureTo(destStore, from, to, inputs, bytesSent); copyClosureTo(destStore, from, to, inputs, bytesSent);
auto now2 = std::chrono::steady_clock::now();
result.overhead += std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
} }
autoDelete.cancel(); autoDelete.cancel();
@ -289,7 +296,14 @@ void State::buildRemote(ref<Store> destStore,
for (auto & output : step->drv.outputs) for (auto & output : step->drv.outputs)
outputs.insert(output.second.path); outputs.insert(output.second.path);
MaintainCount mc(nrStepsCopyingFrom); MaintainCount mc(nrStepsCopyingFrom);
auto now1 = std::chrono::steady_clock::now();
copyClosureFrom(destStore, from, to, outputs, bytesReceived); copyClosureFrom(destStore, from, to, outputs, bytesReceived);
auto now2 = std::chrono::steady_clock::now();
result.overhead += std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
} }
/* Shut down the connection. */ /* Shut down the connection. */

View file

@ -165,7 +165,7 @@ bool State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
} }
if (retry) { if (retry) {
pqxx::work txn(*conn); pqxx::work txn(*conn);
finishBuildStep(txn, result.startTime, result.stopTime, build->id, finishBuildStep(txn, result.startTime, result.stopTime, result.overhead, build->id,
stepNr, machine->sshName, bssAborted, result.errorMsg); stepNr, machine->sshName, bssAborted, result.errorMsg);
txn.commit(); txn.commit();
if (quit) exit(1); if (quit) exit(1);
@ -214,7 +214,8 @@ bool State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
{ {
pqxx::work txn(*conn); pqxx::work txn(*conn);
finishBuildStep(txn, result.startTime, result.stopTime, build->id, stepNr, machine->sshName, bssSuccess); finishBuildStep(txn, result.startTime, result.stopTime, result.overhead,
build->id, stepNr, machine->sshName, bssSuccess);
for (auto & b : direct) for (auto & b : direct)
markSucceededBuild(txn, b, res, build != b || result.status != BuildResult::Built, markSucceededBuild(txn, b, res, build != b || result.status != BuildResult::Built,
@ -334,8 +335,8 @@ bool State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
} }
if (!cachedFailure) if (!cachedFailure)
finishBuildStep(txn, result.startTime, result.stopTime, build->id, finishBuildStep(txn, result.startTime, result.stopTime, result.overhead,
stepNr, machine->sshName, buildStepStatus, result.errorMsg); build->id, stepNr, machine->sshName, buildStepStatus, result.errorMsg);
/* Mark all builds that depend on this derivation as failed. */ /* Mark all builds that depend on this derivation as failed. */
for (auto & build2 : indirect) { for (auto & build2 : indirect) {

View file

@ -221,18 +221,20 @@ int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build,
} }
void State::finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime, BuildID buildId, int stepNr, void State::finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime, unsigned int overhead,
const std::string & machine, BuildStepStatus status, const std::string & errorMsg, BuildID propagatedFrom) BuildID buildId, int stepNr, const std::string & machine, BuildStepStatus status,
const std::string & errorMsg, BuildID propagatedFrom)
{ {
assert(startTime); assert(startTime);
assert(stopTime); assert(stopTime);
txn.parameterized txn.parameterized
("update BuildSteps set busy = 0, status = $1, propagatedFrom = $4, errorMsg = $5, startTime = $6, stopTime = $7, machine = $8 where build = $2 and stepnr = $3") ("update BuildSteps set busy = 0, status = $1, propagatedFrom = $4, errorMsg = $5, startTime = $6, stopTime = $7, machine = $8, overhead = $9 where build = $2 and stepnr = $3")
((int) status)(buildId)(stepNr) ((int) status)(buildId)(stepNr)
(propagatedFrom, propagatedFrom != 0) (propagatedFrom, propagatedFrom != 0)
(errorMsg, errorMsg != "") (errorMsg, errorMsg != "")
(startTime)(stopTime) (startTime)(stopTime)
(machine, machine != "").exec(); (machine, machine != "")
(overhead, overhead != 0).exec();
} }

View file

@ -49,6 +49,7 @@ typedef enum {
struct RemoteResult : nix::BuildResult struct RemoteResult : nix::BuildResult
{ {
time_t startTime = 0, stopTime = 0; time_t startTime = 0, stopTime = 0;
unsigned int overhead = 0;
nix::Path logFile; nix::Path logFile;
bool canRetry() bool canRetry()
@ -370,7 +371,8 @@ private:
const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "", const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "",
BuildID propagatedFrom = 0); BuildID propagatedFrom = 0);
void finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime, BuildID buildId, int stepNr, void finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime,
unsigned int overhead, BuildID buildId, int stepNr,
const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "", const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "",
BuildID propagatedFrom = 0); BuildID propagatedFrom = 0);

View file

@ -98,6 +98,11 @@ __PACKAGE__->table("BuildSteps");
is_foreign_key: 1 is_foreign_key: 1
is_nullable: 1 is_nullable: 1
=head2 overhead
data_type: 'integer'
is_nullable: 1
=cut =cut
__PACKAGE__->add_columns( __PACKAGE__->add_columns(
@ -125,6 +130,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 }, { data_type => "text", is_nullable => 1 },
"propagatedfrom", "propagatedfrom",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"overhead",
{ data_type => "integer", is_nullable => 1 },
); );
=head1 PRIMARY KEY =head1 PRIMARY KEY
@ -194,8 +201,8 @@ __PACKAGE__->belongs_to(
); );
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2015-02-25 16:27:20 # Created by DBIx::Class::Schema::Loader v0.07043 @ 2016-02-16 18:04:52
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZbOxzCzFN7fIT9M2BFY0iQ # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TRALbEoaF/OIOyERYCyxkw
my %hint = ( my %hint = (
columns => [ columns => [

View file

@ -273,6 +273,9 @@ create table BuildSteps (
propagatedFrom integer, propagatedFrom integer,
-- Time in milliseconds spend copying stuff from/to build machines.
overhead integer,
primary key (build, stepnr), primary key (build, stepnr),
foreign key (build) references Builds(id) on delete cascade, foreign key (build) references Builds(id) on delete cascade,
foreign key (propagatedFrom) references Builds(id) on delete cascade foreign key (propagatedFrom) references Builds(id) on delete cascade

1
src/sql/upgrade-45.sql Normal file
View file

@ -0,0 +1 @@
alter table BuildSteps add column overhead integer;