Skip to content

filebeat/filestream: Use gzip.Reader.Reset instead of Close+NewReader#48516

Merged
orestisfl merged 1 commit intoelastic:mainfrom
orestisfl:filestream-gzip-reset-optimization
Jan 23, 2026
Merged

filebeat/filestream: Use gzip.Reader.Reset instead of Close+NewReader#48516
orestisfl merged 1 commit intoelastic:mainfrom
orestisfl:filestream-gzip-reset-optimization

Conversation

@orestisfl
Copy link
Contributor

Proposed commit message

filebeat/filestream: Use gzip.Reader.Reset instead of Close+NewReader

Replace the pattern of closing the gzip reader and creating a new one with a call to gzip.Reader.Reset() in gzipSeekerReader.Seek().

Reset() is the idiomatic way to reuse a gzip reader when switching to a new underlying reader. It:

  • Reuses internal buffers instead of allocating new ones, reducing memory pressure and GC overhead
  • Is semantically equivalent to creating a new reader (discards current state and reinitializes)
  • Eliminates the unnecessary Close() call whose error was being ignored anyway

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

How to test this PR locally

Run the gzip-related unit and integration tests

Related issues

@orestisfl orestisfl requested a review from AndersonQ January 23, 2026 09:05
@orestisfl orestisfl self-assigned this Jan 23, 2026
@orestisfl orestisfl requested a review from a team as a code owner January 23, 2026 09:05
@orestisfl orestisfl added the backport-skip Skip notification from the automated backport with mergify label Jan 23, 2026
@orestisfl orestisfl requested a review from leehinman January 23, 2026 09:05
@orestisfl orestisfl added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team skip-changelog labels Jan 23, 2026
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@github-actions
Copy link
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jan 23, 2026
@botelastic
Copy link

botelastic bot commented Jan 23, 2026

This pull request doesn't have a Team:<team> label.

Replace the pattern of closing the gzip reader and creating a new one with a call to gzip.Reader.Reset() in gzipSeekerReader.Seek().

`Reset()` is the idiomatic way to reuse a gzip reader when switching to a new underlying reader. It:
- Reuses internal buffers instead of allocating new ones, reducing memory pressure and GC overhead
- Is semantically equivalent to creating a new reader (discards current state and reinitializes)
- Eliminates the unnecessary `Close()` call whose error was being ignored anyway
@orestisfl orestisfl force-pushed the filestream-gzip-reset-optimization branch from d0899c2 to 078f098 Compare January 23, 2026 09:07
@orestisfl orestisfl merged commit 027a84b into elastic:main Jan 23, 2026
19 checks passed
@orestisfl orestisfl deleted the filestream-gzip-reset-optimization branch January 23, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip Skip notification from the automated backport with mergify cleanup skip-changelog Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants