Skip to content

Add pLimit when loading file explorer in refresh placeholders#1379

Merged
dajimenezriv-internxt merged 11 commits into
mainfrom
add-p-limit-to-load-in-memory-paths
May 12, 2026
Merged

Add pLimit when loading file explorer in refresh placeholders#1379
dajimenezriv-internxt merged 11 commits into
mainfrom
add-p-limit-to-load-in-memory-paths

Conversation

@dajimenezriv-internxt
Copy link
Copy Markdown
Contributor

@dajimenezriv-internxt dajimenezriv-internxt commented May 11, 2026

What

After trying a lot of things to reduce RAM usage (explained in this ticket https://inxt.atlassian.net/browse/PB-6240), we have been able to reduce the RAM usage by around 290MB for a test case of 1000 folders x 100 files (100k files). Previously it was ~835MB, now it's ~545MB.

We have done that by limiting the number of concurrent promises that can run when refreshing placeholders using pLimit and also by only storing in the Map the required properties.

I've also implemented a fix to not block the main thread when createOrUpdateBatch for files and folders.

@dajimenezriv-internxt dajimenezriv-internxt self-assigned this May 11, 2026
@sonarqubecloud
Copy link
Copy Markdown

export async function loadInMemoryPaths({ ctx }: { ctx: SyncContext }) {
const files: FileExplorerFiles = new Map();
const folders: FileExplorerFolders = new Map();
const limit = pLimit(20);
Copy link
Copy Markdown
Contributor

@AlexisMora AlexisMora May 12, 2026

Choose a reason for hiding this comment

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

I have seen that you already defined a concurrency limit of 20 on refresh-items-placeholders do you see a benefit in centralizing this value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could, but technically the values can change individually. I've set 20 because it was the recommendation of claude. I've tried changing both but in general terms 20 was the one that was working the best. However, it doesn't mean that is has to be the same for both. Each step has it's own concurrency, maybe in the future one should be 20 and the other 15. Basically they don't change because of the same reason that's why the should be 2 different values (at least with the knowledge I have).

@dajimenezriv-internxt dajimenezriv-internxt merged commit 40120fd into main May 12, 2026
10 checks passed
@dajimenezriv-internxt dajimenezriv-internxt deleted the add-p-limit-to-load-in-memory-paths branch May 12, 2026 14:58
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