More efficient response format
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp, javascript
- Domain
- backend, performance
Research direction
Start at src/vtquery.cpp, comparing Execute() around line 262 with response creation around line 390. Read the vector-tile handoff in vtcomposite and vtshaver for the thread-pool pattern and node.Buffer transfer. The scope is not settled between asynchronous JSON generation and compression, so confirm the chosen approach and benchmark that response work no longer blocks the main event loop.
Written by the indexing model from the issue text.
Description
In profiling vtquery under load with @mapsam I recall seeing that the JSON response creation runs on the main event loop and takes a non-trivial amount of time to return as a JS object.
Given this fact there are several things we can consider that would speed up the response:
Async json generation in threadpool
We could generate the JSON response async inside the thread pool (so inside Execute() rather than on the main thread like is currently done (https://github.com/mapbox/vtquery/blob/96c645b8cdac54c8af968188587a14c1535862f8/src/vtquery.cpp#L390).
This would require serializing the JSON to a string and then passing the data back from the threadpool in the same way that we pass vector tiles back from the threadpool to the main thread in vtcomposite and vtshaver (as a node.Buffer).
Compressing the JSON response
Now that we're working with a string, we could also gzip compress the JSON string in the threadpool before sending back. This could help speed up the transfer of the data to clients.
- Dominant language
- JavaScript
- Stars
- 45
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/vtquery
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
-
union geometries Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
dedupe is too strong Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
docToolchain/docToolchain#1705 ·
-
Timezone select lists one option per character; duplicate "Failed" reason; shared tracker popover id Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
nightscout/nocturne#1414 ·
-
bug v2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelcontextprotocol/inspector#2458 · 1 comment ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
carbon-design-system/ibm-products#9907 ·