Skip to content

Speed up model parsing, cut memory and import time - #764

Merged
MarshalX merged 1 commit into
mainfrom
faster-leaner-models
Oct 22, 2026
Merged

MarshalX merged 1 commit into
mainfrom
faster-leaner-models

Conversation

@MarshalX

Copy link
Copy Markdown
Owner

What is done

  • Reduce model memory up to 39% by sharing __pydantic_fields_set__ between models
  • Optimize string format validation
  • Optimize unknown-type field decoding
  • Optimize CID validation
  • Optimize bytes field decoding
  • Optimize firehose frame parsing
  • Optimize get_or_create
  • Optimize DotDict (5× faster, less memory)
  • Reduce import time and memory with lazy imports
  • Fix hasattr() on the models package raising ModuleNotFoundError

Results

Workload Time Retained memory
Firehose frame parsing −15.5% -
Firehose: frame + CAR + record decode −8.1% 6.8 MB -> 4.6 MB (−32%)
Jetstream messages −6.3% 15.0 MB -> 9.2 MB (−39%)
Feed response (100 posts) ±0% 12.5 MB -> 7.8 MB (−38%)
Followers response (100 profiles) −2.9% 3.5 MB -> 2.2 MB (−37%)
DotDict (records without a model) −78.6% (5× faster) 6.5 MB -> 6.0 MB
Import Before After
from atproto import Client 209 ms, 63 MB RSS 150 ms, 51 MB RSS
from atproto import FirehoseSubscribeReposClient 206 ms, 63 MB RSS 143 ms, 45 MB RSS
from atproto import JetstreamClient 207 ms, 63 MB RSS 171 ms, 54 MB RSS

@MarshalX
MarshalX merged commit 4b7a5dd into main Oct 22, 2026
38 of 39 checks passed
@MarshalX
MarshalX deleted the faster-leaner-models branch October 22, 2026 20:01
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.

1 participant