Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: reduce memory usage #711

Closed
wants to merge 8 commits into from
Closed

refactor: reduce memory usage #711

wants to merge 8 commits into from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Oct 13, 2023

🧿 Current issues / What's wrong ?

In helpers/spaces.ts, we're storing a duplicate array for ranked spaces, increasing memory usage.

💊 Fixes / Solution

We already have a full spaces object, ranked spaces are just a subset of that object, in a specific order. Instead of saving the ranked spaces as an array of object, we could just save the ranked space Ids in an array, reducing the memory usage.

🚧 Changes

  • Convert rankedSpaces from an an array of spaces to an array of space IDs.
  • Reduce the number of property in spacesMetadata to only the one currently used

Todo

  • Need to add more tests
  • Ultimate goal will be to remove the spaces cache entirely

🛠️ Tests

@wa0x6e wa0x6e changed the base branch from master to use-verified-n-flagged-from-db October 13, 2023 01:43
@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Attention: Patch coverage is 0% with 37 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/graphql/operations/ranking.ts 0.00% 20 Missing ⚠️
src/helpers/spaces.ts 0.00% 14 Missing ⚠️
src/graphql/helpers.ts 0.00% 3 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

@wa0x6e wa0x6e changed the base branch from use-verified-n-flagged-from-db to master October 13, 2023 04:08
@wa0x6e wa0x6e marked this pull request as ready for review October 14, 2023 08:10
@wa0x6e wa0x6e marked this pull request as draft October 14, 2023 08:11
@wa0x6e wa0x6e closed this Dec 10, 2024
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.

2 participants