GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Speedup InitialSessionState..cctor() by iSazonov · Pull Request #14283 · PowerShell/PowerShell Conversation
|
| // with no content. So create a scratch file and test on that. | ||
| string dtAppLockerTestFileContents = AppLockerTestFileContents + DateTime.Now; | ||
| string dtAppLockerTestFileContents = AppLockerTestFileContents + DateTime.UtcNow.Ticks; | ||
| IO.File.WriteAllText(testPathScript, dtAppLockerTestFileContents); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It seems the file name does not depend on the DateTime, but rather the file contents. So maybe we want to keep human date format
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The file is created for automatic testing - no humans see and read the file.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
no humans see and read the file.
Perhaps it is for debugging purposes.
Actually, if no humans see the file do we require the datetime to be written in any form at all?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I am only resolving the perf issue. I can only guess it is how AppLocker works. Perhaps Travis Plunk (@TravisEz13) or Paul Higinbotham (@PaulHigin) could add more information.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Travis Plunk (@TravisEz13) and Paul Higinbotham (@PaulHigin), can you please comment on whether we need DateTime to be added to the file content at all?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The DateTime was included to add some randomness to the file contents. I think we still need it, but could change it to some other random value if computing it is quicker than DateTime.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ilya (@iSazonov) Maybe replacing DateTime.Now.Ticks with Environemnt.TickCount?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Dongbo Wang (@daxian-dbw) I have no objections. I see Environment.TickCount64 - maybe use it?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That sounds fine to me, go ahead.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done. The PR description has been updated too.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // AppLocker fails when you try to check a policy on a file | ||
| // with no content. So create a scratch file and test on that. | ||
| string dtAppLockerTestFileContents = AppLockerTestFileContents + DateTime.Now; | ||
| string dtAppLockerTestFileContents = AppLockerTestFileContents + DateTime.UtcNow.Ticks; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| string dtAppLockerTestFileContents = AppLockerTestFileContents + DateTime.UtcNow.Ticks; | |
| string dtAppLockerTestFileContents = AppLockerTestFileContents + DateTime.UtcNow.ToString("u"); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I took real world measurements using PerfView 😋
It seems my suggested change is not much of an improvement, I measured 8ms for the code line.
I also measured the original code line and it was 14ms, same as your measurement.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
DateTime.UtcNow is more fast - it does not read current user time zone and does not convert to local time.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Is this a release build? Running a microbenchmark, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes, it is release build. And it is startup scenario - cold start (.Net runtime loads Calendar data from OS and initializes internal structures - you can see this in attached trace file.). If you run BenchmarkDotNet it is warm start. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🎉 Handy links: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… seed for AppLocker test file content (PowerShell#14283)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.