Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

compress qlogs when the QUIC connection is closed #193

Merged
merged 2 commits into from
Feb 12, 2021

Conversation

marten-seemann
Copy link
Collaborator

Fixes #191. Fixes #192.

I hate that we to make this change, but I don't see any other solution. Compression algorithms keep a lot of internal state, so we shouldn't have too many of them running in parallel. This was already an issue when using gzip (see #192), which got exacerbated by using zstd.

The alternative is to use the file system as a buffer: We qlog into a temporary file .<name>.qlog.swp. Once the QUIC connection is closed, we compress that file to <name>.qlog.zst.

tracer.go Outdated
if err := l.f.Close(); err != nil {
return err
}
if err := os.Remove(l.f.Name()); err != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Isn't this error handling beautiful? 🤢

@marten-seemann
Copy link
Collaborator Author

Seems to work:
Screen Shot 2021-02-11 at 18 07 28

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

General idea SGTM, but I want to make sure close always closes, even if we start running out of space etc.

WriteCloser: newBufferedWriteCloser(bufio.NewWriter(gz), gz),
f: f,
filename: finalFilename,
Writer: bufio.NewWriter(f),
}
}

func (l *qlogger) Close() error {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some defers for closing/deleting here? Ideally, close would return after closing everything, even if something fails along the way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, although using defer means that we won't be able to handle the error (without adding a ton of boilerplate code).

Copy link
Member

Choose a reason for hiding this comment

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

A helper Compress function to compress/copy would help a bit. Also, you may find https://pkg.go.dev/go.uber.org/multierr#Append useful.

But I don't care strongly any which way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's ok that we're ignoring the error here. If closing the file fails, there's really nothing we can do about it anyway.

@marten-seemann marten-seemann force-pushed the deferred-qlog-compression branch 3 times, most recently from baa1bb1 to 40fecb3 Compare February 12, 2021 05:38
@marten-seemann marten-seemann merged commit b3d6573 into master Feb 12, 2021
@marten-seemann marten-seemann deleted the deferred-qlog-compression branch February 13, 2021 02:34
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

qlog compression is a memory hog zstd memory consumption kills nodes
2 participants