-
Notifications
You must be signed in to change notification settings - Fork 698
Open
Labels
Description
Massive chunks of uncompressed binaries are just local.get with small indices. To use Tensorflow's SIMD WebAssembly bundle (424594 B) as an example:
| Index | Bundle size % | local.get % |
|---|---|---|
| 0 | 2.7% | 9.8% |
| 0-1 | 4.9% | 18.0% |
| 0-3 | 9.1% | 33.2% |
| 0-7 | 15.4% | 56.2% |
| 0-15 | 22.8% | 83.4% |
| All | 27.3% | 100% |
Here's similar stats for local.set and local.tee:
local.set index |
Bundle size % | local.set % |
|---|---|---|
| 0 | 0.36% | 5.9% |
| 0-1 | 0.73% | 12.2% |
| 0-3 | 1.6% | 25.9% |
| 0-7 | 2.8% | 47.1% |
| 0-15 | 4.5% | 72.2% |
| All | 6.2% | 100% |
local.tee index |
Bundle size % | local.tee % |
|---|---|---|
| 0 | 0.38% | 7.8% |
| 0-1 | 0.73% | 15.1% |
| 0-3 | 1.5% | 30.4% |
| 0-7 | 2.6% | 53.1% |
| 0-15 | 4.1% | 83.5% |
| All | 5.0% | 100% |
I checked savings from
multiple possibilities:
- 1-byte
local.get 0-15only: about 11.4% - 1-byte
local.get 0-7only: about 7.7% - 1-byte
local.get 0-3only: about 4.6% - 1-byte
local.get 0-7+local.set/tee 0-3: about 9.3% - 1-byte
local.get 0-3+local.set/tee 0-1: about 5.4%
I checked Tensorflow's non-SIMD bundle and saw similar ratios.
Each of these, to my knowledge, are possible in the 0xE0-0xEF space (unless there's extensions I don't know about), so I propose putting 1-byte local.get 0-15 there.