lizhimins opened a new pull request, #6691:
URL: https://github.com/apache/rocketmq-dashboard/pull/6691

   ### Motivation
   
   `GET /api/instances` resolved topic/group counts for every caller, which 
costs two remote
   OpenAPI calls per cloud instance. With 11 cloud instances configured the 
endpoint took
   1.5-3.0s (measured against a deployed studio), and because instance-scoped 
pages derive
   their selected instance from that list, they serialized their own data 
request behind it:
   the topic page rendered its first row after 3121ms and the consumer group 
page after
   1957ms, while `/api/topics/page` and `/api/groups/page` themselves answered 
in 17-27ms.
   
   ### Modification
   
   - `listInstances` gains a `withCounts` flag (query param, default false). 
Without it the
     counts are marked `resourceCountsAvailable=false` instead of reporting a 
plausible zero,
     so no consumer can mistake "not requested" for "measured 0". The instance 
list page is
     the only view that displays counts, so it is the only caller that opts in.
   - `docs/api-spec.md` documents the parameter and the three count fields' 
semantics.
   - The instance selector trusts the instance named in the route before the 
list lands, so
     pages fetch their own data immediately; an unknown route id still falls 
back to the first
     instance and rewrites the route, as before.
   - The "no instance selected" spinner moves into its own effect, so the list 
resolving no
     longer re-runs the load effect and asks the backend for the identical page 
a second time.
   
   ### Measured after the change (Chromium, real CJK fonts, 1600px viewport, 
deployed studio)
   
   | metric | before | after |
   |---|---|---|
   | topic page first row | 3121ms | 544ms |
   | group page first row | 1957ms | 370ms |
   | `/api/instances` | 1.5-3.0s | 10-22ms |
   | list requests per page view | 1 (but late) | 1 (early) |
   
   ### Test plan
   
   - [x] Backend: `InstanceServiceTest` + `InstanceControllerTest` (112 tests) 
incl. a case
     asserting the provider registry is never touched without `withCounts`.
   - [x] Frontend: full suite 159 files / 1622 tests; new hook test pins "route 
instance is
     selected while the list is still loading and the selector never asks for 
counts".
   - [x] Deployed to a test machine and re-measured; 
`/api/instances?withCounts=true` still
     returns correct counts (1.3-1.5s, unchanged behaviour for the list page).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to