Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the property disabling optimization #19701

Conversation

SeeminglyScience
Copy link
Collaborator

@SeeminglyScience SeeminglyScience commented May 23, 2023

PR Summary

NOTE: I'm mainly opening this PR to see if tests fail on any of the platforms we have CI for. If it does, that still tells us where to look.

  • Remove the property group that disabled optimization when building for non-Windows platforms
  • Set packing size on the UnixTm struct to match our native declaration
  • Add SetLastError to our p/invoke as libpsl-native!setdate does set errno (without this, I was getting "Unknown Error 203" when running Set-Date without sudo. With the change, it displays the expected error)

Resolves #19677

PR Context

PR Checklist

- Remove the property group that disabled optimization when building for
  non-Windows platforms
- Set packing size on the `UnixTm` struct to match our native
  declaration
- Add `SetLastError` to our p/invoke as libpsl-native!setdate does set
  `errno`
@ghost ghost assigned PaulHigin May 23, 2023
@daxian-dbw daxian-dbw added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 23, 2023
@pull-request-quantifier-deprecated

This PR has 11 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +2 -9
Percentile : 4.4%

Total files changed: 2

Change summary by file extension:
.props : +0 -7
.cs : +2 -2

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@iSazonov
Copy link
Collaborator

As remainder #6881 (comment)
My suggestion was to use stime API to avoid all these issues including ARM.

@SeeminglyScience
Copy link
Collaborator Author

As remainder #6881 (comment) My suggestion was to use stime API to avoid all these issues including ARM.

Is the issue you're referring to something else that also only occurs when optimization is off? Or is it a different thing we also need to fix in the same area? Asking because for this PR I'm mainly looking at getting optimization back on.

Side note, do you happen to know a good resource going in depth on the layout differences for ARM?

Copy link
Member

@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider backporting this to 7.3?

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iSazonov
Copy link
Collaborator

iSazonov commented May 25, 2023

As remainder #6881 (comment) My suggestion was to use stime API to avoid all these issues including ARM.

Is the issue you're referring to something else that also only occurs when optimization is off? Or is it a different thing we also need to fix in the same area? Asking because for this PR I'm mainly looking at getting optimization back on.

I pointed the issue to inform you about history. The reason for this problem for many years is that we use a complex structure when we might not. So stime uses time_t which is usually uint64 which does not require marshalling including ARM. (I haven't checked it since it hasn't been approved before.)

Side note, do you happen to know a good resource going in depth on the layout differences for ARM?

I didn't need to dive deep, so I just watched how it was done in the .Net Runtime.
If we continue to use this structure, we need to make sure that this alignment also works on ARM. An example of unpredictability https://stackoverflow.com/questions/5098864/struct-layout-on-wince-gives-unexpected-results That's why I thought of stime.

Stack Overflow
[StructLayout( LayoutKind.Explicit, Pack = 1, Size = 20 )] public struct StatusStruct { /// <summary> /// validation field /// </summary> [FieldOffset( 0 )] public I...

@kunalspathak
Copy link

Can you share any benchmark measurements to show how much improvements do we get on linux?

@ghost ghost added the Review - Needed The PR is being reviewed label Jun 1, 2023
@ghost
Copy link

ghost commented Jun 1, 2023

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@StevenBucher98 StevenBucher98 added the PowerShell-Docs not needed The PR was reviewed and doesn't appear to require a PowerShell Docs update label Jun 5, 2023
@daxian-dbw daxian-dbw removed the Review - Needed The PR is being reviewed label Jun 5, 2023
@daxian-dbw
Copy link
Member

It used to fail on macOS and according to @SeeminglyScience it worked this time. So, we will merge this PR and keep an eye on the release automation test run. If a failure happens there on a specific platform, that will tell us where to look.

@daxian-dbw daxian-dbw merged commit cc05fde into PowerShell:master Jun 5, 2023
@kunalspathak
Copy link

It used to fail on macOS and according to @SeeminglyScience it worked this time. So, we will merge this PR and keep an eye on the release automation test run. If a failure happens there on a specific platform, that will tell us where to look.

Did you get a chance to measure the improvements out of it?

@daxian-dbw
Copy link
Member

No, we didn't do measurement. But it should be faster and more efficient according to the documentation of this compiler option.

@SeeminglyScience
Copy link
Collaborator Author

Did you get a chance to measure the improvements out of it?

Not yet but I do plan to. Busy with some other tasks atm but when I get around to it I'll share in this thread

@ghost
Copy link

ghost commented Jun 29, 2023

🎉v7.4.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport-7.3.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Extra Small PowerShell-Docs not needed The PR was reviewed and doesn't appear to require a PowerShell Docs update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turn on optimization for non-windows
8 participants