mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
![]() 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 |
||
---|---|---|
.. | ||
abstract | ||
core | ||
core-net | ||
drivers | ||
event-libs | ||
jose | ||
misc | ||
plat | ||
roles | ||
secure-streams | ||
system | ||
tls | ||
CMakeLists.txt | ||
README.md |
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 |