Skip to content

Commit 304edc1

Browse files
authored
Switch to prebuildify (#13)
Perf improvements Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
1 parent ab7b413 commit 304edc1

9 files changed

Lines changed: 151 additions & 385 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ concurrency:
1515
jobs:
1616
build:
1717
runs-on: ${{ matrix.os }}
18-
permissions:
19-
contents: write
20-
packages: write
21-
id-token: write
2218
strategy:
2319
fail-fast: false
2420
matrix:
@@ -61,7 +57,7 @@ jobs:
6157

6258
name: ${{ matrix.os }} (host=${{ matrix.host }}, target=${{ matrix.target }})
6359
steps:
64-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
60+
- uses: actions/checkout@v4
6561
- uses: actions/setup-node@v4
6662
with:
6763
node-version: ${{ matrix.node }}
@@ -102,41 +98,29 @@ jobs:
10298
echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
10399
104100
- name: Build binaries
105-
run: yarn prebuild -a ${{ env.TARGET }}
101+
run: yarn prebuild --arch ${{ env.TARGET }} --tag-libc
106102

107103
- name: Print binary info
108104
if: contains(matrix.os, 'ubuntu')
109105
run: |
110-
ldd build/**/node_sqlite3.node
106+
ldd prebuilds/*/*.node
111107
echo "---"
112-
nm build/**/node_sqlite3.node | grep "GLIBC_" | c++filt || true
108+
nm prebuilds/*/*.node | grep "GLIBC_" | c++filt || true
113109
echo "---"
114-
file build/**/node_sqlite3.node
110+
file prebuilds/*/*.node
115111
116112
- name: Run tests
117113
run: yarn test
118114

119-
- name: Upload binaries to commit artifacts
115+
- name: Upload prebuilds to artifacts
120116
uses: actions/upload-artifact@v4
121-
if: matrix.node == 24 && matrix.os == 'ubuntu-22.04'
122117
with:
123-
name: prebuilt-binaries
124-
path: prebuilds/*
118+
name: prebuilds-${{ matrix.os }}-${{ matrix.host }}-${{ matrix.target }}-${{ matrix.node }}
119+
path: prebuilds/
125120
retention-days: 7
126121

127-
- name: Upload binaries to GitHub Release
128-
run: yarn upload --upload-all ${{ github.token }}
129-
if: startsWith(github.ref, 'refs/tags/')
130-
- name: Publish
131-
run: |
132-
npm publish --provenance --access=public
133-
if: matrix.node == 24 && matrix.os == 'ubuntu-22.04' && startsWith(github.ref, 'refs/tags/')
134122
build-qemu:
135123
runs-on: ubuntu-24.04-arm
136-
permissions:
137-
contents: write
138-
packages: write
139-
id-token: write
140124
strategy:
141125
fail-fast: false
142126
matrix:
@@ -159,7 +143,7 @@ jobs:
159143
node: 22
160144
name: ${{ matrix.variant }} (node=${{ matrix.node }}, target=${{ matrix.target }})
161145
steps:
162-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
146+
- uses: actions/checkout@v4
163147

164148
- name: Set up QEMU
165149
uses: docker/setup-qemu-action@v3
@@ -180,7 +164,47 @@ jobs:
180164
.
181165
CONTAINER_ID=$(docker create -it sqlite-builder)
182166
docker cp $CONTAINER_ID:/usr/src/build/prebuilds/ ./prebuilds
167+
- name: Sanitize target name for Artifact
168+
run: |
169+
SAFE_TARGET=$(echo "${{ matrix.target }}" | tr '/' '-')
170+
echo "SAFE_TARGET=$SAFE_TARGET" >> $GITHUB_ENV
171+
- name: Upload QEMU prebuilds to artifacts
172+
uses: actions/upload-artifact@v4
173+
with:
174+
name: prebuilds-qemu-${{ matrix.variant }}-${{ env.SAFE_TARGET }}-${{ matrix.node }}
175+
path: prebuilds/
176+
retention-days: 7
177+
178+
publish:
179+
needs: [build, build-qemu]
180+
runs-on: ubuntu-22.04
181+
permissions:
182+
contents: write
183+
packages: write
184+
id-token: write
185+
steps:
186+
- uses: actions/checkout@v4
187+
188+
- uses: actions/setup-node@v4
189+
with:
190+
node-version: 24
191+
scope: '@appthreat'
192+
193+
- name: Download and merge all prebuilds
194+
uses: actions/download-artifact@v4
195+
with:
196+
pattern: prebuilds-*
197+
path: prebuilds/
198+
merge-multiple: true
199+
200+
- name: Add yarn
201+
run: npm install -g yarn
202+
203+
- name: Install dependencies
204+
run: |
205+
yarn install --ignore-scripts
206+
npm publish --dry-run
183207
184-
- name: Upload binaries to GitHub Release
185-
run: yarn install --ignore-scripts && yarn upload --upload-all ${{ github.token }}
208+
- name: Publish to npm
209+
run: npm publish --provenance --access=public
186210
if: startsWith(github.ref, 'refs/tags/')

deps/common-sqlite.gypi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
'-O2'
4646
],
4747
'GCC_OPTIMIZATION_LEVEL': '3',
48+
'LLVM_LTO': 'YES',
49+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',
4850
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
4951
'DEAD_CODE_STRIPPING': 'YES',
5052
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES'
@@ -57,4 +59,4 @@
5759
}
5860
}
5961
}
60-
}
62+
}

deps/sqlite3.gyp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
'target_defaults': {
99
'default_configuration': 'Release',
1010
"cflags": [
11-
'-O3', '-flto', '-pipe', '-ffunction-sections', '-fdata-sections'
11+
'-O3', '-flto', '-pipe', '-ffunction-sections', '-fdata-sections', '-fvisibility=hidden'
1212
],
1313
'cxxflags':[
14-
'-O3', '-flto', '-pipe', '-ffunction-sections', '-fdata-sections'
14+
'-O3', '-flto', '-pipe', '-ffunction-sections', '-fdata-sections', '-fvisibility=hidden'
1515
],
16-
'ldflags': [ '-flto', '-Wl,--gc-sections','-s' ],
16+
'ldflags': [ '-flto', '-Wl,--gc-sections', '-s' ],
1717
'configurations': {
1818
'Debug': {
1919
'defines': [ 'DEBUG', '_DEBUG' ],
@@ -35,6 +35,8 @@
3535
'msvs_settings': {
3636
'VCCLCompilerTool': {
3737
'Optimization': 2, # /O2
38+
'FavorSizeOrSpeed': 1, # /Ot (Favor fast code)
39+
'StringPooling': 'true', # /GF
3840
'EnableFunctionLevelLinking': 'true', # /Gy
3941
'EnableIntrinsicFunctions': 'true',
4042
},
@@ -103,4 +105,4 @@
103105
],
104106
}
105107
]
106-
}
108+
}

0 commit comments

Comments
 (0)