[Bugfix] Fix memory leak and broken metrics in UCMBlendConnector#904
Open
SuperMarioYL wants to merge 1 commit intoModelEngine-Group:developfrom
Open
Conversation
Contributor
Author
|
The CI failure in |
Two functional bugs in the blend connector: 1. Memory leak: requests_blend_meta is never cleaned up for finished requests. build_connector_meta pops from self.requests_meta but not from self.requests_blend_meta, causing unbounded growth proportional to the total number of completed requests. Each entry holds BlendRequestMeta with block hashes and chunk metadata, so this is not trivial in long-running serving scenarios. 2. Broken metrics: self.monitor.update_stats() references an undefined attribute. The parent class UCMDirectConnector uses the module-level ucmmetrics.update_stats() API, but the blend connector calls self.monitor which does not exist, causing AttributeError on any blend request with metrics enabled. Signed-off-by: supermario_leo <leo.stack@outlook.com>
3bbe2d1 to
91aa440
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fix two functional bugs in
UCMBlendConnectorthat affect production serving reliability.Modifications
Bug 1:
requests_blend_metamemory leakbuild_connector_metacleans upself.requests_metafor finished requests (line 466) but never cleans upself.requests_blend_meta. Sinceget_num_new_matched_tokensadds an entry torequests_blend_metafor every request (line 399), this dict grows unboundedly for the lifetime of the process.Each
BlendRequestMetaholds block hashes,ChunkMetaDataobjects, and stage info, so in long-running serving scenarios the memory impact is significant.Fix: Add
self.requests_blend_meta.pop(request_id, None)alongside the existing cleanup.Bug 2:
self.monitorAttributeError crashes metrics pathWhen
self.metrics_configis enabled, the blend connector callsself.monitor.update_stats("ConnStats", {...})(line 386). However,self.monitoris never defined — the parent classUCMDirectConnectoruses the module-levelucmmetrics.update_stats({...})API instead.This means any blend request with metrics enabled raises
AttributeError: 'UCMBlendConnector' object has no attribute 'monitor'.Fix: Replace
self.monitor.update_stats(...)withucmmetrics.update_stats(...)to match the parent class pattern.Test
black --checkandisort --check --profile=blackpass on the modified file.