data icon indicating copy to clipboard operation
data copied to clipboard

Pre-RFC: Coalesced Responses

Open runspired opened this issue 2 years ago • 0 comments

Similar to https://github.com/emberjs/data/issues/8855 but for response handling

Processing results has non-trivial baseline overhead, especially for relationships. Often requests made close to each other contain result payloads that require work that could be deduplicated if processed together.

This proposal would add an optional coalescing feature to the CacheHandler. When coalescing, the handler would delay processing any payloads for a short time, and process any received payloads as a single batch, allowing XHR requests which resolve very close together to batch and dedupe similar work while still taking advantage of empty time while long requests are pending.

We may want to make the coalescing delay configurable, but the default would be to debounce await new Promise((resolve) => requestAnimationFrame(() => setTimeout(resolve, 0)));, thus waiting one frame past the last payload received to process.

runspired avatar Sep 10 '23 07:09 runspired