Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/hub/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
xet-core-wasm-build
shard.bin
xorb.bin
*.bin
.debug
10 changes: 10 additions & 0 deletions packages/hub/src/utils/ChunkCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ export class ChunkCache {
hmacs = new Set<string>(); // todo : remove old hmacs

addChunkToCache(hash: string, xorbIndex: number, chunkIndex: number, hmac: string | null): void {
if (this.map.has(hash)) {
// Happens when we receive an existing chunk from remote dedup info (eg duplicate chunk in shard? Or shards with same hmac key
// sharing chunks/xorbs)

// processing this chunk again would desync the cache, as `this.map.size` would not increase, as opposed to `this.index`

// Ideally we'd still process it to evict it later ("refresh it") but would need more complex handling, or stop using
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, maybe a not-to-complex solution:

  • remove and readd the key in the map (to put the key at the end)
  • in the eviction code, instead of checking on map.size > MAX_SIZE, check on map.size > 1 && firstValue === this.index (or something approaching)

Would need unit tests and careful thinking

// the Uint16Array / Int32Array which are optimized for memory usage
return;
}
this.map.set(hash, this.index);
if (hmac !== null) {
this.hmacs.add(hmac);
Expand Down