Skip to content

Conversation

abrarsheikh
Copy link
Contributor

@abrarsheikh abrarsheikh commented Jul 3, 2025

__getitem__ on headers is a O(n) operation. Optimize the code to cut out the extra loop.

@abrarsheikh abrarsheikh added the go add ONLY when ready to merge, run all tests label Jul 3, 2025
@abrarsheikh abrarsheikh marked this pull request as ready for review July 3, 2025 23:16
@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 23:16
@abrarsheikh abrarsheikh requested a review from a team as a code owner July 3, 2025 23:16
@abrarsheikh abrarsheikh requested a review from zcin July 3, 2025 23:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes header handling by cutting out an extra loop over headers, consolidating existence check and retrieval into a single operation.

  • Uses headers.get to check for and retrieve the request ID in one pass.
  • Generates and appends a new request ID only when it's missing.

Signed-off-by: abrar <[email protected]>
@zcin zcin merged commit cc5a8ca into master Jul 7, 2025
5 checks passed
@zcin zcin deleted the SERVE-886-abrar-header_req_id_middleware branch July 7, 2025 17:31
ccmao1130 pushed a commit to ccmao1130/ray that referenced this pull request Jul 29, 2025
…54326)

`__getitem__` on headers is a O(n) operation. Optimize the code to cut
out the extra loop.

---------

Signed-off-by: abrar <[email protected]>
Signed-off-by: ChanChan Mao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants