Skip to content

Misc optimize#14

Merged
johnlanni merged 8 commits intohigress-group:envoy-1.27from
johnlanni:misc-optimize
Nov 11, 2025
Merged

Misc optimize#14
johnlanni merged 8 commits intohigress-group:envoy-1.27from
johnlanni:misc-optimize

Conversation

@johnlanni
Copy link
Copy Markdown

@johnlanni johnlanni commented Nov 11, 2025

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]


Note

Introduce xxhash-based cached protobuf Message hashing and use it across Envoy (listener/maps/config hashing), plus HIGRESS-specific fixes/features including WASM VM proactive rebuild, end_stream handling, new stats, and minor HTTP/redirect tweaks.

  • Protobuf/Build:
    • Add xxHash dependency and patch google::protobuf::Message with cached ComputeHashValue()/GetCachedHashValue().
    • Expose HashCachedMessageUtil and switch various hash/equality maps to it (e.g., FilterChainMatch, FilterChain, listener default FC comparison).
    • Use cached hashing for listener/config hashes (e.g., ListenerManagerImpl, RDS RouteConfig hashing).
  • HIGRESS/WASM:
    • Add WASM VM rebuild flow (PluginHandleSharedPtrThreadLocal::rebuild), new rebuild_total stat, lower recover interval, and filter-state trigger (wasm_need_rebuild).
    • Expose plugin_vm_memory property; tests for VM memory and proactive rebuild.
  • HTTP/Conn Manager/Filters:
    • Rename ALIMESH to HIGRESS in stats macros; add keep-alive header handling.
    • Ensure end_stream consistency when injecting data (set remote_decode_complete_/local_complete_).
    • Preserve downstream remote address on internal redirect recreation.
    • Header access fallback via StreamInfo when request headers pointer is null.
  • Custom Response Redirect:
    • Preserve original upstream cluster info and response code during internal redirects; set response code in StreamInfo.
  • Config/Stats:
    • Add GAUGE(last_update_success) to subscription stats; set in gRPC subscription (guarded by macro).
  • Tests:
    • Extensive tests for cached hashing (struct/list/any/nested), listener/protobuf size updates, WASM VM memory and rebuild scenarios.

Written by Cursor Bugbot for commit 45d3e7f. This will update automatically on new commits. Configure here.

jue-yin and others added 8 commits November 11, 2025 13:46
在protobuf::message中使用递归哈希以避免转为字符串的开销,加入哈希缓存机制以减少envoy listener manager多次hash时重复计算,该优化对大量filter chain的场景非常有效

Change-Id: I1eeea1121a11a91478750290a573c569e2a25727
Change-Id: Iff5ca5cccb4f63a15a499e1f5d8a7f98ab0131b5
Change-Id: Id81142e2f0a14e4d884fbaf0222f56255d87d907
…the initial status code and target service information.

Change-Id: I3e21b8a555f15adb85285006bfca643202ed67f7
Change-Id: I18431153fdc4d7b5b40ac1d7e10fe73240e2fa64
Change-Id: I247d12cc12c31f9e8d9e027d0f04af2fc37bf785
…rations

Change-Id: Ie0930f4f1de7501447c3a420b476379b8787bb1e
Change-Id: I787f124bb7b1b35d7b9fecfa8fe6261fd52f413f
@johnlanni johnlanni merged commit f16899c into higress-group:envoy-1.27 Nov 11, 2025
5 checks passed
@lingma-agents
Copy link
Copy Markdown

lingma-agents bot commented Nov 11, 2025

CodeReview流程已终止

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

#if defined(HIGRESS) && defined(ENVOY_ENABLE_FULL_PROTOS)
class HashCachedMessageUtil : public MessageUtil {
public:
bool operator()(const Protobuf::Message& message) const { return message.GetCachedHashValue(); }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Hash Functor Returns Wrong Type, Catastrophic Collisions

The hash functor operator() in HashCachedMessageUtil returns bool instead of std::size_t. When used as the hash template parameter in absl::node_hash_map and absl::flat_hash_map, this causes the hash value to be implicitly converted to bool (0 or 1), resulting in catastrophic hash collisions where all messages hash to either 0 or 1, breaking hash map functionality.

Fix in Cursor Fix in Web

} else if (test == "RebuildTest") {
if (!getRequestHeader("rebuild")->toString().empty()) {
logInfo("Setting rebuild flag");
setFilterState("wasm_rebuild", "true");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Silent Wasm Rebuild Failure

The filter state key "wasm_rebuild" doesn't match the constant WasmRebuildKey defined as "wasm_need_rebuild" in source/extensions/common/wasm/context.cc. This mismatch prevents the rebuild flag from being detected, causing the rebuild feature to silently fail in tests and production.

Fix in Cursor Fix in Web

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