Page MenuHomePhabricator

Optimize pickle file storage with subdirectory structure to avoid filesystem limitations
Closed, ResolvedPublicFeature

Description

Currently pickle files are stored in flat directories per language:

en/100000.p, en/100002.p, en/100003.p ...

This creates over 7 million files in single directory for enwiki which causes filesystem performance issues.

Proposed solution: Use subdirectories based on floor(page_id/1000)

Examples:
- page_id 100000 → en/100/100000.p
- page_id 100002 → en/100/100002.p  
- page_id 200005 → en/200/200005.p

This reduces files per directory from ~7M to ~7K.

Implementation will include:
- Helper functions for path calculation
- Support for the new directory structure
- Optional migration utility for existing files

Related to T414071

Event Timeline

Change #1224790 had a related patch set uploaded (by Xinacod; author: Xinacod):

[pywikibot/core@master] Optimize pickle file storage with subdirectory structure

https://gerrit.wikimedia.org/r/1224790

Xqt triaged this task as Low priority.
Xqt changed the subtype of this task from "Task" to "Feature Request".

Change #1224790 merged by jenkins-bot:

[pywikibot/core@master] Optimize pickle file storage with subdirectory structure

https://gerrit.wikimedia.org/r/1224790

Change #1236372 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] tests: update test collector

https://gerrit.wikimedia.org/r/1236372

Change #1236372 merged by jenkins-bot:

[pywikibot/core@master] tests: update test collector

https://gerrit.wikimedia.org/r/1236372

We should probably do the same on the actual wikiwho storage volumes. You know, I bet that's part of the reason Python pickles are seemingly so slow… Even small articles can take seconds to load, but that makes sense when it has to do a filesystem lookup amongst millions of files.

@Xqt @Xinacod As far as I can tell, you are making direct copies of WikiWho data. This cache I presume is per-Pywikibot instance and not somewhere shared? Let's see if we can upstream your work and make the WikiWho API itself be fast enough :) Local caching is of course great, but not if you are making millions of copies, and especially if it's just to get around upstream slowness.