Skip to content

Commit 896e86f

Browse files
committed
fix: general fixes for gitlab ci
- syntax: linting - bench: benchmark working with swc now - test: fixed test timing out in ci - ci: added example and dummy benchmark - ci: allow failure for `build:windows`
1 parent 5060ac7 commit 896e86f

File tree

11 files changed

+424
-45
lines changed

11 files changed

+424
-45
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ build:linux:
169169
build:windows:
170170
stage: build
171171
needs: []
172+
allow_failure: true
172173
tags:
173174
- windows
174175
variables:
@@ -247,7 +248,7 @@ build:prerelease:
247248
needs:
248249
- build:dist
249250
- build:linux
250-
- build:windows
251+
# - build:windows
251252
- build:macos
252253
# Don't interrupt publishing job
253254
interruptible: false
@@ -332,7 +333,7 @@ release:distribution:
332333
needs:
333334
- build:dist
334335
- build:linux
335-
- build:windows
336+
# - build:windows
336337
- build:macos
337338
- integration:merge
338339
# Don't interrupt publishing job

benches/dummy.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import path from 'path';
2+
import b from 'benny';
3+
import { suiteCommon } from './utils';
4+
5+
async function main() {
6+
// Running benchmark
7+
const summary = b.suite(
8+
path.basename(__filename, path.extname(__filename)),
9+
b.add('add 1 + 1', async () => {
10+
return 1 + 1;
11+
}),
12+
b.add('subtract 1 - 1', async () => {
13+
return 1 - 1;
14+
}),
15+
b.add('multiply 1 * 1', async () => {
16+
return 1 * 1;
17+
}),
18+
b.add('divide 1 / 1', async () => {
19+
return 1 / 1;
20+
}),
21+
...suiteCommon,
22+
);
23+
return summary;
24+
}
25+
26+
if (require.main === module) {
27+
void main();
28+
}
29+
30+
export default main;

benches/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
import fs from 'fs';
44
import path from 'path';
55
import si from 'systeminformation';
6+
import Stream1KB from './stream_1KB';
7+
import Dummy from './dummy';
68

79
async function main(): Promise<void> {
810
await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true });
11+
// Running benches
12+
await Stream1KB();
13+
await Dummy();
914
const resultFilenames = await fs.promises.readdir(
1015
path.join(__dirname, 'results'),
1116
);

benches/results/metrics.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# TYPE dummy_ops gauge
2+
dummy_ops{name="add 1 + 1"} 11776647
3+
dummy_ops{name="subtract 1 - 1"} 11685857
4+
dummy_ops{name="multiply 1 * 1"} 12000931
5+
dummy_ops{name="divide 1 / 1"} 11857267
6+
7+
# TYPE dummy_margin gauge
8+
dummy_margin{name="add 1 + 1"} 0.55
9+
dummy_margin{name="subtract 1 - 1"} 0.95
10+
dummy_margin{name="multiply 1 * 1"} 0.48
11+
dummy_margin{name="divide 1 / 1"} 0.58
12+
13+
# TYPE dummy_samples counter
14+
dummy_samples{name="add 1 + 1"} 84
15+
dummy_samples{name="subtract 1 - 1"} 84
16+
dummy_samples{name="multiply 1 * 1"} 85
17+
dummy_samples{name="divide 1 / 1"} 83
18+
19+
# TYPE stream_1KB_ops gauge
20+
stream_1KB_ops{name="send 1Kib of data"} 176
21+
22+
# TYPE stream_1KB_margin gauge
23+
stream_1KB_margin{name="send 1Kib of data"} 2.68
24+
25+
# TYPE stream_1KB_samples counter
26+
stream_1KB_samples{name="send 1Kib of data"} 76

benches/results/system.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
{
22
"cpu": {
3-
"manufacturer": "AMD",
4-
"brand": "Ryzen 7 2700X Eight-Core Processor",
5-
"vendor": "AMD",
6-
"family": "23",
7-
"model": "8",
8-
"stepping": "2",
3+
"manufacturer": "Intel",
4+
"brand": "Xeon® E3-1241 v3",
5+
"vendor": "Intel",
6+
"family": "6",
7+
"model": "60",
8+
"stepping": "3",
99
"revision": "",
1010
"voltage": "",
11-
"speed": 3.7,
12-
"speedMin": 2.2,
13-
"speedMax": 3.7,
11+
"speed": 3.5,
12+
"speedMin": 0.8,
13+
"speedMax": 3.9,
1414
"governor": "performance",
15-
"cores": 16,
16-
"physicalCores": 8,
17-
"performanceCores": 8,
15+
"cores": 8,
16+
"physicalCores": 4,
17+
"performanceCores": 4,
1818
"efficiencyCores": 0,
1919
"processors": 1,
2020
"socket": "",
21-
"flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca sev sev_es",
21+
"flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d",
2222
"virtualization": true,
2323
"cache": {
24-
"l1d": 262144,
25-
"l1i": 524288,
26-
"l2": 4194304,
27-
"l3": 16777216
24+
"l1d": 131072,
25+
"l1i": 131072,
26+
"l2": 1048576,
27+
"l3": 8388608
2828
}
2929
},
3030
"osInfo": {
3131
"platform": "linux",
3232
"distro": "nixos",
3333
"release": "22.11",
34-
"kernel": "6.1.23",
34+
"kernel": "5.10.177",
3535
"arch": "x64"
3636
},
3737
"system": {
38-
"model": "System Product Name",
39-
"manufacturer": "System manufacturer"
38+
"model": "P7 Pro SE",
39+
"manufacturer": "EUROCOM"
4040
}
4141
}

