Skip to content

Lazy load request/response bodies fixes #50 #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2025

Conversation

chirino
Copy link
Collaborator

@chirino chirino commented Jun 2, 2025

commit 6dca5a0 (HEAD -> lazy-loading, chirino/lazy-loading)
Author: Hiram Chirino hiram@hiramchirino.com
Date: Mon Jun 2 16:22:20 2025 -0400

feat: implement lazy response body loading for improved memory efficiency

• Add HttpResponseBody class for lazy response body management with supplier-based loading
• Add deferred loading mechanism - response body only loaded when WASM modules access it
• Fix request body processing logic to properly handle early returns for non-body plugins
• Update response header filtering logic to skip unnecessary processing when no body handling needed

This implementation extends the existing lazy request body loading concept to response bodies,
providing significant memory and performance improvements. The lazy loading mechanism ensures
response bodies are only read from the output stream when WASM plugins actually call
proxy_get_buffer_bytes to access the data. This prevents unnecessary memory allocation and
I/O operations for plugins that process headers but don't need response body content, while
maintaining full backward compatibility with existing plugin implementations.

Signed-off-by: Hiram Chirino <hiram@hiramchirino.com>

commit 4bb0309
Author: Hiram Chirino hiram@hiramchirino.com
Date: Mon Jun 2 14:44:22 2025 -0400

refactor: implement lazy request body loading with dedicated HttpRequestBody class

• Created new HttpRequestBody class to encapsulate lazy loading logic and state
• Refactored PluginHttpContext to use HttpRequestBody instead of managing state directly
• Updated ProxyWasmFilter to use shared HttpRequestBody instance across plugins
• Improved request body processing loop with proper action handling
• Enhanced type safety by removing Object-based field types
• Moved body state management from context to dedicated supplier class

This refactoring addresses memory efficiency concerns by only loading request bodies
when WASM modules actually access them via proxy_get_buffer_bytes.

Signed-off-by: Hiram Chirino <hiram@hiramchirino.com>

chirino added 2 commits June 2, 2025 16:51
…estBody class

• Created new HttpRequestBody class to encapsulate lazy loading logic and state
• Refactored PluginHttpContext to use HttpRequestBody instead of managing state directly
• Updated ProxyWasmFilter to use shared HttpRequestBody instance across plugins
• Improved request body processing loop with proper action handling
• Enhanced type safety by removing Object-based field types
• Moved body state management from context to dedicated supplier class

This refactoring addresses memory efficiency concerns by only loading request bodies
when WASM modules actually access them via proxy_get_buffer_bytes.

Signed-off-by: Hiram Chirino <hiram@hiramchirino.com>
…ency

• Add HttpResponseBody class for lazy response body management with supplier-based loading
• Add deferred loading mechanism - response body only loaded when WASM modules access it
• Fix request body processing logic to properly handle early returns for non-body plugins
• Update response header filtering logic to skip unnecessary processing when no body handling needed

This implementation extends the existing lazy request body loading concept to response bodies,
providing significant memory and performance improvements. The lazy loading mechanism ensures
response bodies are only read from the output stream when WASM plugins actually call
proxy_get_buffer_bytes to access the data. This prevents unnecessary memory allocation and
I/O operations for plugins that process headers but don't need response body content, while
maintaining full backward compatibility with existing plugin implementations.

Signed-off-by: Hiram Chirino <hiram@hiramchirino.com>
@chirino chirino merged commit a8fdf7e into roastedroot:main Jun 2, 2025
9 of 10 checks passed
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.

1 participant