1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00
libwebsockets/lib
Andy Green 3549a94ce6 roles: compress role ops structs
role ops are usually only sparsely filled, there are currently 20
function pointers but several roles only fill in two.  No single
role has more than 14 of the ops.  On a 32/64 bit build this part
of the ops struct takes a fixed 80 / 160 bytes then.

First reduce the type of the callback reason part from uint16_t to
uint8_t, this saves 12 bytes unconditionally.

Change to a separate function pointer array with a nybble index
array, it costs 10 bytes for the index and a pointer to the
separate array, for 32-bit the cost is

2 + (4 x ops_used)

and for 64-bit

6 + (8 x ops_used)

for 2 x ops_used it means 32-bit: 10 vs 80 / 64-bit: 22 vs 160

For a typical system with h1 (9), h2 (14), listen (2), netlink (2),
pipe (1), raw_skt (3), ws (12), == 43 ops_used out of 140, it means
the .rodata for this reduced from 32-bit: 560 -> 174 (386 byte
saving) and 64-bit: 1120 -> 350 (770 byte saving)

This doesn't account for the changed function ops calling code, two
ways were tried, a preprocessor macro and explicit functions

For an x86_64 gcc 10 build with most options, release mode,
.text + .rodata

before patch:          553282
accessor macro:        552714 (568 byte saving)
accessor functions:    553674 (392 bytes worse than without patch)

therefore we went with the macros
2020-11-28 10:58:38 +00:00
..
abstract cmakelist: Augean Stables refactor 2020-05-27 08:40:12 +01:00
core roles: compress role ops structs 2020-11-28 10:58:38 +00:00
core-net roles: compress role ops structs 2020-11-28 10:58:38 +00:00
drivers lws_netdev: fix rssi averaging 2020-07-21 08:16:01 +01:00
event-libs libevent: fix typo in signal handler 2020-10-19 16:35:03 +01:00
jose lws_jwt_token_sanity 2020-07-15 16:18:00 +01:00
misc docs: switch to use main 2020-10-19 16:35:03 +01:00
plat client: rfc6724 dns results sorting 2020-11-28 10:58:07 +00:00
roles roles: compress role ops structs 2020-11-28 10:58:38 +00:00
secure-streams mqtt: lws_system blobs for password username 2020-11-26 09:23:30 +00:00
system client: rfc6724 dns results sorting 2020-11-28 10:58:07 +00:00
tls docs: switch to use main 2020-10-19 16:35:03 +01:00
CMakeLists.txt cmake: add windows version resources to library 2020-10-19 16:35:03 +01:00
README.md cleaning 2020-01-05 22:17:58 +00:00

Library sources layout

Code that goes in the libwebsockets library itself lives down ./lib

Path Sources
lib/core Core lws code related to generic fd and wsi servicing and management
lib/core-net Core lws code that applies only if networking enabled
lib/event-libs Code containing optional event-lib specific adaptations
lib/jose JOSE / JWS / JWK / JWE implementations
lib/misc Code for various mostly optional miscellaneous features
lib/plat Platform-specific adaptation code
lib/roles Code for specific optional wsi roles, eg, http/1, h2, ws, raw, etc
lib/system Code for system-level features, eg, dhcpclient
lib/tls Code supporting the various TLS libraries