@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

In Harbormaster, record byte length on the build logs

Summary: Depends on D19135. Ref T13088. Denormalize the total log size onto the log itself. This makes reasoning about the log at display time easier, and we don't need to fish around in the database as much to figure out what we're dealing with.

Test Plan: Ran `bin/harbormaster rebuild-log`, saw an existing log populate. Ran `bin/harbormaster write-log`, saw new log write with proper length information.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13088

Differential Revision: https://secure.phabricator.com/D19136

+35 -13
+2
resources/sql/autopatches/20180223.log.01.bytelength.sql
··· 1 + ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildlog 2 + ADD byteLength BIGINT UNSIGNED NOT NULL;
+20 -13
src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
··· 12 12 protected $duration; 13 13 protected $live; 14 14 protected $filePHID; 15 + protected $byteLength; 15 16 16 17 private $buildTarget = self::ATTACHABLE; 17 18 private $rope; ··· 42 43 return id(new HarbormasterBuildLog()) 43 44 ->setBuildTargetPHID($build_target->getPHID()) 44 45 ->setDuration(null) 45 - ->setLive(1); 46 + ->setLive(1) 47 + ->setByteLength(0); 46 48 } 47 49 48 50 public function scheduleRebuild($force) { ··· 70 72 71 73 'live' => 'bool', 72 74 'filePHID' => 'phid?', 75 + 'byteLength' => 'uint64', 73 76 ), 74 77 self::CONFIG_KEY_SCHEMA => array( 75 78 'key_buildtarget' => array( ··· 341 344 $append_data = $rope->getPrefixBytes($data_limit); 342 345 $data_size = strlen($append_data); 343 346 344 - if ($append_id) { 345 - queryfx( 346 - $conn_w, 347 - 'UPDATE %T SET chunk = CONCAT(chunk, %B), size = %d WHERE id = %d', 348 - $chunk_table, 349 - $append_data, 350 - $prefix_size + $data_size, 351 - $append_id); 352 - } else { 353 - $this->writeChunk($encoding_text, $data_size, $append_data); 354 - } 347 + $this->openTransaction(); 348 + if ($append_id) { 349 + queryfx( 350 + $conn_w, 351 + 'UPDATE %T SET chunk = CONCAT(chunk, %B), size = %d WHERE id = %d', 352 + $chunk_table, 353 + $append_data, 354 + $prefix_size + $data_size, 355 + $append_id); 356 + } else { 357 + $this->writeChunk($encoding_text, $data_size, $append_data); 358 + } 359 + 360 + $this->byteLength += $data_size; 361 + $this->save(); 362 + $this->saveTransaction(); 355 363 356 364 $rope->removeBytesFromHead($data_size); 357 365 } 358 366 } 359 - 360 367 361 368 362 369 /* -( PhabricatorPolicyInterface )----------------------------------------- */
+13
src/applications/harbormaster/worker/HarbormasterLogWorker.php
··· 57 57 $data = $this->getTaskData(); 58 58 $is_force = idx($data, 'force'); 59 59 60 + if (!$log->getByteLength() || $is_force) { 61 + $iterator = $log->newChunkIterator() 62 + ->setAsString(true); 63 + 64 + $byte_length = 0; 65 + foreach ($iterator as $block) { 66 + $byte_length += strlen($block); 67 + } 68 + $log 69 + ->setByteLength($byte_length) 70 + ->save(); 71 + } 72 + 60 73 if ($log->canCompressLog()) { 61 74 $log->compressLog(); 62 75 }