File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -61,5 +61,8 @@ RUN find /nodejs/node_modules -name "*.cjs.map" -delete
61
61
RUN find /nodejs/node_modules -name "*.ts.map" -delete
62
62
RUN find /nodejs/node_modules -name "*.md" -delete
63
63
64
+ # Warm up compile cache
65
+ RUN node -e "require('/nodejs/node_modules/datadog-lambda-js/runtime/module_importer').initTracer()"
66
+
64
67
FROM scratch
65
68
COPY --from=builder /nodejs /
Original file line number Diff line number Diff line change 43
43
"hot-shots" : " 8.5.0" ,
44
44
"promise-retry" : " ^2.0.1" ,
45
45
"serialize-error" : " ^8.1.0" ,
46
- "shimmer" : " 1.2.1"
46
+ "shimmer" : " 1.2.1" ,
47
+ "v8-compile-cache" : " ^2.4.0"
47
48
},
48
49
"jest" : {
49
50
"verbose" : true ,
Original file line number Diff line number Diff line change 1
1
2
2
const { logDebug, updateDDTags } = require ( "../utils" ) ;
3
3
4
+ function compileCache ( ) {
5
+ const { FileSystemBlobStore, NativeCompileCache } = require ( 'v8-compile-cache' ) . __TEST__
6
+
7
+ const cacheDir = __dirname
8
+ const prefix = 'module_importer'
9
+ const blobStore = new FileSystemBlobStore ( cacheDir , prefix )
10
+
11
+ const nativeCompileCache = new NativeCompileCache ( )
12
+ nativeCompileCache . setCacheStore ( blobStore )
13
+ nativeCompileCache . install ( )
14
+
15
+ process . once ( 'exit' , ( ) => {
16
+ if ( blobStore . isDirty ( ) ) {
17
+ blobStore . save ( )
18
+ }
19
+ nativeCompileCache . uninstall ( )
20
+ } )
21
+ }
22
+
4
23
// Currently no way to prevent typescript from auto-transpiling import into require,
5
24
// so we expose a wrapper in js
6
25
exports . import = function ( path ) {
7
26
return import ( path ) ;
8
27
}
9
28
10
29
exports . initTracer = function ( ) {
30
+ compileCache ( )
31
+
11
32
// Looks for the function local version of dd-trace first, before using
12
33
// the version provided by the layer
13
34
const path = require . resolve ( "dd-trace" , { paths : [ "/var/task/node_modules" , ...module . paths ] } ) ;
Original file line number Diff line number Diff line change @@ -4075,6 +4075,11 @@ uuid@^9.0.1:
4075
4075
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
4076
4076
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
4077
4077
4078
+ v8-compile-cache@^2.4.0 :
4079
+ version "2.4.0"
4080
+ resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz#cdada8bec61e15865f05d097c5f4fd30e94dc128"
4081
+ integrity sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==
4082
+
4078
4083
v8-to-istanbul@^8.1.0 :
4079
4084
version "8.1.1"
4080
4085
resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz#77b752fd3975e31bbcef938f85e9bd1c7a8d60ed"
You can’t perform that action at this time.
0 commit comments