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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

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: 37 lines in your changes are missing coverage. Please review.

Comparison is base (695e385) 0.00% compared to head (401356a) 0.00%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master    #711   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files          40      40           
  Lines        1998    1997    -1     
  Branches       40      40           
======================================
+ Misses       1958    1957    -1     
  Partials       40      40           
Files Coverage Δ
src/graphql/helpers.ts 0.00% <0.00%> (ø)
src/helpers/spaces.ts 0.00% <0.00%> (ø)
src/graphql/operations/ranking.ts 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@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
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