Skip to content

Migrate to push-based data flow for tracer #65

Open
@aryanjassal

Description

@aryanjassal

Specification

Currently, the tracer is pull-based. The events are generated and added to a global queue, which a generator can consume. This is bad, as if no consumers are present, then the events can start building up indefinitely.

To fix this, we need to adopt a push-based dataflow, where there is a source of events which are all consumed in real-time by subscribers via callbacks. This approach draws inspiration from how rxjs handles this.

For this implementation, however, rxjs is unnecessary complexity and we can make do with only WebStreams or EventEmitters internally. I'm leaning towards using streams, as streams handle backpressure for us if the consuming callbacks are slower than incoming data. However, that might mean an observable slowdown of the program if the backpressure buffer is full. To avoid this, we may need to create an unbound buffer, but that would again result in the same issue where the buffer can grow indefinitely. It would be a bit more manageable here, as events can be ignored if no consumers have been registered. This would need some discussion.

Additional context

Tasks

  1. Switch from pull-based to push-based design
  2. Incorporate rxjs or streams to manage resources
  3. Should support multiple consumers or subscribers
  4. Add benchmarks for different approaches like observables and webstreams

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions