Skip to content

Conversation

@cprussin
Copy link
Collaborator

Upon investigation, it seems the PythConnection from @pythnetwork/client is extremely inefficient for a few reasons:

  1. PythConnection requires loading all account info when creating the connection class, so that it can build a mapping from price account to program account. However IH never used this mapping in practice, so all of that was wasted work. This caused major issues for page load performance as loading all account info from pythnet was a ton of parsing which locked up the browser for multiple seconds.

  2. PythConnection did not expose a mechanism to remove unused subscriptions

In doing this I also removed all the live prices contexts since none of that is needed any more, as well as the call to initialize prices with the last available price as that too looks unnecessary and redundant.

This change should drastically improve performance in IH, especially during page load.

Upon investigation, it seems the `PythConnection` from `@pythnetwork/client` is
extremely inefficient for a few reasons:

1. `PythConnection` requires loading _all_ account info when creating the
connection class, so that it can build a mapping from price account to program
account.  However IH never used this mapping in practice, so all of that was
wasted work.  This caused major issues for page load performance as loading all
account info from pythnet was a ton of parsing which locked up the browser for
multiple seconds.

2. `PythConnection` did not expose a mechanism to remove unused subscriptions

In doing this I also removed all the live prices contexts since none of that is
needed any more, as well as the call to initialize prices with the last
available price as that too looks unnecessary and redundant.

This change should _drastically_ improve performance in IH, especially during
page load.
@cprussin cprussin requested a review from a team as a code owner October 28, 2025 00:19
@vercel
Copy link

vercel bot commented Oct 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
component-library Ready Ready Preview Comment Oct 28, 2025 0:24am
insights Ready Ready Preview Comment Oct 28, 2025 0:24am
5 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
api-reference Skipped Skipped Oct 28, 2025 0:24am
developer-hub Skipped Skipped Oct 28, 2025 0:24am
entropy-explorer Skipped Skipped Oct 28, 2025 0:24am
proposals Skipped Skipped Oct 28, 2025 0:24am
staking Skipped Skipped Oct 28, 2025 0:24am

);
return () => {
removeSubscription(feedKey, setData);
unsubscribe(cluster, subscriptionId).catch((error: unknown) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: should we consider a failure to unsubscrive as a more critical failure and alert the user to reload their page (or similar)?

Copy link
Collaborator Author

@cprussin cprussin Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, at the worst case it means that the websocket will be continuing to send some data that we ignore. The way the web3.js Connection object works is that it updates all subscriptions when creating a new subscription or deleting a subscription, so the websocket unsubscribe message will be retried by the next time any change in the subscribed feeds happens anyways. So even the problem with continuing to receive unnecessary ws messages would resolve itself by just navigating around the app.

Copy link
Contributor

@benduran benduran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamp

@cprussin cprussin merged commit 331c14e into main Oct 28, 2025
10 checks passed
@cprussin cprussin deleted the cprussin/dont-use-pythconnection branch October 28, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants