perf: introduce translator context#7535
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7535 +/- ##
==========================================
+ Coverage 72.34% 72.40% +0.05%
==========================================
Files 232 232
Lines 34209 34278 +69
==========================================
+ Hits 24749 24818 +69
- Misses 7681 7683 +2
+ Partials 1779 1777 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
wait #7534 |
|
/retest |
|
@kkk777-7 you might wanna merge the main branch to this branch to include the disk space cleaner. |
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
9527aa1 to
ce0cfcc
Compare
|
The gateway/internal/gatewayapi/resource/resource.go Lines 117 to 124 in 7cb5f72 |
This reverts commit 14a3784. Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
f9b5a6a to
3d4c714
Compare
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
|
Think out load: could we also add other resources(Namespace,Secret,ConfigMap, etc.) to the translator context to avoid linear lookups to improve CPU performance? This could increase memory usage - shouldn't be much increase since we just mirror the slices that already in resource using pointers, but we should benchmark both CPU and memory to ensure we don’t introduce significant overhead. |
we should do that. |
+1 |
|
|
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
f8b98e9 to
6461f2c
Compare
|
/retest |
|
@arkodg |
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
|
/retest |
|
Friendly ping @zirain @zhaohuabing |
* perf: introduce translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * perf: add policy map in translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * chore: update tranlate bench Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * Revert "perf: add policy map in translator context" This reverts commit 14a3784. Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * add translator context method, remove unused function Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update gatewayapi test output Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * add resources in translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * add gatewayapi translate bench Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * fix: set resources in translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * fix: go lint Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * address comments Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * feat: support egctl translate options Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update: bench test Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update embedded field Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * fix gatewayapi testdata output Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> --------- Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com> Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
* fix json report (#8614) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> * fix: deep copy status in translator layer to avoid race (#8778) Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> * chore: setup translator test (#7627) * chore: setup gatewayapi translator test Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * remove: duplicate resources in testfiles Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update gatewayapi test output Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> --------- Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> * perf: introduce translator context (#7535) * perf: introduce translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * perf: add policy map in translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * chore: update tranlate bench Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * Revert "perf: add policy map in translator context" This reverts commit 14a3784. Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * add translator context method, remove unused function Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update gatewayapi test output Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * add resources in translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * add gatewayapi translate bench Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * fix: set resources in translator context Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * fix: go lint Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * address comments Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * feat: support egctl translate options Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update: bench test Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update embedded field Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * fix gatewayapi testdata output Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> --------- Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com> Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> * fix gen-check Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Co-authored-by: Kota Kimura <86363983+kkk777-7@users.noreply.github.com> Co-authored-by: zirain <zirain2009@gmail.com>
What this PR does / why we need it:
Introduce Translator Context to improve GatewayAPI translator performance.
Now, Gateway API translator methods hold a lot of local maps to improve retrievals.
These can be all moved to a common preprocessing step, saved in the Translator context and reused across methods.
Also each resource is currently retrieved by performing a linear search over
resource.Resources.Therefore, for resources that are accessed frequently, maintaining a map is expected to improve CPU performance.
This PR's scope
Although the following items were initially considered, the improvements were minimal and would increase the complexity, so they were excluded from the scope. Ref : #7535 (comment)
Policy Target Gateway MapPolicy Target Route MapWhich issue(s) this PR fixes:
Fixes #6711
Release Notes: No
Benchmark Detail
gobench result
gatewayapi translator benchmark (vs latest main branch)