Skip to content

perf(core): Don't use a LocalEndpoint to send the config#296

Merged
ketiltrout merged 2 commits into
chime-upgradefrom
send_config_directly
Jul 16, 2026
Merged

perf(core): Don't use a LocalEndpoint to send the config#296
ketiltrout merged 2 commits into
chime-upgradefrom
send_config_directly

Conversation

@ketiltrout

@ketiltrout ketiltrout commented Jul 15, 2026

Copy link
Copy Markdown
Member

This fixes an unintended side-effect of implementing "/get-coco-config" as a cocod LocalEndpoint.

Like "real" endpoints, when there's a hit on this cocod LocalEndpoint:

  • the "get-coco-config" request is appended to the request queue in redis by Sanic
  • (eventually) the request is popped off the queue by the qworker
  • the qworker responds by writing the coco config as the response back to redis
  • Once it appears, the Sanic worker pulls the response out of redis and sends it back to the client.

The unintended problem here is serializing the config request with all other coco requests. Because the client calls this endpoint whenever it starts up, the net effect is: the client is forced to wait for everything already existing in the queue to be handled before it can finish intialising. If the cocod queue happens to be super deep, the client might time-out before Sanic responds with the config.

However, it's not necessary to involve the queue or the qworker at all here, because the coco config is fully sanitized before Sanic starts up. The Sanic process has the same config as the qworker process.

So, this PR replaces the old "get-coco-config" LocalEndpoint with a simple /config Sanic route which responds immediately with the coco config (as a standard JSON response, without the coco Result framework.)

This should significantly speed-up client start-up in cases where the queue is congested.

This fixes an unintended side-effect of implementing "/get-coco-config"
as a cocod `LocalEndpoint`.

Like "real" endpoints, when there's a hit on this cocod `LocalEndpoint`:
* the "get-coco-config" request is appended to the request queue in
  redis by Sanic
* (eventually) the request is popped off the `queue` by the qworker
* the qworker responds by writing the coco config as the response back
  to redis
* Once it appears, the Sanic worker pulls the response out of redis and
  sends it back to the client.

The unintended problem here is serializing the config request with all
other coco requests.  Because the client calls this endpoint whenever it
starts up, the net effect is: the client is forced to wait for
_everything_ already existing in the queue to be handled before it can
finish intialising.  If the `cocod` queue happens to be super deep, the
client might time-out before Sanic responds with the config.

However, it's not necessary to involve the queue or the qworker at all
here, because the coco config is fully sanitized before Sanic starts
up.  The Sanic process has the same config as the qworker process.

So, this PR replaces the old "get-coco-config" `LocalConfig` with a
simple `/config` Sanic route which responds immediately with the
coco config (as a standard JSON response, without the coco
`Result` framework.)

This should significantly speed-up client start-up in cases where the
queue is congested.
@aelanman

Copy link
Copy Markdown
Contributor

Ah! I wonder if this was related to some issues we've had at outriggers.

@ketiltrout
ketiltrout merged commit 245f446 into chime-upgrade Jul 16, 2026
5 checks passed
@ketiltrout
ketiltrout deleted the send_config_directly branch July 16, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants