1
- import { provideDummyTracing , provideJaegerTracing } from '@contentlayer/utils'
1
+ import { provideJaegerTracing } from '@contentlayer/utils'
2
2
import { pipe , provideConsole , T } from '@contentlayer/utils/effect'
3
3
import type { _A , _E } from '@effect-ts/core/Utils'
4
4
import * as os from 'node:os'
@@ -14,6 +14,7 @@ export type Either<E, A> = Left<E, A> | Right<E, A>
14
14
15
15
type DTO = Either < _E < ReturnType < F > > , _A < ReturnType < F > > >
16
16
17
+ // TODO: generalize codec / serializing
17
18
// FIXME: naming
18
19
export function fromWorkerPool ( ) : F {
19
20
const cores = os . cpus ( ) . length
@@ -24,7 +25,7 @@ export function fromWorkerPool(): F {
24
25
//
25
26
// via https://github.com/piscinajs/piscina#queue-size
26
27
maxQueue : cores ** cores ,
27
- // by default, this is cores * 1.5
28
+ // FIXME: on the default, (# cores * 1.5), this lead to memory issues that caused a thread panic
28
29
maxThreads : cores ,
29
30
// FIXME: get path dynamically
30
31
filename :
@@ -34,7 +35,7 @@ export function fromWorkerPool(): F {
34
35
return ( payload ) =>
35
36
pipe (
36
37
// host -> worker
37
- T . succeedWith ( ( ) => JSON . stringify ( payload , null , 2 ) ) ,
38
+ T . succeedWith ( ( ) => JSON . stringify ( payload ) ) ,
38
39
T . chain ( ( value ) => T . promise < string > ( ( ) => pool . run ( value , { name : 'makeCacheItemFromFilePath' } ) ) ) ,
39
40
// worker -> host
40
41
T . chain ( ( value ) => T . succeedWith < DTO > ( ( ) => JSON . parse ( value ) ) ) ,
@@ -62,6 +63,6 @@ export function makeCacheItemFromFilePath(payload: string): Promise<string> {
62
63
provideConsole ,
63
64
provideJaegerTracing ( 'worker' ) ,
64
65
T . runPromise ,
65
- ( p ) => p . then ( ( value ) => JSON . stringify ( value , null , 2 ) ) ,
66
+ ( p ) => p . then ( ( value ) => JSON . stringify ( value ) ) ,
66
67
)
67
68
}
0 commit comments