-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes and simplifications for RequestSharing (#3086)
## Fixed Cache Size Metric The `RequestSharing` component was the prime suspect for a significant memory leak due to its metric displaying that the internal cache grows indefinitely. After wasting waaay too much time on this it appears that the metric simply has a bug. If somebody calls `shared_or_else()` and there is already an **outdated** `WeakShared` item in the cache that has not been removed by GC we'd: 1. build a new future 2. `insert()` it into the cache 3. increase the metrics for the cache size by 1 But in this specific edge case the `insert()` would actually overwrite an existing item in the cache and not add a new one so increasing the metrics by 1 is actually over counting the number of cached items. Over time this accumulated more and more and made it look like the component had a serious memory leak. The easy fix is to just not use `inc()` and `sub()` for adjusting the cache size metrics but rather `set(cache.len())` since that is absolutely fool proof. ## Removed 1 `RequestSharing` instance The `TradeEstimator` has a `RequestSharing` and contains a `TradeFinder` which also contains a `RequestSharing` instance. This double caching is overly complex and due to that I already suspected it 3 times that it might be related to a memory leak. Now only the `TradeFinder` uses `RequestSharing` which is the component that actually sends the HTTP requests.
- Loading branch information
1 parent
f808db2
commit 2a3c2a4
Showing
4 changed files
with
14 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ impl ExternalPriceEstimator { | |
timeout, | ||
)), | ||
rate_limiter, | ||
driver.to_string(), | ||
)) | ||
} | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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