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

Honor Concord's TruncatedString flag to reduce memory usage #68969

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

chuckries
Copy link
Contributor

Concord is going to begin limiting the amount of memory it pulls from the target process for strings. Any string result that has been truncated is marked with a new flag, such that APIs like GetUnderlyingString can still work for things like string visualizers in order to surface the full bytes of the string.

This adds concords new flag as a temporary constant and ensures that HasUnderlyingValue and GetUnderlyingValue both still work without pulling in the full string memory unnecessarily.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Interactive untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 10, 2023
@ghost ghost added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Jul 10, 2023
@chuckries
Copy link
Contributor Author

chuckries commented Jul 11, 2023

cc @isadorasophia, @gregg-miskelly

@gregg-miskelly
Copy link

    private string GetUnderlyingStringImpl(DkmClrValue value, DkmInspectionContext inspectionContext)

Same suggestion from the Concord code review: I think we need to set a flag in the inspection context to indicate we want large strings rather than changing EvaluateToString to always assume that.


Refers to: src/ExpressionEvaluator/Core/Source/ResultProvider/Formatter.Values.cs:216 in 238d264. [](commit_id = 238d264, deletion_comment = False)

@@ -253,7 +253,8 @@ private static DkmEvaluationResultFlags GetFlags(DkmClrValue value, DkmInspectio
}
}

if (!value.IsError() && value.HasUnderlyingString(inspectionContext))
// check for truncated string before HasUndleryingString so we don't pull the string into memory just to set the flag
if (!value.IsError() && ((value.EvalFlags & (DkmEvaluationResultFlags)DkmEvaluationResultFlagsExtensions.TruncatedStringFlag) != 0 || value.HasUnderlyingString(inspectionContext)))

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't HasUnderlyingString also check for TruncatedStringFlag when allocating the string?
(...does GetUnderlyingStringImpl call into GetValueString?)

@@ -253,7 +253,8 @@ private static DkmEvaluationResultFlags GetFlags(DkmClrValue value, DkmInspectio
}
}

if (!value.IsError() && value.HasUnderlyingString(inspectionContext))
// check for truncated string before HasUndleryingString so we don't pull the string into memory just to set the flag
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
// check for truncated string before HasUndleryingString so we don't pull the string into memory just to set the flag
// check for truncated string before HasUnderlyingString so we don't pull the string into memory just to set the flag

@chuckries chuckries requested a review from a team as a code owner July 21, 2023 21:28
@@ -253,7 +253,8 @@ private static DkmEvaluationResultFlags GetFlags(DkmClrValue value, DkmInspectio
}
}

if (!value.IsError() && value.HasUnderlyingString(inspectionContext))
// check for truncated string before HasUndleryingString so we don't pull the string into memory just to set the flag
if (!value.IsError() && (value.EvalFlags.HasFlag(DkmEvaluationResultFlags.TruncatedString) || value.HasUnderlyingString(inspectionContext)))

This comment was marked as resolved.

@chuckries
Copy link
Contributor Author

@tmat I believe this is ready to merge, although CI is very unhappy. Did I do something to upset CI or is this a known issue? The errors don't look like anything I've touched.

@chuckries chuckries force-pushed the dev/chuckr/LargeStrings branch 3 times, most recently from 166bcc8 to 94fd48e Compare July 28, 2023 23:10
@tmat tmat merged commit 6faeaaa into dotnet:main Jul 31, 2023
24 checks passed
@ghost ghost added this to the Next milestone Jul 31, 2023
@dibarbet dibarbet modified the milestones: Next, 17.8 P2 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interactive Community The pull request was submitted by a contributor who is not a Microsoft employee. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants