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

Put os.Stdin size to NewReaderSize instead NewReader #441

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IgorHalfeld
Copy link

@IgorHalfeld IgorHalfeld commented Jul 9, 2020

solves #439

In Golang NewReader, the default is 4069 for the Buffer size.
What I did was use NewReaderSize to put the Buffer size as the size of os.Stdin.
So it doesn't give that error of:

Error: failed to read input: bufio.Scanner: token too long

I changed ioutil.ReadAll (default size is 512) to .io.ReadFull too

@IgorHalfeld IgorHalfeld requested a review from a team as a code owner July 9, 2020 22:24
@codecov
Copy link

codecov bot commented Jul 9, 2020

Codecov Report

Merging #441 into master will increase coverage by 0.27%.
The diff coverage is 70.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #441      +/-   ##
==========================================
+ Coverage   30.89%   31.16%   +0.27%     
==========================================
  Files          26       26              
  Lines        3208     3215       +7     
==========================================
+ Hits          991     1002      +11     
+ Misses       2122     2117       -5     
- Partials       95       96       +1     
Impacted Files Coverage Δ
cmd/context.go 30.05% <70.37%> (+5.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6e83e7...de18f39. Read the comment docs.

@marcomorain
Copy link
Contributor

Hi @IgorHalfeld - thanks for the PR 🙏 we appreciate it.

Can you explain what the issue is here please? The issue that you have linked refers to a problem splitting test results, and this patch changes the function that reads contexts. Did you link to the wrong issue?

@IgorHalfeld
Copy link
Author

@marcomorain I updated the PR description

@IgorHalfeld
Copy link
Author

IgorHalfeld commented Jul 10, 2020

I fixed code coverage 🚀

IMHO I think you shouldn't use Ginkgo for testing, the Go standard test tool with Testify is the best choice for a number of factors, one of which is performance.

I used Ginkgo for 1 year and a half at work, and when we got to a large codebase we started having problems with test execution time.

@sibelius
Copy link

any plans to get this in?

it is breaking a lot of our circleci tests jobs

@sibelius
Copy link

any progress on this?

@Streeterxs
Copy link

Hope a merge soon. We have a lot of tests, fails a lot because of this

@jgcmarins
Copy link

Can we have this one merged?

@marcomorain
Copy link
Contributor

I'll get someone to review this today 👍

@sibelius
Copy link

sibelius commented Jul 8, 2021

what about today?

Copy link
Contributor

@kelvinkfli kelvinkfli left a comment

Choose a reason for hiding this comment

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

Thank you @IgorHalfeld, and apologies for the delay! I just had a few questions regarding this PR.

stat, _ := os.Stdin.Stat()

buffSize, err := os.Stdin.Stat()
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid the redundancy, would it be possible to remove this Stat() call and instead use the one on line 174?

Suggested change
buffSize, err := os.Stdin.Stat()
stat, err := os.Stdin.Stat()
if err != nil {
return "", err
}
reader := bufio.NewReaderSize(os.Stdin, int(stat.Size()))
// ...

Comment on lines -175 to +185
bytes, err := ioutil.ReadAll(os.Stdin)
bytes := make([]byte, buffSize.Size())
_, err := io.ReadFull(reader, bytes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you happen to experience errors other than failed to read input: bufio.Scanner: token too long from this code path?

I believe that ioutil.ReadAll will read the entire contents of the provided io.Reader without any limitations. It seems that '512' refers to the initial buffer size, which will dynamically grow until EOF/OOM occurs, so I'm not certain changing this to io.ReadFull will address that error specifically.

@corinnesollows
Copy link
Contributor

Merge conflicts need to be resolved. Context create was recently updated to accept OrgId

@wind57
Copy link

wind57 commented Jul 27, 2022

it seems we are hitting the same issue, and we have only? 653 tests to run, see here. Are there any plans to fix this? Or may be a workaround?

@corinnesollows
Copy link
Contributor

@wind57 @IgorHalfeld This PR is conflicting with master. The quickest solution is for a fresh PR to be made by an external contributor and we can look into it from there.
The longer solution is that we do have a ticket made for our team to fix this issue and when we have capacity we will look into it then. Thank you!

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

8 participants