Joystream / joystream

Joystream Monorepo
http://www.joystream.org
GNU General Public License v3.0
1.42k stars 115 forks source link

Colossus: In memory local data objects cache improvements #4991

Closed mnaamani closed 8 months ago

mnaamani commented 9 months ago

Background

The node keeps track of the local data objects in storage in a Map. This is acceptable for now but is not scalable, as it will grow memory usage linearly with the number of objects stored.

https://github.com/Joystream/joystream/blob/5d911ce1bd546da16c983c852203a2a6eac8d8ea/storage-node/src/services/caching/localDataObjects.ts#L21

Some room for improvement.

  1. addDataObjectIdToCache() should check for existence of entry before adding
  2. loadDataObjectIdCache() should be protected to only run once
  3. pin/unpinDataObjectIdToCache() should check existence of entry before pinning/unpinning
  4. getDataObjectIdFromCache() - lock before check for id (I previously suggested it was not necessary in PR) I was wrong.
  5. getDataObjectIDs() returns an array. At some point this is going to be expensive and we will hit the JavaScript limit on size of array elements. (32-bit index so ~4Billion elements)
kdembler commented 8 months ago

closed by https://github.com/Joystream/joystream/pull/5016