Import-Module Jump-Location slows down powershell 5 times on burning console benchmark #17

Closed
vors opened this Issue Sep 18, 2014 · 6 comments

Comments

Projects
None yet
3 participants
@vors
Collaborator

vors commented Sep 18, 2014

Benchmark: http://www.leeholmes.com/blog/2005/12/18/burn-console-optimized-and-ready-for-marshmallows/

Drops from 54 fps to 10 fps

This most likely totally related to using break-point on $pwd for tracking directory changes. We need to find a better way to achieve same thing.

@tkellogg

This comment has been minimized.

Show comment
Hide comment
@tkellogg

tkellogg Sep 18, 2014

Owner

yeah, I got the $pwd trick from some PowerShell experts off of Stack Overflow. If there's a newer/better way to do it, I'm all ears.

Owner

tkellogg commented Sep 18, 2014

yeah, I got the $pwd trick from some PowerShell experts off of Stack Overflow. If there's a newer/better way to do it, I'm all ears.

@tkellogg

This comment has been minimized.

Show comment
Hide comment
@tkellogg

tkellogg Sep 19, 2014

Owner

I thought about this last night while I wasn't sleeping and remembered this line:

https://github.com/tkellogg/Jump-Location/blob/master/Jump.Location/CommandController.cs#L82

I believe the Thread.Sleep(10) is probably too short. Raise it to like 100 or 1000 or something.

Owner

tkellogg commented Sep 19, 2014

I thought about this last night while I wasn't sleeping and remembered this line:

https://github.com/tkellogg/Jump-Location/blob/master/Jump.Location/CommandController.cs#L82

I believe the Thread.Sleep(10) is probably too short. Raise it to like 100 or 1000 or something.

@vors

This comment has been minimized.

Show comment
Hide comment
@vors

vors Sep 19, 2014

Collaborator

I don't think that's the reason. @lzybkr (author of PSReadLine and a lot of PS internals) pointed out the problem with Set-PSBreakpoint: it turns off optimizations. I will work on it on weekend. Changing hook from BP to prompt will also solve #15. You remember, prompt was the second suggestion on the original stackoverflow question =) http://stackoverflow.com/questions/11788133/how-to-detect-how-long-a-user-stays-in-one-location-in-powershell/11813545#11813545

Collaborator

vors commented Sep 19, 2014

I don't think that's the reason. @lzybkr (author of PSReadLine and a lot of PS internals) pointed out the problem with Set-PSBreakpoint: it turns off optimizations. I will work on it on weekend. Changing hook from BP to prompt will also solve #15. You remember, prompt was the second suggestion on the original stackoverflow question =) http://stackoverflow.com/questions/11788133/how-to-detect-how-long-a-user-stays-in-one-location-in-powershell/11813545#11813545

@vors

This comment has been minimized.

Show comment
Hide comment
@vors

vors Sep 21, 2014

Collaborator

Remark: #24 doesn't exactly solve #15.
It solves motivation scenario (POSH git + Jump-Location) for #15.

Collaborator

vors commented Sep 21, 2014

Remark: #24 doesn't exactly solve #15.
It solves motivation scenario (POSH git + Jump-Location) for #15.

@vors vors self-assigned this Sep 22, 2014

@oising

This comment has been minimized.

Show comment
Hide comment
@oising

oising Sep 23, 2014

Here's another way to monitor the $pwd variable:

PS C:\local> $n = 0; (gv pwd).attributes.Add((new-object ValidateScript { $global:n++; $true }))
PS C:\local> $n
1
PS C:\local> $n
1
PS C:\local> cd poke
PS C:\local\poke> $n
2

If you want to do this programmatically with a custom attribute, derive from the argument transformation attribute. Obviously I'm not saying use global variables to track state, but this is just a demonstration of how the script is only invoked when $pwd changes.

oising commented Sep 23, 2014

Here's another way to monitor the $pwd variable:

PS C:\local> $n = 0; (gv pwd).attributes.Add((new-object ValidateScript { $global:n++; $true }))
PS C:\local> $n
1
PS C:\local> $n
1
PS C:\local> cd poke
PS C:\local\poke> $n
2

If you want to do this programmatically with a custom attribute, derive from the argument transformation attribute. Obviously I'm not saying use global variables to track state, but this is just a demonstration of how the script is only invoked when $pwd changes.

@vors

This comment has been minimized.

Show comment
Hide comment
@vors

vors Sep 23, 2014

Collaborator

@oising that's a great trick! Thank you for sharing it.
I also trying to address Scott's scenario with posh-git #15, so OnIdle seems more appropriate for that. It will not track anything inside the scripts.

Collaborator

vors commented Sep 23, 2014

@oising that's a great trick! Thank you for sharing it.
I also trying to address Scott's scenario with posh-git #15, so OnIdle seems more appropriate for that. It will not track anything inside the scripts.

@vors vors closed this in #24 Sep 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment