redwood: Jest is leaking memory even on a simple default redwood app
Expected behaviour
yarn redwood test should use ~ same heap size for each test unless the user has specifically done something wrong.
i.e. the heap size should not spiral out of control just by creating more tests
What currently happens
The heap size spirals out of control by creating more tests
Steps to reproduce
1. Create new app
yarn create redwood-app --typescript test
2. Add some models to ./api/db/schema.prisma
Excuse the silly models, just something quick to generate tests.
model Man {
id String @id @default(cuid())
name String
}
model Woman {
id String @id @default(cuid())
name String
}
model Boy {
id String @id @default(cuid())
name String
}
model Girl {
id String @id @default(cuid())
name String
}
model Dog {
id String @id @default(cuid())
name String
}
model Cat {
id String @id @default(cuid())
name String
}
3. Generate some tests
yarn redwood generate sdl --crud man
yarn redwood generate sdl --crud woman
yarn redwood generate sdl --crud boy
yarn redwood generate sdl --crud girl
yarn redwood generate sdl --crud dog
yarn redwood generate sdl --crud cat
4. Run tests
yarn redwood test --logHeapUsage
5. Checkout heap spiral
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 17 (13 by maintainers)
Update
Given that there’s been progress on this (in the coming v0.44) but not complete resolution, I am moving this topic to a new Issue with updated benchmarks and a reproduction repo:
Closing this out. Look for v0.44 release comming asap
@thedavidprice I just tried out with a new project (
v0.42.1). This time I created some web tests via:This is the output from running tests:
Notice that the web tests are indeed fairly quick and the heap is consistent.
It seems the problem is stemming from the API tests as the heap is still spiralling out of control.
Yeah it is the same project as I used last time, just updated with
yarn rw upgrade.I’ll try with a fresh repo tomorrow morning 👍🏼
It’s a SIGKILL, can’t say for sure if it’s related. I can’t seem to replicate the error with the repro listed (first post). @zygopleural Is this from the same project? If we can get a reproduction that would be ideal.
Hey folks, can you confirm you weren’t seeing this prior to 0.42? We diagnosed this heap usage issue present in all the previous versions, and from our tests .42 seemed to improve it. The issue seems to be related to jest and node, so I’d be surprised if this is a new one.
Any details of the errors would be appreciated, can’t really diagnose from the screen shot ✌🏽
@callingmedic911 and I have definitely seen usage drop switching to node 16.10 (as recommended in the issue in jests repo)
Hi all! Some updates here based on my evaluation of #4024, which will be included in the imminent release. (Full related comment here.)
Here’s the relevant results of a simple performance test comparing v0.41 (latest) with recent canary (next).
Performance Results
I used my standard https://github.com/thedavidprice/redwood-tutorial-test repo.
v0.41.0
https://s.tape.sh/ORsePaAK
rw testrw test webrw test apiv0.41.1-canary.162 (latest)
https://s.tape.sh/99YpX63l
rw testrw test webrw test apiWe see both time and heap improvements for Web tests, as intended with this PR! Even more important (and unexpected) is that we see a massive improvement to heap when running both via
rw test, especially given that there are negligible changes when runningrw test apialone.Same issue for me, Node version
v16.11.1