test: stress test on aarch64 linux gnu platform (#2662)

* test: stress test on aarch64 linux gnu platform

* remove configs in yarnrc

* clippy
This commit is contained in:
LongYinan 2025-06-02 22:45:01 +08:00 committed by GitHub
parent 23dbcd81fe
commit b93bdfd3eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 17 deletions

View File

@ -102,6 +102,7 @@ struct DeferredData<Data: ToNapiValue, Resolver: FnOnce(Env) -> Result<Data>> {
resolver: Result<Resolver>,
#[cfg(feature = "deferred_trace")]
trace: DeferredTrace,
tsfn: sys::napi_threadsafe_function,
}
pub struct JsDeferred<Data: ToNapiValue, Resolver: FnOnce(Env) -> Result<Data>> {
@ -164,6 +165,7 @@ impl<Data: ToNapiValue, Resolver: FnOnce(Env) -> Result<Data>> JsDeferred<Data,
resolver: result,
#[cfg(feature = "deferred_trace")]
trace: self.trace,
tsfn: self.tsfn,
};
// Call back into the JS thread via a threadsafe function. This results in napi_resolve_deferred being called.
@ -178,14 +180,6 @@ impl<Data: ToNapiValue, Resolver: FnOnce(Env) -> Result<Data>> JsDeferred<Data,
status == sys::Status::napi_ok,
"Call threadsafe function in JsDeferred failed"
);
let status = unsafe {
sys::napi_release_threadsafe_function(self.tsfn, sys::ThreadsafeFunctionReleaseMode::release)
};
debug_assert!(
status == sys::Status::napi_ok,
"Release threadsafe function in JsDeferred failed"
);
}
}
@ -247,12 +241,20 @@ extern "C" fn napi_resolve_deferred<Data: ToNapiValue, Resolver: FnOnce(Env) ->
) {
let deferred = context.cast();
let deferred_data: Box<DeferredData<Data, Resolver>> = unsafe { Box::from_raw(data.cast()) };
let tsfn = deferred_data.tsfn;
let result = deferred_data
.resolver
.and_then(|resolver| resolver(Env::from_raw(env)))
.and_then(|res| unsafe { ToNapiValue::to_napi_value(env, res) });
if let Err(e) = result.and_then(|res| {
let release_tsfn_result = check_status!(
unsafe {
sys::napi_release_threadsafe_function(tsfn, sys::ThreadsafeFunctionReleaseMode::release)
},
"Release threadsafe function in JsDeferred failed"
);
if let Err(e) = release_tsfn_result.and(result).and_then(|res| {
check_status!(
unsafe { sys::napi_resolve_deferred(env, deferred, res) },
"Resolve deferred value failed"

View File

@ -8,15 +8,11 @@ import { Animal, Kind, DEFAULT_COST, shutdownRuntime } from '../index.cjs'
const __dirname = join(fileURLToPath(import.meta.url), '..')
const t =
// aarch64-unknown-linux-gnu is extremely slow in CI, skip it or it will timeout
process.arch === 'arm64' && process.platform === 'linux' ? test.skip : test
const concurrency =
(process.platform === 'win32' ||
process.platform === 'darwin' ||
(process.platform === 'linux' &&
process.arch === 'x64' &&
(process.arch === 'x64' || process.arch === 'arm64') &&
// @ts-expect-error
process?.report?.getReport()?.header?.glibcVersionRuntime)) &&
!process.env.WASI_TEST &&
@ -28,7 +24,7 @@ test.after(() => {
shutdownRuntime()
})
t('should be able to require in worker thread', async (t) => {
test('should be able to require in worker thread', async (t) => {
await Promise.all(
Array.from({ length: concurrency }).map(() => {
const w = new Worker(join(__dirname, 'worker.js'), {
@ -52,7 +48,7 @@ t('should be able to require in worker thread', async (t) => {
)
})
t('custom GC works on worker_threads', async (t) => {
test('custom GC works on worker_threads', async (t) => {
await Promise.all(
Array.from({ length: concurrency }).map(() =>
Promise.all([
@ -95,7 +91,7 @@ t('custom GC works on worker_threads', async (t) => {
)
})
t('should be able to new Class in worker thread concurrently', async (t) => {
test('should be able to new Class in worker thread concurrently', async (t) => {
await Promise.all(
Array.from({ length: concurrency }).map(() => {
const w = new Worker(join(__dirname, 'worker.js'), {