Improve performance #9794

Merged
thatonecalculator merged 2 commits from supakaity/hajkey:hk/delete-fixes into develop 2 months ago

delete !== undefined

So during the rome refactor (6b00abf05c), some delete object[key] statements were changed to object[key] = undefined.

Unfortunately setting to undefined means that the key is still iterable and this causes some issues.

In the case of the chart updates, upon chart.commit(...), it leaves the entry there and over time it causes the worker to keep creating empty entries in the chart database for every event that's ever happened since the process first started.

This means that after several days of running, the server may be updating many thousands of hashtags every 20 minutes, regardless of whether the hashtag had any use during that collection interval.

This also means that the database tables are growing continually at an ever increasing rate the longer the process has run without being restarted.

To fix this, some of the objects in question have been converted from plain {} objects to Map<K,V>s so we can use the accessor methods as recommended in the Rome documentation. In the case of the chart core's buffer, I had to put in a rome-ignore directive as I couldn't work out an elegant way to do it "properly" within the Commit<T> type.

Parallel execution

The second issue is that when performing large numbers of chart updates, the Promise.all allows unrestrained parallel execution of the chart update queries, which can adversely affect the operation of regular website queries and cause excess CPU consumption.

To fix this I have put a promiseLimiter in to restrict the number of concurrent queries per chart update.

# delete !== undefined So during the rome refactor (6b00abf05c0825244c66a20627b29805e2e14a4b), some `delete object[key]` statements were changed to `object[key] = undefined`. Unfortunately setting to undefined means that the key is still iterable and this causes some issues. In the case of the chart updates, upon `chart.commit(...)`, it leaves the entry there and over time it causes the worker to keep creating empty entries in the chart database for every event that's ever happened since the process first started. This means that after several days of running, the server may be updating many thousands of hashtags every 20 minutes, regardless of whether the hashtag had any use during that collection interval. This also means that the database tables are growing continually at an ever increasing rate the longer the process has run without being restarted. To fix this, some of the objects in question have been converted from plain `{}` objects to `Map<K,V>`s so we can use the accessor methods as recommended in the Rome documentation. In the case of the chart core's buffer, I had to put in a `rome-ignore` directive as I couldn't work out an elegant way to do it "properly" within the `Commit<T>` type. # Parallel execution The second issue is that when performing large numbers of chart updates, the `Promise.all` allows unrestrained parallel execution of the chart update queries, which can adversely affect the operation of regular website queries and cause excess CPU consumption. To fix this I have put a `promiseLimiter` in to restrict the number of concurrent queries per chart update.
supakaity added 1 commit 2 months ago
ci/woodpecker/pr/dockerHubRelease unknown status Details
ci/woodpecker/pr/dockerHubReleaseCandidate unknown status Details
ci/woodpecker/pr/dockerHubTag Pipeline was successful Details
ci/woodpecker/pr/commit Pipeline failed Details
ci/woodpecker/pr/testDocker Pipeline failed Details
b96fe57793
Improve performance of charts
Fix some undefined !== deleted issues
supakaity added 1 commit 2 months ago

❤️❤️❤️❤️

❤️❤️❤️❤️
thatonecalculator merged commit 6ebd25d874 into develop 2 months ago
supakaity deleted branch hk/delete-fixes 2 months ago
The pull request has been merged as 6ebd25d874.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b supakaity-hk/delete-fixes develop
git pull hk/delete-fixes

Step 2:

Merge the changes and update on Forgejo.
git checkout develop
git merge --no-ff supakaity-hk/delete-fixes
git push origin develop
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: calckey/calckey#9794
Loading…
There is no content yet.