Rapid icon indicating copy to clipboard operation
Rapid copied to clipboard

Busy/Idle events to support code benchmarking

Open bhousel opened this issue 3 years ago • 2 comments

@vanreece has been doing an investigation into code benchmarking and we could really use some more events sprinkled around the various parts of the RapiD code that perform background work (data fetching, etc), so that we're able to run the performance benchmarks when the system is in a quiesced state. (https://github.com/mapbox/mapbox-gl-js/issues/1715 comes to mind).

My plan is to add events like this anywhere that the system is doing background work that might affect performance, or where we might want to show a spinner or something.

  • .on('busy') - component started doing something in the background (fetching tiles, etc)
  • .on('idle') - component is done whatever it was doing

then context will also listen to these and keep a count going to expose a main event like:

  • context.on('busy') - at least one component somewhere is busy
  • context.on('idle') - all components are done their work

Will write this in a way that the events will always be matched up, e.g. fire 1 single busy , then later 1 single idle.

bhousel avatar Oct 26 '21 13:10 bhousel

I've added the events to the Esri and FBML services and it's pretty cool - here is with some console logging:

Screen Shot 2021-10-27 at 9 07 27 AM

Also you can bind handlers to context and do this:

Screen Shot 2021-10-27 at 9 10 58 AM

I'm thinking a bit more about how we might want to use these events, and considering:

  • should the events come with a payload of data?
  • another event like .on('work') dispatched sometimes to say how it's going / what it's doing?

Just tossing out ideas - don't want to overthink it and we can change it later.

bhousel avatar Oct 27 '21 13:10 bhousel

Awesome. Looking good! I think eventually we may want a more robust system of information that can happen, I could totally imagine some sort of x/y tiles loaded or something eventually happening, but we can always add that later. Thanks Bryan!

vanreece avatar Nov 01 '21 19:11 vanreece