Automattic / Automattic/jetpack
Improve performance of do_server_site_stats
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
`do_server_site_stats` will run multiple remote requests when multiple stats items are stored in the `$this->stats` var. https://github.com/Automattic/jetpack/blob/master/class.jetpack.php#L4316-L4348
A couple of ideas:
- [ ] - Defer all `do_server_site_stats` to run on shutdown instead of during the execution tree to improve perceived performance.
- [ ] - Speed up the overall process. Modify the endpoint endpoint to accept multiple stats at once or set the http timeout to 1, etc (while the function returns true/false if the call works, we don't actually use it) so we send the stats request but don't wait at all for a response.
Contributor guide
Research direction
Start in class.jetpack.php around lines 4316-4348 and trace how do_server_site_stats handles multiple items in $this->stats. Compare deferring requests until shutdown with batching or a shorter timeout, then verify that multiple stats no longer cause the observed request delay while the stats still get sent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend-api-design, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100