Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Remove code which delete GUID from Progress, Verbose, Debug and Warning messages#18871

Merged
daxian-dbw merged 6 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
iSazonov:perf-progress-regexiSazonov/PowerShell:perf-progress-regexCopy head branch name to clipboard
Mar 13, 2023
Merged

Remove code which delete GUID from Progress, Verbose, Debug and Warning messages#18871
daxian-dbw merged 6 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
iSazonov:perf-progress-regexiSazonov/PowerShell:perf-progress-regexCopy head branch name to clipboard

Conversation

@iSazonov

@iSazonov iSazonov commented Dec 31, 2022

Copy link
Copy Markdown
Collaborator

PR Summary

Since nobody can find where GUID is added to a message we can remove RemoveGuidFromMessage and RemoveIdentifierInfoFromMessage methods and wait feedback. I guess it is not used for years (maybe it was in psworkflows?).
Notice, the methods are perf expensive since process every message by Regex.

See also #18871 (review)

PR Context

PR Checklist

@iSazonov iSazonov added the CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log label Dec 31, 2022
@iSazonov iSazonov self-assigned this Dec 31, 2022
@iSazonov iSazonov marked this pull request as ready for review December 31, 2022 16:39
@xtqqczze

xtqqczze commented Jan 2, 2023

Copy link
Copy Markdown
Contributor

As the the pattern is known at compile time, could we use a regular expression source generator?

Comment thread src/System.Management.Automation/engine/hostifaces/HostUtilities.cs Outdated
@iSazonov

iSazonov commented Jan 2, 2023

Copy link
Copy Markdown
Collaborator Author

As the the pattern is known at compile time, could we use a regular expression source generator?

We could. But first I would like to know where we create this prefix. If it's remoting only, it's probably not worth it.

return message;
}

const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:).*";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:).*";
const string pattern = @"^[\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:";

Remove the unnecessary capturing group and refactor:

