Skip to content

Conversation

ilevkivskyi
Copy link
Member

This makes cache meta files ~1.5x smaller. (I hoped together with previous diff it will give us 4x, but it is more like 3x). Implementation is mostly straightforward, here are some comments:

  • I make CacheMeta a regular class, it doesn't need to be immutable IMO (since we actually mutate it in few places).
  • I remove all uses of untyped dicts in favour of CacheMeta (note this might make JSON format slightly slower actually, but difference is below noise level)
  • Instead of manually checking some individual keys, I use blanket try/except (KeyError, ValueError) when deserializing metas.
  • In one place (where we update meta file after read), I update the loaded view to match the updated file 1:1. This should be more robust.
  • I still use JSON dumps for options and plugins snapshots. Serializing these using FF is tricky (and will be simpler with type tags).
  • I rename data_json/meta_json paths to data_file/meta_file everywhere.

@ilevkivskyi ilevkivskyi requested a review from JukkaL October 19, 2025 21:16
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Nice! Did you see any measurable performance differences?

@ilevkivskyi
Copy link
Member Author

I didn't do any precise measurements, on average of three warm runs import torch was ~5% faster. I will try making more precise measurements.

@ilevkivskyi
Copy link
Member Author

OK, after more careful measurements it is more like 4%, but still not nothing. Btw I also compared this PR vs 1.18.2, and warm import torch is ~25% faster.

@ilevkivskyi ilevkivskyi merged commit b266dd1 into python:master Oct 20, 2025
20 checks passed
@ilevkivskyi ilevkivskyi deleted the use-ff-meta branch October 20, 2025 22:28
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