Skip to content

Start-Job is now 6-10x slower, and does not preserve $env:PSModulePath #7402

@jazzdelightsme

Description

@jazzdelightsme

Steps to reproduce

$iter = 10
$env:PSModulePath = 'Custom PSModulePath'

Measure-Command {
    for( $i = 0; $i -lt $iter; $i++ )
    {
        $job = start-job -ScriptBlock { Write-Host $env:PSModulePath }
    }
}

Expected behavior

I should be able to kick off ten jobs in just a few seconds (maybe 2 or 3). When the results of the job come in, I should see Custom PSModulePath. This is the behavior in 5.1.

Actual behavior

It takes between 12 and 20 seconds. That's longer than a second per job! (and I'm not waiting for the job to finish; this is just the time for Start-Job to return) And then the output is the default module path.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0-preview.4
PSEdition                      Core
GitCommitId                    6.1.0-preview.4-26-g668ce91ddb14d71177b4de4f94d99c3e429e4ff7
OS                             Microsoft Windows 10.0.17692
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions