Skip to content

perf(specs): Clean up factories usage in spec/specs in directories k-o - #6250

Open
vankiru wants to merge 5 commits into
mainfrom
perf/spec-services-k-o
Open

perf(specs): Clean up factories usage in spec/specs in directories k-o#6250
vankiru wants to merge 5 commits into
mainfrom
perf/spec-services-k-o

Conversation

@vankiru

@vankiru vankiru commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Context

Currently, around 50% of the spec runtime is spent preparing data and creating factories. A lot of this data is either duplicated or recreates the same objects multiple times, so we can get rid of a good chunk of it and significantly speed up the specs.

To avoid creating unnecessary factories, we can use let_it_be, before_all, and create_default from test-prof. More info here.

Description

This PR cleans up the services specs in folders k-o and removes unnecessary factory usage.

Here are the numbers before and after the cleanup. The times below are for running the specs in a single process:

Metric Before After
Total # of factories 97,841 63,994
Time spent creating factories 11:51.790 07:40.512
Total time 18:00.870 14:22.880

Overall results

This PR is part of a series of PRs focused on cleaning up factory usage across different specs.

Once all the changes are merged, we expect to:

  • Reduce the number of factories by ~50k
  • Cut spec runtime by around 20%
  • Shave off roughly 1:15 min from the CI runtime
Metric Before After
Total # of factories 157,949 103,761
Total time spent creating factories 17:59.851 11:14.739
Total time 34:41.482 27:03.658

Here is the CI run with all the changes merged together:

@vankiru
vankiru force-pushed the perf/spec-services-k-o branch from fb326b3 to a294733 Compare August 31, 2026 09:02
@vankiru
vankiru marked this pull request as ready for review August 31, 2026 15:27
@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor

Automated pre-review (advisory, not a required check) — verdict: HOLD · CI green

HOLD — several new let_it_be fixtures are mutated by examples, so later examples can reuse stale in-memory Active Record state even though the database transaction rolls back.

  • Keep membership per-example or use reload/refind in both membership specs; revoke changes its status, while update examples cache differing role associations.
  • Apply the same isolation to the shared add_on/plan records that are discarded in the one-off, subscription-creation, and subscription-amendment execution specs.

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