Wt embedded » History » Version 6
Pieter Libin, 10/29/2009 03:00 PM
1 | 1 | Pieter Libin | h1. Wt embedded |
---|---|---|---|
2 | |||
3 | {{toc}} |
||
4 | |||
5 | Find here information on running Wt in resource constrained embedded systems: performance, code size, memory usage, and other info. |
||
6 | |||
7 | |||
8 | h2. General |
||
9 | |||
10 | Wt can easily be built for and deployed on embedded POSIX systems, such as embedded linux. |
||
11 | |||
12 | |||
13 | h3. Cross-building |
||
14 | |||
15 | Using CMake with a cross compilation environment: to be completed... |
||
16 | |||
17 | Instructions for cross compiling with cmake can be found on the "CMake Wiki":http://www.cmake.org/Wiki/CMake_Cross_Compiling. If you encounter the following error a workaround is to replace $Build/src/filetostring with a version compiled with your native compiler. |
||
18 | |||
19 | <pre> |
||
20 | /bin/sh: ./filetostring: cannot execute binary file |
||
21 | </pre> |
||
22 | |||
23 | |||
24 | h3. Optimizing executable size |
||
25 | |||
26 | Points to consider when optimizing the executable size: |
||
27 | |||
28 | * Choose build-type <tt>MinSizeRel</tt> |
||
29 | * Add extra compile FLAGS: <tt>-fvisibility=hidden</tt> (to avoid listing symbols in the executable) |
||
30 | * Add extra compile FLAGS: -DHAVE_GNU_REGEX to avoid the dependency on libboost_regex, when building on a system that is based on glibc or uClibc. |
||
31 | * _*Add extra compile FLAGS: -DNO_SPIRIT to not use spirit for parsing locale and cookies (FIXME: not yet supported)*_ |
||
32 | * Build static libraries (for libwt.a and libwthttp.a) |
||
33 | * Disable build options you don't need and introduce extra dependencies (libz, openssl ?) |
||
34 | * Link statically to all libraries that you use only for Wt (such as for example the boost libraries). You will need to do this manually since this currently isn't supported in the CMake build process. In this way, only used symbols from these libraries (including the static wt and wthttp) will be kept. |
||
35 | * Strip your binary using <tt>strip -s</tt>. |
||
36 | * Optionally, when available for your platform, you may want to compress the size of your binary using the "Ultimate Packer for eXecutables (upx)":http://upx.sourceforge.net/. This typically reduces executable size further by 60-70%, without noticable run-time performance hits. |
||
37 | |||
38 | |||
39 | h3. Measuring performance |
||
40 | |||
41 | To report the run-time performance of Wt on a particular embedded platform, you must connect to the device using a local area connection (through at most one switch), and measure the time between transmission and reception of packets (using a packet sniffer). For the measurements, we use two examples that are included in the Wt distribution: "hello":http://www.webtoolkit.eu/wt/examples/hello/hello.wt (as an example of a minimal application), and "composer":http://www.webtoolkit.eu/wt/examples/composer/composer.wt (as an example of a simple, yet functional, application). |
||
42 | |||
43 | We propose to measure the time to create a new session, and the time of a small event. |
||
44 | |||
45 | |||
46 | h4. Runtime: new session |
||
47 | |||
48 | Wt starts a new session by serving a small page to determines browser capabilities, and then trigger a second call to get the "main page", that has all visible content. To compare the relative performance for a particular platform, you should measure this "load" time, as the total duration of these two requests. You should measure the time from sending the first request, to sending the third request. The third request is either a GET request for auxiliary content (CSS or images), a GET request to a Wt resource, or a POST request to load invisible content in the background. |
||
49 | |||
50 | |||
51 | h4. Runtime: event |
||
52 | |||
53 | We estimate the time needed to process a small event, such as a click on the "Greet me" button in hello, and "Save now" in composer, by measuring the total time for the packet exchange triggered by such an event. |
||
54 | |||
55 | |||
56 | h4. Memory usage: basis |
||
57 | |||
58 | Measuring memory usage is a tricky thing, since code and read-only data memory used by shared libraries is effectively shared between processes, while writable data segments are obviously private to each process. |
||
59 | |||
60 | Therefore, we use <tt>pmap</tt> to study the memory in different segments. The basis RAM usage is divided between read-only segments, and writable segments. Only the latter are really constrained by physical RAM. We get the total writable size. by summing the size of all writable segments, indicated by pmap with a *w*. The total size reported by pmap and top, minus the size of all writable segments is then the read-only RAM usage. Thus, this number includes shared libraries, and thus overestimates actual RAM usage. |
||
61 | |||
62 | |||
63 | h4. Memory usage: per session |
||
64 | |||
65 | Compare the memory usage after starting 10 sessions with base memory usage, and divide the difference by 10 to estimate the memory used by a single session. |
||
66 | |||
67 | |||
68 | h2. Platforms |
||
69 | |||
70 | |||
71 | h3. ARM926EJ-S |
||
72 | |||
73 | |||
74 | h4. Processor features |
||
75 | |||
76 | * Clock-speed: 200 MHz |
||
77 | * Linux BogoMIPS: 89.70 |
||
78 | * Caches: 8K instruction, 8K data |
||
79 | |||
80 | |||
81 | h4. Config #1: minimal |
||
82 | |||
83 | |||
84 | h5. Setup |
||
85 | |||
86 | * *Wt version:* CVS-snapshot 18/03/08 |
||
87 | * *Target system:* Linux uclibc 2.6.23 |
||
88 | * *Build environment:* buildroot, arm-linux-gcc 4.2.1 |
||
89 | * *Options:* with multi-threading, but without libz and OpenSSL |
||
90 | * *Build type:* full static build, except for: libc, libpthread, libdl, libstdc++, and libm |
||
91 | * *Build settings:* MinSizeRel, -DHAVE_GNU_REGEX |
||
92 | * *Runtime settings:* ./app.wt --docroot . --http-address 0.0.0.0 --threads=2 --no-compression |
||
93 | |||
94 | |||
95 | h5. Performance results |
||
96 | |||
97 | 3 | Pieter Libin | |
98 | 4 | Pieter Libin | *Code size and RAM usage (in KBytes)* |
99 | 6 | Pieter Libin | |_.Program|_.Code size (strip)|_.Code size (strip + upx)|_.RAM: basis † (read-only)|_.RAM: basis (writable)|_.RAM: per session| |
100 | 5 | Pieter Libin | | hello| 1.130 | 304 | 2.580 | 372 | 28| |
101 | | composer| 1.265 | 332 | 2.712 | 372 | 126| |
||
102 | 1 | Pieter Libin | |
103 | 3 | Pieter Libin | † includes shared libraries ! |
104 | 1 | Pieter Libin | |
105 | 5 | Pieter Libin | *Runtime-performance* |
106 | 6 | Pieter Libin | |_.Program | _.New session (http) | _.Event (http)| |
107 | 5 | Pieter Libin | | hello | 0.58 s | 0.15 s | |
108 | |composer| 1.8 s | 0.15 s | |