1 Memory usage with libtuv on iotjs is described here and compared to libuv.
3 * Compared with release version in i686.
4 * iotjs version: hash f8e8391d8c30a76c2f82644e454056c11a2bad1a
6 #### runtime memory usage compare with libuv running iotjs
12 ./tools/build.py --buildtype=release --nochecktest
16 ./tools/build.py --buildtype=release --nochecktest --tuv
18 2) memory usage measurement with valgrind running `test httpserver`
20 valgrind ./build/i686-linux/release/iotjs/iotjs ./test/run_pass/test_httpserver.js
25 ==5740== Memcheck, a memory error detector
26 ==5740== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
27 ==5740== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
28 ==5740== Command: ./build/i686-linux/release/iotjs/iotjs ./test/run_pass/test_httpserver.js
31 ==5740== HEAP SUMMARY:
32 ==5740== in use at exit: 0 bytes in 0 blocks
33 ==5740== total heap usage: 959 allocs, 959 frees, 482,669 bytes allocated
35 ==5740== All heap blocks were freed -- no leaks are possible
37 ==5740== For counts of detected and suppressed errors, rerun with: -v
38 ==5740== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
43 ==7584== Memcheck, a memory error detector
44 ==7584== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
45 ==7584== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
46 ==7584== Command: ./build/i686-linux/release/iotjs/iotjs ./test/run_pass/test_httpserver.js
49 ==7584== HEAP SUMMARY:
50 ==7584== in use at exit: 0 bytes in 0 blocks
51 ==7584== total heap usage: 955 allocs, 955 frees, 481,645 bytes allocated
53 ==7584== All heap blocks were freed -- no leaks are possible
55 ==7584== For counts of detected and suppressed errors, rerun with: -v
56 ==7584== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
59 482,669 vs 481,645 = 1,024 bytes saved
65 ./tools/build.py --buildtype=release --nochecktest --target-arch=arm --target-os=linux
66 ./tools/build.py --buildtype=release --nochecktest --target-arch=arm --target-os=linux --tuv
69 2) binary size in i686-linux
71 * libuv : 213,130 / iotjs: 2,512,292, stripped: 782,152
72 * libtuv: 103,158 / iotjs: 2,460,357, stripped: 732,776
73 * itself: 109,972 smaller, iotjs: 51,935(striped 49,376) saved
75 3) binary size in arm-linux
77 * libuv : 176,614 / iotjs: 2,543,525, stripped: 536,460
78 * libtuv: 83,458 / iotjs: 2,506,455, stripped: 507,548
79 * itself: 93,156 smaller, iotjs: 37,070(stripped: 28,912) saved
81 #### libuv vs libtuv itself
83 1) use `tuvtester` as an application to compare.
85 2) codes changes to make both libuv.a and libtuv.a interchangeable.
87 2-1) as libtuv uses c++ compiler, wrap all codes with
93 2-2) for libuv, give `libuv.a` by changing `tuvtest.cmake` file. use file from iotjs build.
95 target_link_libraries(${TUVTESTNAME} LINK_PUBLIC
97 "/(absolute path to libuv)/libuv.a"
101 2-3) some functions that does not exist in libuv. add this bottom of in runner_main.cpp
105 #define uv__handle_deinit(h) \
107 QUEUE_REMOVE(&(h)->handle_queue); \
108 QUEUE_INIT(&(h)->handle_queue); \
112 void uv_deinit(uv_loop_t* loop, uv_handle_t* handle) {
116 QUEUE_FOREACH(q, &loop->handles_queue) {
117 h = QUEUE_DATA(q, uv_handle_t, handle_queue);
119 uv__handle_deinit(handle);
128 2-4) remove test codes that does not run with libuv, tested codes are like this in runner_list.h
130 #define TEST_LIST_ALL(TE) \
131 TE(idle_basic, 5000) \
132 TE(timer_init, 5000) \
134 TE(condvar_2, 5000) \
135 TE(condvar_3, 5000) \
138 TE(fs_file_noent, 5000) \
139 TE(fs_file_sync, 5000) \
140 TE(fs_file_async, 5000) \
141 TE(fs_file_write_null_buffer, 5000) \
142 TE(fs_stat_missing_path, 5000) \
143 TE(fs_open_dir, 5000) \
144 TE(fs_file_open_append, 5000) \
145 TE(fs_read_file_eof, 5000) \
147 TE(threadpool_queue_work_simple, 5000) \
150 // shutdown_eof should be last of tcp test, it'll stop "echo_sevrer"
152 #if defined(__linux__)
153 #define TEST_LIST_EXT(TE) \
156 #define TEST_LIST_EXT(TE) \
160 #define HELPER_LIST_ALL(TE) \
168 valgrind ./build/i686-linux/release/bin/tuvtester
173 ==24952== Memcheck, a memory error detector
174 ==24952== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
175 ==24952== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
176 ==24952== Command: ./build/i686-linux/release/bin/tuvtester
184 [fs_file_noent ]...OK
186 [fs_file_async ]...OK
187 [fs_file_write_null_buffer ]...OK
188 [fs_stat_missing_path ]...OK
190 [fs_file_open_append ]...OK
191 [fs_read_file_eof ]...OK
192 [threadpool_queue_work_simple ]...OK
193 Waiting Helpers to end...
195 ==24952== HEAP SUMMARY:
196 ==24952== in use at exit: 0 bytes in 0 blocks
197 ==24952== total heap usage: 44 allocs, 44 frees, 1,727 bytes allocated
199 ==24952== All heap blocks were freed -- no leaks are possible
201 ==24952== For counts of detected and suppressed errors, rerun with: -v
202 ==24952== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
207 ==26621== Memcheck, a memory error detector
208 ==26621== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
209 ==26621== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
210 ==26621== Command: ./build/i686-linux/release/bin/tuvtester
218 [fs_file_noent ]...OK
220 [fs_file_async ]...OK
221 [fs_file_write_null_buffer ]...OK
222 [fs_stat_missing_path ]...OK
224 [fs_file_open_append ]...OK
225 [fs_read_file_eof ]...OK
226 [threadpool_queue_work_simple ]...OK
227 Waiting Helpers to end...
229 ==26621== HEAP SUMMARY:
230 ==26621== in use at exit: 0 bytes in 0 blocks
231 ==26621== total heap usage: 40 allocs, 40 frees, 991 bytes allocated
233 ==26621== All heap blocks were freed -- no leaks are possible
235 ==26621== For counts of detected and suppressed errors, rerun with: -v