benches/stream_1KB.ts

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import type * as events from '../src/events';
2+
import type { Host } from '../src/types';
3+
import path from 'path';
4+
import fs from 'fs';
5+
import b from 'benny';
6+
import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger';
7+
import { suiteCommon } from './utils';
8+
import QUICServer from '../src/QUICServer';
9+
import * as testsUtils from '../tests/utils';
10+
import QUICClient from '../src/QUICClient';
11+
12+
async function main() {
13+
const logger = new Logger(`Stream1KB Bench`, LogLevel.WARN, [
14+
new StreamHandler(
15+
formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`,
16+
),
17+
]);
18+
// Setting up initial state
19+
const crypto = {
20+
key: await testsUtils.generateKey(),
21+
ops: {
22+
sign: testsUtils.sign,
23+
verify: testsUtils.verify,
24+
randomBytes: testsUtils.randomBytes,
25+
},
26+
};
27+
28+
const data1KiB = Buffer.alloc(1024, 0xf0);
29+
const host = '::ffff:127.0.0.1' as Host;
30+
const certChainPem = await fs.promises.readFile(
31+
path.resolve(path.join(__dirname), '../tests/fixtures/certs/rsa1.crt'),
32+
);
33+
const privKeyPem = await fs.promises.readFile(
34+
path.resolve(path.join(__dirname), '../tests/fixtures/certs/rsa1.key'),
35+
);
36+
37+
const quicServer = new QUICServer({
38+
config: {
39+
tlsConfig: {
40+
privKeyPem: privKeyPem.toString(),
41+
certChainPem: certChainPem.toString(),
42+
},
43+
verifyPeer: false,
44+
},
45+
keepaliveIntervalTime: 1000,
46+
crypto,
47+
logger,
48+
});
49+
quicServer.addEventListener(
50+
'connection',
51+
async (e: events.QUICServerConnectionEvent) => {
52+
const conn = e.detail;
53+
conn.addEventListener(
54+
'stream',
55+
(streamEvent: events.QUICConnectionStreamEvent) => {
56+
const stream = streamEvent.detail;
57+
void Promise.allSettled([
58+
(async () => {
59+
// Consume data
60+
for await (const _ of stream.readable) {
61+
// Do nothing, only consume
62+
}
63+
})(),
64+
(async () => {
65+
// End writable immediately
66+
await stream.writable.close();
67+
})(),
68+
]);
69+
},
70+
);
71+
},
72+
);
73+
await quicServer.start({
74+
host,
75+
});
76+
const client = await QUICClient.createQUICClient({
77+
config: {
78+
verifyPeer: false,
79+
},
80+
host,
81+
port: quicServer.port,
82+
crypto,
83+
logger,
84+
});
85+
// Running benchmark
86+
const summary = b.suite(
87+
path.basename(__filename, path.extname(__filename)),
88+
b.add('send 1Kib of data', async () => {
89+
const stream = await client.connection.streamNew();
90+
await Promise.all([
91+
(async () => {
92+
// Consume data
93+
for await (const _ of stream.readable) {
94+
// Do nothing, only consume
95+
}
96+
})(),
97+
(async () => {
98+
// Write data
99+
const writer = stream.writable.getWriter();
100+
await writer.write(data1KiB);
101+
await writer.close();
102+
})(),
103+
]);
104+
}),
105+
...suiteCommon,
106+
b.complete(async () => {
107+
await quicServer.stop({ force: true });
108+
await client.destroy({ force: true });
109+
}),
110+
);
111+
return summary;
112+
}
113+
114+
if (require.main === module) {
115+
void main();
116+
}
117+
118+
export default main;

benches/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './utils';

benches/utils/utils.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import b from 'benny';
4+
import { codeBlock } from 'common-tags';
5+
import packageJson from '../../package.json';
6+
7+
const suiteCommon = [
8+
b.cycle(),
9+
b.complete(),
10+
b.save({
11+
file: (summary) => summary.name,
12+
folder: path.join(__dirname, '../results'),
13+
version: packageJson.version,
14+
details: true,
15+
}),
16+
b.save({
17+
file: (summary) => summary.name,
18+
folder: path.join(__dirname, '../results'),
19+
version: packageJson.version,
20+
format: 'chart.html',
21+
}),
22+
b.complete((summary) => {
23+
const filePath = path.join(
24+
__dirname,
25+
'../results',
26+
summary.name + '_metrics.txt',
27+
);
28+
fs.writeFileSync(
29+
filePath,
30+
codeBlock`
31+
# TYPE ${summary.name}_ops gauge
32+
${summary.results
33+
.map(
34+
(result) =>
35+
`${summary.name}_ops{name="${result.name}"} ${result.ops}`,
36+
)
37+
.join('\n')}
38+
39+
# TYPE ${summary.name}_margin gauge
40+
${summary.results
41+
.map(
42+
(result) =>
43+
`${summary.name}_margin{name="${result.name}"} ${result.margin}`,
44+
)
45+
.join('\n')}
46+
47+
# TYPE ${summary.name}_samples counter
48+
${summary.results
49+
.map(
50+
(result) =>
51+
`${summary.name}_samples{name="${result.name}"} ${result.samples}`,
52+
)
53+
.join('\n')}
54+
` + '\n',
55+
);
56+
// eslint-disable-next-line no-console
57+
console.log('\nSaved to:', path.resolve(filePath));
58+
}),
59+
];
60+
61+
export { suiteCommon };

0 commit comments

Comments
 (0)