@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.

When a lease triggers a resource allocation for a resource which must activate, awaken the lease task after the resource activates

Summary:
Depends on D19753. Ref T13210. This is a small optimization that saves us from waiting up to 15 seconds for a yield.

When there are no Working Copy resources and a new lease comes in, we'll allocate one and yield until it activates.

If activating it (SSH'ing and running `git clone`) takes less than 15 seconds, the resource will activate (say, at T+4) but the lease won't update again for a while (say, until T+15). This leaves us with a pointless wait (in this example, we're sitting around for 9 seconds when we could move forward).

To improve this a little bit, let resources wake up the lease update tasks that triggered allocation after they activate. In the best case, that task runs ~15 seconds sooner. In the worst case, the awaken is just a no-op.

With a more-full queue, this has a smaller effect (it's likely something else will run and be able to use the resource in those 9 seconds).

With already-activated resources, this has no effect (when resources are already activated, we can lease immediately).

Test Plan:
- Cleaned up all working copy resources.
- Requested a new "A" working copy.
- Before patch: got a working copy after 17-18 seconds, most of which was spent yielded.
- After patch: got a working copy after 3-4 seconds.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13210

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

+12
+7
src/applications/drydock/worker/DrydockLeaseUpdateWorker.php
··· 599 599 'DrydockResourceUpdateWorker', 600 600 array( 601 601 'resourcePHID' => $resource->getPHID(), 602 + 603 + // This task will generally yield while the resource activates, so 604 + // wake it back up once the resource comes online. Most of the time, 605 + // we'll be able to lease the newly activated resource. 606 + 'awakenOnActivation' => array( 607 + $this->getCurrentWorkerTaskID(), 608 + ), 602 609 ), 603 610 array( 604 611 'objectPHID' => $resource->getPHID(),
+5
src/applications/drydock/worker/DrydockResourceUpdateWorker.php
··· 170 170 $blueprint = $resource->getBlueprint(); 171 171 $blueprint->activateResource($resource); 172 172 $this->validateActivatedResource($blueprint, $resource); 173 + 174 + $awaken_ids = $this->getTaskDataValue('awakenOnActivation'); 175 + if (is_array($awaken_ids) && $awaken_ids) { 176 + PhabricatorWorker::awakenTaskIDs($awaken_ids); 177 + } 173 178 } 174 179 175 180