{"action":"created","issue":{"url":"https://api.github.com/repos/puppetlabs/puppetlabs-dsc/issues/165","labels_url":"https://api.github.com/repos/puppetlabs/puppetlabs-dsc/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/puppetlabs/puppetlabs-dsc/issues/165/comments","events_url":"https://api.github.com/repos/puppetlabs/puppetlabs-dsc/issues/165/events","html_url":"https://github.com/puppetlabs/puppetlabs-dsc/pull/165","id":124304375,"number":165,"title":"(MODULES-2709) Reuse PowerShell instance for DSC","user":{"login":"Iristyle","id":394081,"avatar_url":"https://avatars.githubusercontent.com/u/394081?v=3","gravatar_id":"","url":"https://api.github.com/users/Iristyle","html_url":"https://github.com/Iristyle","followers_url":"https://api.github.com/users/Iristyle/followers","following_url":"https://api.github.com/users/Iristyle/following{/other_user}","gists_url":"https://api.github.com/users/Iristyle/gists{/gist_id}","starred_url":"https://api.github.com/users/Iristyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Iristyle/subscriptions","organizations_url":"https://api.github.com/users/Iristyle/orgs","repos_url":"https://api.github.com/users/Iristyle/repos","events_url":"https://api.github.com/users/Iristyle/events{/privacy}","received_events_url":"https://api.github.com/users/Iristyle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-30T05:00:56Z","updated_at":"2016-01-06T08:45:11Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppetlabs-dsc/pulls/165","html_url":"https://github.com/puppetlabs/puppetlabs-dsc/pull/165","diff_url":"https://github.com/puppetlabs/puppetlabs-dsc/pull/165.diff","patch_url":"https://github.com/puppetlabs/puppetlabs-dsc/pull/165.patch"},"body":" - Currently, each time a resource modification is made, the PowerShell\r\n   provider opens up new powershell.exe instance(s), makes a single\r\n   Invoke-DscResource call, then terminates.\r\n\r\n   This is a particularly expensive endeavor, since each resource\r\n   requires a minimum of one powershell.exe instance for the sake of\r\n   using Test to examine if the DSC resource is in the desired state. If\r\n   a resource needs to be added / removed / modified via the Set method\r\n   of Invoke-DscResource, then an additional instance is required.\r\n\r\n   With the working set and slow startup times of powershell.exe this\r\n   is a particularly expensive cost to pay per run.\r\n\r\n - Add a new PowerShellManager class that supports reuse of an initially\r\n   created powershell.exe instance.  Modify the PowerShell provider to\r\n   use this helper class instead of running powershell.exe on demand.\r\n\r\n   In simple tests, this significantly (by a factor or 2x or more)\r\n   reduces the runtime of a manifest.\r\n\r\n - The PowerShellManager class uses popen2 since the PowerShell template\r\n   currently handles capturing Invoke-DscResource errors and propagating\r\n   them through the JSON that is returned to Ruby.  Therefore, ignore\r\n   stderr stream.  In other exploratory work, there was difficulty in\r\n   getting stderr to be read from properly - in such instances, the\r\n   IO.select call over stderr determined that the stream was readable,\r\n   but the subsequent call to stderr.gets would block, and deadlock. Its\r\n   presumed that this is a problem specifically with Ruby on Windows, or\r\n   with capturing stderr from powershell.exe - but the exact cause has\r\n   not yet been determined."},"comment":{"url":"https://api.github.com/repos/puppetlabs/puppetlabs-dsc/issues/comments/169268202","html_url":"https://github.com/puppetlabs/puppetlabs-dsc/pull/165#issuecomment-169268202","issue_url":"https://api.github.com/repos/puppetlabs/puppetlabs-dsc/issues/165","id":169268202,"user":{"login":"Iristyle","id":394081,"avatar_url":"https://avatars.githubusercontent.com/u/394081?v=3","gravatar_id":"","url":"https://api.github.com/users/Iristyle","html_url":"https://github.com/Iristyle","followers_url":"https://api.github.com/users/Iristyle/followers","following_url":"https://api.github.com/users/Iristyle/following{/other_user}","gists_url":"https://api.github.com/users/Iristyle/gists{/gist_id}","starred_url":"https://api.github.com/users/Iristyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Iristyle/subscriptions","organizations_url":"https://api.github.com/users/Iristyle/orgs","repos_url":"https://api.github.com/users/Iristyle/repos","events_url":"https://api.github.com/users/Iristyle/events{/privacy}","received_events_url":"https://api.github.com/users/Iristyle/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T08:45:10Z","updated_at":"2016-01-06T08:45:10Z","body":"@puppetlabs/windows this needs some tests, etc... but works now after changing from `mutex` to `event`"}}