Commit 4c47e09
committed
fix: revert broken recommendation caching causing latency spike
The caching implementation introduced in c1d42f4 contains a critical bug:
on every cache miss, the loop `ids_to_add.extend(cached_ids)` causes
exponential growth of the ids_to_add list (O(n^2) per product), which
rapidly inflates cached_ids to millions of entries. This causes extreme
memory pressure and CPU time, resulting in latency spikes from ~5ms to
400ms+ on /oteldemo.RecommendationService/ListRecommendations.
Reverts the caching logic and restores the original direct catalog call.1 parent c1d42f4 commit 4c47e09
1 file changed
Lines changed: 2 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 40 | | |
45 | 41 | | |
46 | 42 | | |
| |||
67 | 63 | | |
68 | 64 | | |
69 | 65 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | 66 | | |
96 | 67 | | |
97 | 68 | | |
| |||
101 | 72 | | |
102 | 73 | | |
103 | 74 | | |
104 | | - | |
| 75 | + | |
| 76 | + | |
105 | 77 | | |
106 | 78 | | |
107 | 79 | | |
| |||
0 commit comments