Skip to content

Commit bfd2a30

Browse files
authored
feature: performance improvements (#2)
* add some benchmark experiments; in-memory caching for dmmf document and transformers * remove old benchmarking code; add more versatile benchmarking method * revert to sequential code generation after much experimentation * cleanup generate-code; fix tests (reset module level caches) * bump down blacksmith runner * run format * use ubuntu-latest; disable logging by default on generate * run format; remove worker threads references * update prettier * format code * fix: make husky pre-commit hook executable and update lint-staged config * fix: format all files with prettier and improve npm scripts - Fix glob patterns in format and check:format scripts - Format all files to match prettier configuration - Add debug information to check:format for CI debugging * fix: format package.json * clean: remove debug information from check:format script * fix: setup integration tests to work locally - Add .env file with TEST_DATABASE_URL for integration tests - Fix integration test to use 'prisma db push' instead of 'migrate dev' - Update test snapshots for integration tests - All integration tests now pass locally * fix: handle Prisma update notifications in integration tests - Add helper function to filter Prisma CLI update notifications from stderr - Apply filter to all stderr checks in integration tests - Update snapshot for integration test data - Tests now pass in CI even with Prisma update notifications * fix: complete integration test setup for local and CI environments - Add helper function to filter Prisma CLI update notifications from stderr - Simplify database handling to avoid connection conflicts in local development - Update integration test snapshots - All integration tests now pass both locally and in CI - Tests properly handle Prisma version update notifications The test may accumulate data locally but works correctly in CI with fresh databases. * update test snapshots * move to blacksmith; setup pg in pull-request.yml * move back to gh runners
1 parent 8f22174 commit bfd2a30

54 files changed

Lines changed: 13039 additions & 12883 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cli.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ tests/artifacts
1313
**/prisma/migrations/**/*
1414
prisma-client-mock.js
1515
prisma-client-mock.d.ts
16+
17+
generated-test
18+
test-schemas

.github/workflows/main.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
name: CI/CD
1+
name: Deploy
22

33
on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
branches:
9-
- main
107

118
jobs:
129
check:
10+
# runs-on: blacksmith-4vcpu-ubuntu-2404
1311
runs-on: ubuntu-latest
1412

1513
strategy:
1614
matrix:
17-
node-version: [20.x, 21.x, 22.x]
15+
node-version: [20.x, 22.x]
1816

1917
services:
2018
db:
@@ -27,16 +25,27 @@ jobs:
2725
- 5432:5432
2826

2927
steps:
30-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v4
3129

32-
- name: Use Node.js ${{ matrix.node-version }}
33-
uses: actions/setup-node@v2
30+
- name: Install Node
31+
uses: useblacksmith/setup-node@v5
3432
with:
3533
node-version: ${{ matrix.node-version }}
3634

35+
- name: Cache Dependencies
36+
id: cache-deps
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.npm
41+
**/node_modules
42+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
43+
restore-keys: |
44+
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
45+
3746
- name: Setup project
3847
run: |
39-
npm install
48+
npm ci --no-fund --no-audit --no-update-notifier --include=dev --include=optional
4049
4150
- name: Check codebase
4251
run: |

.github/workflows/pull-request.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Pull Request Workflow
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types: [opened, synchronize]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
checks:
15+
# runs-on: blacksmith-4vcpu-ubuntu-2404
16+
runs-on: ubuntu-latest
17+
18+
services:
19+
postgres:
20+
image: postgres:15
21+
env:
22+
POSTGRES_USER: user
23+
POSTGRES_PASSWORD: password
24+
POSTGRES_DB: typegraphql-prisma
25+
options: >-
26+
--health-cmd pg_isready
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
30+
ports:
31+
- 5432:5432
32+
33+
strategy:
34+
matrix:
35+
node-version: [20.x, 21.x, 22.x]
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Install Node
41+
uses: useblacksmith/setup-node@v5
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
45+
- name: Cache Dependencies
46+
id: cache-deps
47+
uses: actions/cache@v4
48+
with:
49+
path: |
50+
~/.npm
51+
**/node_modules
52+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
53+
restore-keys: |
54+
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
55+
56+
- name: Setup project
57+
run: |
58+
npm ci --no-fund --no-audit --no-update-notifier --include=dev --include=optional
59+
60+
- name: Check codebase
61+
run: |
62+
npm run check:format
63+
npm run check:type
64+
65+
- name: Run tests
66+
run: |
67+
npm run test:ci
68+
env:
69+
CI: true
70+
TEST_DATABASE_URL: postgresql://user:password@localhost:5432/typegraphql-prisma

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ build
2323
.env.development.local
2424
.env.test.local
2525
.env.production.local
26+
27+
generated-test

.husky/pre-commit

100644100755
File mode changed.

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ coverage
1313
**/prisma/migrations/**/*
1414
prisma-client-mock.js
1515
prisma-client-mock.d.ts
16+
17+
generated-test
18+
test-schemas

.zed/settings.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"format_on_save": "on",
3+
"lsp": {
4+
"vtsls": {
5+
"settings": {
6+
"typescript": {
7+
"tsserver": {
8+
"maxTsServerMemory": 16184,
9+
"watchOptions": {
10+
"watchFile": "useFsEvents",
11+
"watchDirectory": "useFsEvents",
12+
"fallbackPolling": "dynamicPriority",
13+
"synchronousWatchDirectory": true,
14+
"excludeDirectories": ["**/node_modules", "**/.git"]
15+
}
16+
},
17+
"preferences": {
18+
"includePackageJsonAutoImports": "off"
19+
}
20+
},
21+
"javascript": {
22+
"tsserver": {
23+
"maxTsServerMemory": 16184,
24+
"watchOptions": {
25+
"watchFile": "useFsEvents",
26+
"watchDirectory": "useFsEvents",
27+
"fallbackPolling": "dynamicPriority",
28+
"synchronousWatchDirectory": true,
29+
"excludeDirectories": ["**/node_modules", "**/.git"]
30+
}
31+
},
32+
"preferences": {
33+
"includePackageJsonAutoImports": "off"
34+
}
35+
}
36+
}
37+
}
38+
},
39+
"languages": {
40+
"JavaScript": {
41+
"formatter": { "language_server": { "name": "prettier" } }
42+
},
43+
"TypeScript": {
44+
"show_edit_predictions": true,
45+
"language_servers": ["!typescript-language-server", "vtsls", "..."],
46+
"formatter": { "language_server": { "name": "prettier" } }
47+
},
48+
"TSX": {
49+
"show_edit_predictions": true,
50+
"language_servers": ["!typescript-language-server", "vtsls", "..."],
51+
"formatter": { "language_server": { "name": "prettier" } }
52+
},
53+
"JSON": { "formatter": { "language_server": { "name": "prettier" } } },
54+
"JSONC": { "formatter": { "language_server": { "name": "prettier" } } },
55+
"CSS": { "formatter": { "language_server": { "name": "prettier" } } },
56+
"GraphQL": { "formatter": { "language_server": { "name": "prettier" } } }
57+
}
58+
}

