Skip to content

Commit e37e853

Browse files
authored
Managed Dependencies: fixing cold start time regression (#311)
* Change installed snapshot folder name pattern to *.r * Fix the doc
1 parent 83436cd commit e37e853

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/designs/PowerShell-AzF-Overall-Design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ A snapshot is considered _acceptable_ if it contains any version _allowed_ by th
500500

501501
However, if the latest snapshot is _not acceptable_ (i.e. it does not contain module versions required by the manifest), the worker starts installing the dependencies into a new snapshot, and all the subsequent function invocation requests are blocked, waiting for the new snapshot installation to complete.
502502

503-
When a snapshot installation starts, the dependencies are first installed into a folder with a name following a special pattern (`*i`), so that this snapshot is not picked up by any worker prematurely, before the installation is complete. After _successful_ completion, the snapshot is _atomically promoted_ by renaming the folder to follow a different pattern (`*r`), which indicates to other workers that this snapshot is ready to use. If the installation fails or cannot complete for any reason (for example, the worker restarts, crashes, or gets decommissioned), the folder stays in the installing state until removed.
503+
When a snapshot installation starts, the dependencies are first installed into a folder with a name following a special pattern (`*.ri`), so that this snapshot is not picked up by any worker prematurely, before the installation is complete. After _successful_ completion, the snapshot is _atomically promoted_ by renaming the folder to follow a different pattern (`*.r`), which indicates to other workers that this snapshot is ready to use. If the installation fails or cannot complete for any reason (for example, the worker restarts, crashes, or gets decommissioned), the folder stays in the installing state until removed.
504504

505505
Incomplete and old snapshots that are no longer in use are periodically removed from the file storage. In order to allow detecting unused snapshots, each PowerShell worker keeps "touching" a file named `.used` at the root of the used snapshot folder every `MDHeartbeatPeriod` minutes. Before and after installing any new snapshot, every PowerShell worker looks for unused snapshots by checking the folder creation time and the `.used` file modification time. If both these time values are older than (`MDHeartbeatPeriod` + `MDOldSnapshotHeartbeatMargin`) minutes, the snapshot is considered unused, so the PowerShell worker removes it. The latest `MDMinNumberOfSnapshotsToKeep` snapshots will never be removed, regardless of usage.
506506

src/DependencyManagement/DependencySnapshotFolderNameTools.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal static class DependencySnapshotFolderNameTools
1212
{
1313
private const string InstallingPostfix = "i";
1414

15-
public const string InstalledPostfix = "r";
15+
public const string InstalledPostfix = ".r";
1616

1717
public const string InstalledPattern = "*" + InstalledPostfix;
1818

@@ -29,10 +29,10 @@ public static string CreateUniqueName()
2929
/// appending a postfix, so that that the resulting path follows a different
3030
/// pattern and can be discovered using a different file mask.
3131
/// For example, for the _installed_ path
32-
/// ".../1907101234567r"
32+
/// ".../1907101234567.r"
3333
/// the _installing_ path will be:
34-
/// ".../1907101234567ri"
35-
/// This makes it possible to enumerate all the installed snapshots by using ".../*r" mask,
34+
/// ".../1907101234567.ri"
35+
/// This makes it possible to enumerate all the installed snapshots by using ".../*.r" mask,
3636
/// and all the installing snapshots by using ".../*i" mask.
3737
/// </summary>
3838
public static string ConvertInstalledToInstalling(string installedPath)

0 commit comments

Comments
 (0)