message = message.Substring(matchResult.Length);`

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Eh, I don't know that is real format of the messages - perhaps we need the capture group.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like line 548 below uses the capture group. I would suggest replacing [\d\w] with [a-fA-F0-9] as \w is any alphanumeric character.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@SteveL-MSFT I mean line 548 can become message = message.Substring(matchResult.Length);

@iSazonov iSazonov changed the title Fast return if progress message does not start with GUID Fast return if progress and other messages don't start with GUID Jan 5, 2023
Comment thread src/System.Management.Automation/engine/hostifaces/HostUtilities.cs Outdated
@SteveL-MSFT

SteveL-MSFT commented Jan 7, 2023

Copy link
Copy Markdown
Member

I'm trying to find out why this was originally needed and if it's still needed at all. I was able to find a related methods called GetIdentifierInfo() that extracts the information and it has out parameters for jobInstanceId (the guid), and computerName. So it appears to be related to jobs and remoting. However, I haven't found in the source where it's actually being set.

@iSazonov

iSazonov commented Jan 7, 2023

Copy link
Copy Markdown
Collaborator Author

I see only AddSourceTagToError and CreateInformationalMessage.
Perhaps @PaulHigin can help.

@iSazonov iSazonov requested a review from anmenaga as a code owner January 7, 2023 06:35
@SteveL-MSFT

Copy link
Copy Markdown
Member

@PaulHigin confirmed that this is used by remoting/jobs to de-multiplex multi-sessions so that alleviates my concern if this is dead code.

@@ -499,21 +499,27 @@ internal static List<string> GetSuggestion(HistoryInfo lastHistory, object lastE
/// Remove the GUID from the message if the message is in the pre-defined format.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we update this comment to include:

Suggested change
/// Remove the GUID from the message if the message is in the pre-defined format.
/// Remove the GUID from the message (added by remoting/jobs for concurrent operations to be de-multiplexed) if the message is in the pre-defined format.

return message;
}

const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:).*";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since you're already updating this, perhaps we should change this regex a bit. Replace [\d\w] (which would accept any alphanumeric character making \d redundant anyways) to [a-fA-F0-9] to accept any hex digit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@PaulHigin Could you please point the code (for error and progress bar too) where we add the GUID? Can there be some GUIDs and should we use capture group?

return message;
}

const string pattern = @"^([\d\w]{8}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{4}\-[\d\w]{12}:\[.*\]:).*";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like line 548 below uses the capture group. I would suggest replacing [\d\w] with [a-fA-F0-9] as \w is any alphanumeric character.

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Jan 9, 2023
@ghost ghost added the Review - Needed The PR is being reviewed label Jan 17, 2023
@ghost

ghost commented Jan 17, 2023

Copy link
Copy Markdown

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

@PaulHigin PaulHigin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

To be honest I don't remember if/where Guids are added to remote information messages, or if they even are anymore. I seem to remember that in some cases they were added but, again, I cannot remember or find those cases in the code base. The RemoteData object contains all session routing information so I don't know why/when an information message would need a guid.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

I cannot find too. I guess it is not used for years. I suggest to delete the code (RemoveIdentifierInfoFromMessage and RemoveGuidFromMessage) and wait feedbacks while we are at preview time.

@ghost ghost removed the Review - Needed The PR is being reviewed label Feb 17, 2023
@ghost ghost added the Review - Needed The PR is being reviewed label Feb 24, 2023
@ghost

ghost commented Feb 24, 2023

Copy link
Copy Markdown

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

@daxian-dbw daxian-dbw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@xtqqczze

Copy link
Copy Markdown
Contributor

Since you're already updating this, perhaps we should change this regex a bit. Replace [\d\w] (which would accept any alphanumeric character making \d redundant anyways) to [a-fA-F0-9] to accept any hex digit.

I suggest making these changes for clarity reasons.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

I cannot find too. I guess it is not used for years. I suggest to delete the code (RemoveIdentifierInfoFromMessage and RemoveGuidFromMessage) and wait feedbacks while we are at preview time.

@daxian-dbw What do you think about the proposal?

@ghost ghost removed the Review - Needed The PR is being reviewed label Feb 25, 2023
@daxian-dbw

Copy link
Copy Markdown
Member

I cannot find too. I guess it is not used for years. I suggest to delete the code (RemoveIdentifierInfoFromMessage and RemoveGuidFromMessage) and wait feedbacks while we are at preview time.

@daxian-dbw What do you think about the proposal?

That sounds good to me :)

@pull-request-quantifier-deprecated

Copy link
Copy Markdown

This PR has 29 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       : +0 -29
Percentile : 11.6%

Total files changed: 2

Change summary by file extension:
.cs : +0 -29

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.

@xtqqczze

xtqqczze commented Feb 28, 2023

Copy link
Copy Markdown
Contributor

@iSazonov Please update issue title before merge.

@daxian-dbw daxian-dbw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. As @xtqqczze reminded, please update the PR title and description before merging. Thanks!
Oh, please refer to Paul's comment #18871 (review) in the PR description for context information.

@daxian-dbw daxian-dbw added CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log and removed CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log labels Mar 1, 2023
@iSazonov iSazonov changed the title Fast return if progress and other messages don't start with GUID Remove code which delete GUID from Progress, Verbose, Debug and Warning messages Mar 1, 2023
@iSazonov

iSazonov commented Mar 1, 2023

Copy link
Copy Markdown
Collaborator Author

Done.

@daxian-dbw

Copy link
Copy Markdown
Member

@SteveL-MSFT Please take another look when you get a chance. Thanks!

@ghost ghost added the Review - Needed The PR is being reviewed label Mar 9, 2023
@ghost

ghost commented Mar 9, 2023

Copy link
Copy Markdown

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

@iSazonov

iSazonov commented Mar 9, 2023

Copy link
Copy Markdown
Collaborator Author

@SteveL-MSFT Friendly ping.

@ghost ghost removed the Review - Needed The PR is being reviewed label Mar 9, 2023
@daxian-dbw daxian-dbw merged commit 9dd9322 into PowerShell:master Mar 13, 2023
@iSazonov iSazonov deleted the perf-progress-regex branch March 14, 2023 03:51
@ghost

ghost commented Mar 14, 2023

Copy link
Copy Markdown

🎉v7.4.0-preview.2 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

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log Extra Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.