docs/basics/configuration.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,37 @@ This way you can save even up to 33% of the generation process time.
8686
:::info
8787
When the generator is configured to emit transpiled code, the generated JS code is always formatted by TypeScript compiler and you can't change it to Prettier or disable the formatting by the `formatGeneratedCode` option.
8888
:::
89+
90+
## Verbose logging
91+
92+
By default, the generator runs quietly and only shows essential information. However, during development or debugging, you might want to see detailed timing information and performance metrics for each generation phase.
93+
94+
You can enable verbose logging by setting the `verboseLogging` option to `true`:
95+
96+
```prisma {4}
97+
generator typegraphql {
98+
provider = "typegraphql-prisma"
99+
output = "../prisma/generated/type-graphql"
100+
verboseLogging = true
101+
}
102+
```
103+
104+
When enabled, the generator will output detailed information including:
105+
106+
- Directory setup time
107+
- DMMF generation time
108+
- Configuration parsing time
109+
- Detailed DMMF comparison statistics
110+
- Code generation phase timings
111+
- Performance metrics and insights
112+
- Total generation time breakdown
113+
114+
This is particularly useful for:
115+
116+
- Performance analysis and optimization
117+
- Debugging generation issues
118+
- Understanding which parts of your schema take the most time to process
119+
120+
:::tip
121+
Keep `verboseLogging` disabled in production environments to reduce console noise and improve performance.
122+
:::

0 commit comments

Comments
 (0)