pfelf: separate mmap reader from the underlying reader#1395
Merged
Conversation
This prepares pfelf for the upcoming removal of mmap suppport. To start with, the 'elfReader' is always the underlying original reader it was handed. The mmap is now attempted at open time if possible, and used if it succeeded. This will start reducing the RSS once the Prog/Section.Data() is no longer used. PR open-telemetry#1393 adds a new Underlying() method to access the data without the mmap together with few users. This PR should remove the temporary RSS spikes during scanning the large segments in that PR.
christos68k
approved these changes
May 4, 2026
| // Close closes the File. | ||
| func (f *File) Close() (err error) { | ||
| if f.mmapReader != nil { | ||
| f.mmapReader.Close() |
Member
There was a problem hiding this comment.
Shouldn't we set f.mmapReader to nil here? Maybe also combine all errors into one.
Contributor
Author
There was a problem hiding this comment.
mmapReader.Close() cannot return an actual error. I can add the explicit discard and comment. This will eventually go away when the removal of mmap is complete.
|
|
||
| if osFile, ok := r.(*os.File); ok { | ||
| // Attempt to mmap the file if possible | ||
| f.mmapReader, _ = mmap.OpenFile(osFile) |
Member
There was a problem hiding this comment.
Maybe add a log.Debugf here, wrapping the error with the filename (osFile.Name()) since we removed the filename from the source error
Contributor
Author
There was a problem hiding this comment.
This will eventually go away. The code is also able to handle things without mmap. So I'm not sure if its worth even a debug note.
Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
florianl
approved these changes
May 11, 2026
This was referenced May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This prepares pfelf for the upcoming removal of mmap suppport. To start with, the 'elfReader' is always the underlying original reader it was handed. The mmap is now attempted at open time if possible, and used if it succeeded.
This will start reducing the RSS once the Prog/Section.Data() is no longer used. PR #1393 adds a new Underlying() method to access the data without the mmap together with few users. This PR should remove the temporary RSS spikes during scanning the large segments in that PR.