Skip to content

Return an error early if header list is overrun#912

Closed
IgorBelyi wants to merge 1 commit into
hyperium:masterfrom
IgorBelyi:shortcut-header-list-oversize
Closed

Return an error early if header list is overrun#912
IgorBelyi wants to merge 1 commit into
hyperium:masterfrom
IgorBelyi:shortcut-header-list-oversize

Conversation

@IgorBelyi

@IgorBelyi IgorBelyi commented Jun 11, 2026

Copy link
Copy Markdown

I've ran into a problem that excessive headers still consume CPU even after condition of exceeding max_header_list_size is detected. This PR is a proposed fix for that problem. It allows closure passed into Decoder::decode() to report that it won't be accepting any more headers thus allowing decoder to return earlier skipping unnecessary memory allocations. I did verify locally that CPU overrun is addressed with this change.

@IgorBelyi

Copy link
Copy Markdown
Author

Ok, looking into the test failures. Didn't realize there's more than just cargo test.

@IgorBelyi IgorBelyi force-pushed the shortcut-header-list-oversize branch from 922e5c7 to 6a48c58 Compare June 11, 2026 20:01
Comment thread src/hpack/decoder.rs
) -> Result<(), DecoderError>
where
F: FnMut(Header),
F: FnMut(Header) -> bool,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think returning a bool can be somewhat confusing, both for the calling (do I return true or false), and when it's used (what does that if mean again).

I'd suggest either using ControlFlow, or a Result. I think. What do you think of that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I was trying to stick with smallest change possible but ControlFlow indeed makes sense. Will switch.

Comment thread src/hpack/decoder.rs
false
}
} {
break;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the effects of skipping the rest? Does it the table get out of sync?

Would it safer to have some heuristic that just says, "oversize by some we'll just ignore and reset you, but oversize by double (or whatever) and we'll GOAWAY your connection, you bad bad peer"?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not sure about that. Will need to take a closer look at how it fits into global flow. I was trusting tests to catch anything fishy and just wanted to improve performance to skip unnecessary code.

@IgorBelyi

Copy link
Copy Markdown
Author

Closing in favor of a better thought through #915

@IgorBelyi IgorBelyi closed this Jun 13, 2026
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.

2 participants