osmosis-labs / osmosis-frontend

Web interface for Osmosis Zone
https://app.osmosis.zone/
Apache License 2.0
217 stars 403 forks source link

Pools page, bring blocking queries earlier #3167

Open ValarDragon opened 2 months ago

ValarDragon commented 2 months ago

On the pools page, I see the following two queries taking a long time (180-200ms), and appear to be blocking more queries that are required for page stability.

Slow queries:

These queries come after other queries on this page such as:

These slow queries block the following (much slower) queries, however there is no dependence and they should be parallelized:

jonator commented 2 months ago

WDYM by blocking? The queries are dependent on the mounting of the component tree, which may have some serial properties but I'm not quite sure how the guts of the React engine layout the tree initially. Further, a pitfall of building a dapp is often you need to wait to get the user address from the wallet (which may be blocked on installing wallet client code) which often triggers a flurry of blocked queries once we get that address. In web2, we can normally get that user identifier on the initial query from a browser cookie. Perhaps that's what you're seeing? I'm spitballing and any other input would be appreciated here.

For expensive queries, we tell tRPC not to batch them with other tRPC queries (like you see with the last query, assets.getUserMarketAsset,assets.getAssetHistoricalPrice,assets.getUserAsset). So, expensive queries operate independently and should not be blocked or block any other queries.

The "idea" with batching is it justifies small cheap tRPC queries by automatically combining them at runtime and reducing total networking overhead. But, I'm not sure the observed performance benefits are there. I'd like to verify that it runs the batch in parallel in the server as well, it should. But, it could just be the multi region & edge problem.

MaxMillington commented 1 month ago

@jonator @Amosel was this solved at the offsite? If so, can we close?

jonator commented 1 month ago

We only made improvements to user positions. The user pools query will likely need to be moved to SQS to be optimized enough