Skip to content

Conversation

@timgl
Copy link
Collaborator

@timgl timgl commented Nov 20, 2025

Problem

we import a bunch of heavy packages on startup. do some clever lazy loading to avoid this!

Changes

Before:
image

After:
image

The vast majority now is schema.py, wait for something clever there too!

How did you test this code?

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Changelog: (features only) Is this feature complete?

@timgl timgl requested a review from webjunkie November 20, 2025 18:05
@timgl timgl requested a review from a team as a code owner November 20, 2025 18:05
@timgl timgl changed the title chore: Reduce runserver startup time by 75% chore: Reduce runserver startup time by 75% from 30s to 8s Nov 20, 2025
@posthog-bot posthog-bot requested a review from a team November 20, 2025 18:06
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

15 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@timgl timgl changed the title chore: Reduce runserver startup time by 75% from 30s to 8s chore: Reduce runserver import time by 75% from 30s to 8s Nov 20, 2025
@timgl timgl force-pushed the lazy-load-imports branch from 95eb496 to d2b15c9 Compare November 21, 2025 11:54
"serialize_fields",
"HOGQL_CHARACTERS_TO_BE_WRAPPED",
):
_load_database_module()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might add time to hogql queries? Just reading code here I have no idea what the actual time difference is and if it's meaningful but the hogql query execution path is definitely a place where we want to shave every bit of slowness off of

@EDsCODE EDsCODE requested a review from a team November 21, 2025 15:24
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.

3 participants