Skip to content

Reduce minor allocations at runspace creation time#10803

Closed
iSazonov wants to merge 1 commit intoPowerShell:masterfrom
iSazonov:perf-create-runspace-1
Closed

Reduce minor allocations at runspace creation time#10803
iSazonov wants to merge 1 commit intoPowerShell:masterfrom
iSazonov:perf-create-runspace-1

Conversation

@iSazonov
Copy link
Copy Markdown
Collaborator

@iSazonov iSazonov commented Oct 16, 2019

PR Summary

  • Use internal PSPropertySet() constructor without checks for null and empty property names
  • Initialize Collection with List which is created with explicit size (reduce re-allocations when add new items).

PR Context

Test script:

measure-Command {
for ($i=0; $i -lt 500; $i++) {
    [runspace] $rs = [runspacefactory]::CreateRunspace()
    $rs.Open()
    $rs.Close()
    if ($null -ne $rs) { $rs.Dispose() }
}
}

Allocations before:
image

Allocations after:
image

PR Checklist

@iSazonov iSazonov added the CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log label Oct 16, 2019
@iSazonov iSazonov added this to the 7.0.0-preview.5 milestone Oct 16, 2019
@iSazonov iSazonov force-pushed the perf-create-runspace-1 branch from 575afb6 to 8f5c595 Compare October 21, 2019 12:04
@TravisEz13 TravisEz13 self-assigned this Oct 24, 2019
@TravisEz13
Copy link
Copy Markdown
Member

@daxian-dbw Can you review?

@daxian-dbw
Copy link
Copy Markdown
Member

This optimization has been done by my TypeTable change #10898, which as been merged. This PR can be closed now.

@daxian-dbw daxian-dbw closed this Nov 1, 2019
@iSazonov iSazonov deleted the perf-create-runspace-1 branch November 2, 2019 06:52
@daxian-dbw daxian-dbw removed this from the 7.0.0-preview.6 milestone Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants