Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.

5.0.1 (in development)
----------------------
- `logReadFiles` was removed from the default `INCOMING_MODULE_JS_API` list.
To use this feature you now need to explictly add `logReadFiles` to
`INCOMING_MODULE_JS_API`. (#26190);

5.0.0 - 01/24/26
----------------
Expand Down
12 changes: 9 additions & 3 deletions site/source/docs/porting/files/packaging_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,15 @@ Monitoring file usage

.. important:: Only package the files your app actually needs, in order to reduce download size and improve startup speed.

There is an option to log which files are actually used at runtime. To use it, define the :js:attr:`Module.logReadFiles` object. Each file that is read will be logged to stderr.

An alternative approach is to look at :js:func:`FS.readFiles` in your compiled JavaScript. This is an object with keys for all the files that were read from. You may find it easier to use than logging as it records files rather than potentially multiple file accesses.
There is an option to log which files are actually used at runtime. To use it,
define the :js:attr:`Module.logReadFiles` object. Each file that is read will be
logged to stderr. To use this feautre you need to add ``logReadFiles`` to
:ref:`INCOMING_MODULE_JS_API`.

An alternative approach is to look at :js:func:`FS.readFiles` in your compiled
JavaScript. This is an object with keys for all the files that were read from.
You may find it easier to use than logging as it records files rather than
potentially multiple file accesses.

.. note:: You can also modify the :js:func:`FS.readFiles` object or remove it entirely. This can be useful, say, in order to see which files are read between two points in time in your app.

Expand Down
2 changes: 1 addition & 1 deletion src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ var INCOMING_MODULE_JS_API = [
'buffer', 'canvas', 'doNotCaptureKeyboard', 'dynamicLibraries',
'elementPointerLock', 'extraStackTrace', 'forcedAspectRatio',
'instantiateWasm', 'keyboardListeningElement', 'freePreloadedMediaOnUse',
'loadSplitModule', 'locateFile', 'logReadFiles', 'mainScriptUrlOrBlob', 'mem',
'loadSplitModule', 'locateFile', 'mainScriptUrlOrBlob', 'mem',
'monitorRunDependencies', 'noExitRuntime', 'noInitialRun', 'onAbort',
'onExit', 'onFree', 'onFullScreen', 'onMalloc',
'onRealloc', 'onRuntimeInitialized', 'postMainLoop', 'postRun', 'preInit',
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors1.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19623,
"a.out.js.gz": 8144,
"a.out.js": 19555,
"a.out.js.gz": 8102,
"a.out.nodebug.wasm": 132844,
"a.out.nodebug.wasm.gz": 49884,
"total": 152467,
"total_gz": 58028,
"total": 152399,
"total_gz": 57986,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors2.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19600,
"a.out.js.gz": 8131,
"a.out.js": 19532,
"a.out.js.gz": 8087,
"a.out.nodebug.wasm": 132264,
"a.out.nodebug.wasm.gz": 49542,
"total": 151864,
"total_gz": 57673,
"total": 151796,
"total_gz": 57629,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 23284,
"a.out.js.gz": 9122,
"a.out.js": 23216,
"a.out.js.gz": 9081,
"a.out.nodebug.wasm": 172774,
"a.out.nodebug.wasm.gz": 57405,
"total": 196058,
"total_gz": 66527,
"total": 195990,
"total_gz": 66486,
"sent": [
"__cxa_begin_catch",
"__cxa_end_catch",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19434,
"a.out.js.gz": 8068,
"a.out.js": 19366,
"a.out.js.gz": 8022,
"a.out.nodebug.wasm": 148169,
"a.out.nodebug.wasm.gz": 55285,
"total": 167603,
"total_gz": 63353,
"total": 167535,
"total_gz": 63307,
"sent": [
"_abort_js",
"_tzset_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm_legacy.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19508,
"a.out.js.gz": 8088,
"a.out.js": 19440,
"a.out.js.gz": 8042,
"a.out.nodebug.wasm": 145975,
"a.out.nodebug.wasm.gz": 54915,
"total": 165483,
"total_gz": 63003,
"total": 165415,
"total_gz": 62957,
"sent": [
"_abort_js",
"_tzset_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_lto.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 18970,
"a.out.js.gz": 7824,
"a.out.js": 18902,
"a.out.js.gz": 7782,
"a.out.nodebug.wasm": 102076,
"a.out.nodebug.wasm.gz": 39428,
"total": 121046,
"total_gz": 47252,
"total": 120978,
"total_gz": 47210,
"sent": [
"a (emscripten_resize_heap)",
"b (_setitimer_js)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_mangle.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 23334,
"a.out.js.gz": 9141,
"a.out.js": 23266,
"a.out.js.gz": 9101,
"a.out.nodebug.wasm": 239224,
"a.out.nodebug.wasm.gz": 79795,
"total": 262558,
"total_gz": 88936,
"total": 262490,
"total_gz": 88896,
"sent": [
"__cxa_begin_catch",
"__cxa_end_catch",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_noexcept.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19623,
"a.out.js.gz": 8144,
"a.out.js": 19555,
"a.out.js.gz": 8102,
"a.out.nodebug.wasm": 134851,
"a.out.nodebug.wasm.gz": 50712,
"total": 154474,
"total_gz": 58856,
"total": 154406,
"total_gz": 58814,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_files_js_fs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 18241,
"a.out.js.gz": 7465,
"a.out.js": 18174,
"a.out.js.gz": 7430,
"a.out.nodebug.wasm": 381,
"a.out.nodebug.wasm.gz": 260,
"total": 18622,
"total_gz": 7725,
"total": 18555,
"total_gz": 7690,
"sent": [
"a (fd_write)",
"b (fd_read)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_O0.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 24225,
"a.out.js.gz": 8703,
"a.out.js": 24246,
"a.out.js.gz": 8709,
"a.out.nodebug.wasm": 15138,
"a.out.nodebug.wasm.gz": 7455,
"total": 39363,
"total_gz": 16158,
"total": 39384,
"total_gz": 16164,
"sent": [
"fd_write"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 26663,
"a.out.js.gz": 11392,
"a.out.js": 26596,
"a.out.js.gz": 11356,
"a.out.nodebug.wasm": 17730,
"a.out.nodebug.wasm.gz": 8957,
"total": 44393,
"total_gz": 20349,
"total": 44326,
"total_gz": 20313,
"sent": [
"__syscall_stat64",
"emscripten_resize_heap",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 244840,
"a.out.js": 244769,
"a.out.nodebug.wasm": 577863,
"total": 822703,
"total": 822632,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
2 changes: 1 addition & 1 deletion test/codesize/test_codesize_minimal_O0.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,6 @@ function checkIncomingModuleAPI() {
ignoredModuleProp('freePreloadedMediaOnUse');
ignoredModuleProp('loadSplitModule');
ignoredModuleProp('locateFile');
ignoredModuleProp('logReadFiles');
ignoredModuleProp('mainScriptUrlOrBlob');
ignoredModuleProp('mem');
ignoredModuleProp('monitorRunDependencies');
Expand Down Expand Up @@ -1309,6 +1308,7 @@ function checkIncomingModuleAPI() {
ignoredModuleProp('wasmBinary');
ignoredModuleProp('websocket');
ignoredModuleProp('fetchSettings');
ignoredModuleProp('logReadFiles');
}

// Imports from the Wasm binary.
Expand Down
10 changes: 5 additions & 5 deletions test/codesize/test_unoptimized_code_size.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"hello_world.js": 56906,
"hello_world.js.gz": 17709,
"hello_world.js": 56925,
"hello_world.js.gz": 17717,
"hello_world.wasm": 15138,
"hello_world.wasm.gz": 7455,
"no_asserts.js": 26576,
"no_asserts.js.gz": 8881,
"no_asserts.wasm": 12187,
"no_asserts.wasm.gz": 5984,
"strict.js": 54881,
"strict.js.gz": 17045,
"strict.js.gz": 17046,
"strict.wasm": 15138,
"strict.wasm.gz": 7450,
"total": 180826,
"total_gz": 64524
"total": 180845,
"total_gz": 64533
}
2 changes: 1 addition & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -15341,7 +15341,7 @@ def test_executable_requires_node(self):

def test_logReadFiles(self):
create_file('test.txt', 'hello')
self.cflags += ['--preload-file=test.txt']
self.cflags += ['--preload-file=test.txt', '-sINCOMING_MODULE_JS_API=logReadFiles']

output = self.do_runf('checksummer.c', args=['test.txt'])
self.assertNotContained('read file:', output)
Expand Down
1 change: 1 addition & 0 deletions tools/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
# default set.
EXTRA_INCOMING_JS_API = [
'fetchSettings',
'logReadFiles',
]

logger = logging.getLogger('args')
Expand Down