Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relocate services and block syncing out of the service worker to the offscreen entry #1573

Open
Tracked by #1790
TalDerei opened this issue Jul 27, 2024 · 2 comments
Assignees
Labels
discovery enhancement performance Related to speed improvements refactor Improving existing system with new design sync V2 features required after mainnet

Comments

@TalDerei
Copy link
Contributor

TalDerei commented Jul 27, 2024

proposal:

The service worker has inherent performance limitations due to its single-threaded and blocking nature. Consequently, note payloads inside blocks are trial decrypted serially. To address this, we propose moving block syncing out of the service worker and into the offscreen client, thereby allowing this CPU bound operation to be parallelized using dedicated web workers. This approach is supported by benchmarks recorded in #1142.

This raises some technical considerations:

  • Should we move everything into the offscreen client?
  • Is the offscreen client persistent and stable?
  • How will error propagation be handled?
  • Messaging

The specific components being considered for moving into the offscreen client are:

  1. RPC services interacting with the block processor (move services and block processor into offscreen entry #1788)
  2. The entire block processor component (move services and block processor into offscreen entry #1788)
  3. The trial decryption operation, modified in wasm to use rayon threads (Implement worker scaffolding to enable parallelization  #1787)
@TalDerei TalDerei added refactor Improving existing system with new design enhancement performance Related to speed improvements sync labels Jul 27, 2024
@TalDerei TalDerei self-assigned this Jul 27, 2024
@TalDerei TalDerei added V2 features required after mainnet discovery labels Jul 27, 2024
@turbocrime
Copy link
Contributor

turbocrime commented Jul 27, 2024

previously #710

services

a major benefit of moving services to offscreen is the entire package could then target standard dom api and drop chrome dependency.

targeting standard dom is important. the current offscreen mechanism implicitly depends on undocumented messaging and implementation details, and no consumer is going to achieve that.

targeting standard dom api, development of penumbra providers for ffx and other browsers would be as simple as writing a transport session manager for those browsers.

this could also be done piecemeal, right now, using the proxying tools and a context client. offscreen could, on-demand, run a limited service of only the endpoints that require wasm, and with the proxy tool, the existing router adapter can seamlessly merge these.

this could be done most quickly by splitting the view service def, but that's a bad shortcut.

if we want the existing services implementation to be adaptable for this, it would be necessary to stop doing direct cross-method calls in services, and to rewrite use of queriers to use of context clients.

block processor

offscreen block processor currently shares queriers with services. if these begin to run separately, we either have to

  • separate block proccessor from queriers, and run multiple queriers
  • provide a cross-document queriers messaging system
  • stop using queriers

i prefer the third option. most queriers are very thin wrappers to single api functions on promise clients.

eliminating queriers and switching to client use is simple in the block processor, and would provide versatility.

in services, it's more complex as switching to clients means that we now have local same-document clients and fullnode clients. i still think this is beneficial.

moving block processor out of the main worker also allows the extension to respond to messages during heavy operations inside the block processor. genesis sync freeze (which prevents injection init, shows user the 'connect' button when already connected) would not happen

@TalDerei
Copy link
Contributor Author

TalDerei commented Sep 3, 2024

@TalDerei TalDerei changed the title relocate block syncing out of the service worker and into the offscreen client relocate services and block syncing out of the service worker to the offscreen entry Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discovery enhancement performance Related to speed improvements refactor Improving existing system with new design sync V2 features required after mainnet
Projects
Status: 🗄️ Backlog
Development

No branches or pull requests

2 participants