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

golang seems to think 4gb is a 'huge buffer' #21

Merged
merged 2 commits into from
Oct 21, 2015
Merged

golang seems to think 4gb is a 'huge buffer' #21

merged 2 commits into from
Oct 21, 2015

Conversation

dt
Copy link
Contributor

@dt dt commented Oct 21, 2015

ioutil.ReadFile won't pre-alloc a buffer of size > 1gb (excepted from ioutil.go):

      // Don't preallocate a huge buffer, just in case.
      if size := fi.Size(); size < 1e9 {

(from https://golang.org/src/io/ioutil/ioutil.go?s=1464:1510#L60 )

Thus reading a 4gb hfile results in 8gb alloc'ed while growing the buffer.

@dt
Copy link
Contributor Author

dt commented Oct 21, 2015

cc @paperstreet

ioutil.ReadFile won't pre-alloc a buffer of size > 1gb (excepted from ioutil.go):

  // Don't preallocate a huge buffer, just in case.
  if size := fi.Size(); size < 1e9 {

(from https://golang.org/src/io/ioutil/ioutil.go?s=1464:1510#L60 )

Thus reading a 4gb hfile results in 8gb alloc'ed while growing the buffer.
@dt dt assigned theevocater and unassigned surajacharya Oct 21, 2015
theevocater added a commit that referenced this pull request Oct 21, 2015
golang seems to think 4gb is a 'huge buffer'
@theevocater theevocater merged commit 685ab85 into foursquare:master Oct 21, 2015
@dt dt deleted the dt.readall branch October 23, 2015 12: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.

3 participants