Skip to content

Parallelize calling event handlers which do not call store.get #691

Open
@Zerim

Description

@Zerim

Syncing a subgraph currently takes a long time, on the order of many hours. Most of that time is getting events from the blockchain and processing them in the WASM runtime.

Currently, we process events sequentially. For event handlers that call store.get, this is necessary as they depend on the prior state of the store, and thus events must be processed in a strict order.

For handlers which do not call store.get, however, we can parallelize their execution, producing a stream of store update transactions. These store transactions still must be applied in the correct order, also properly accounting for the handlers which depend on the state of the store to be correct at a given point in time.

Even so, by parallelizing the instantiation of many WASM runtimes and calling of event handlers, I predict an order of magnitude improvement in syncing time for a certain subset of subgraphs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions