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

Snippet production #2629

Merged
merged 9 commits into from
Feb 28, 2023
Merged

Snippet production #2629

merged 9 commits into from
Feb 28, 2023

Conversation

michaelcfanning
Copy link
Member

We now create context region snippets that are restricted to 512 bytes in size. In the event that the original snippet is larger than this, we simply recapitulate that snippet in the log data (i.e., the context region is identical).

@michaelcfanning
Copy link
Member Author

Need a review asap on this. @suvamM @EasyRhinoMSFT @shaopeng-gh @yongyan-gh @HulonJenkins

@@ -164,6 +164,11 @@ public Region ConstructMultilineContextSnippet(Region inputRegion, Uri uri, stri
// Generating full inputRegion to prevent issues.
Region originalRegion = this.PopulateTextRegionProperties(inputRegion, uri, populateSnippet: true, fileText);

if (originalRegion.CharLength >= BIGSNIPPETLENGTH)
Copy link
Collaborator

@EasyRhinoMSFT EasyRhinoMSFT Feb 28, 2023

Choose a reason for hiding this comment

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

=

So 512 is considered big? I.e., the max is 511 #WontFix

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1. This should be >

Copy link
Member Author

Choose a reason for hiding this comment

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

why? if the size of the original region is as big as our bigsnippet maximum, why would attempt to generate it? what am i missing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was verifying that the max length is 511, since the >= operator excludes 512. This seems to be an off-by-one considering the statement that snippets are "restricted to 512 bytes in size"

@@ -745,8 +740,7 @@ public void FileRegionsCache_PopulatesWithOneLine_IncreasingToTheRight()
region = fileRegionsCache.PopulateTextRegionProperties(region, uri, true, content);
Region multilineRegion = fileRegionsCache.ConstructMultilineContextSnippet(region, uri);

// CharLength + 128 to the right = 428 characters
multilineRegion.CharLength.Should().Be(300 + 128);
multilineRegion.CharLength.Should().Be(512);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious, with the bug regarding > above, how does this test pass?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand the bug that you see. big snippet is defined as 512.

@suvamM
Copy link
Collaborator

suvamM commented Feb 28, 2023

Just wanted to comment on the fantastic PR description: brief and informative. Thanks @michaelcfanning

@@ -745,8 +740,7 @@ public void FileRegionsCache_PopulatesWithOneLine_IncreasingToTheRight()
region = fileRegionsCache.PopulateTextRegionProperties(region, uri, true, content);
Region multilineRegion = fileRegionsCache.ConstructMultilineContextSnippet(region, uri);

// CharLength + 128 to the right = 428 characters
multilineRegion.CharLength.Should().Be(300 + 128);
multilineRegion.CharLength.Should().Be(512);
Copy link

@schlaman-ms schlaman-ms Feb 28, 2023

Choose a reason for hiding this comment

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

And shouldn't that be a constant? #Resolved

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 to Craig's comment. We should have an Assume section in the test defining the constants.

Copy link
Member Author

Choose a reason for hiding this comment

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

We now pick it up from the product, good call.

@michaelcfanning
Copy link
Member Author

:)


In reply to: 1448659817

@michaelcfanning michaelcfanning merged commit 615a31a into main Feb 28, 2023
@michaelcfanning michaelcfanning deleted the snippet-production branch February 28, 2023 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants