Commit c717832
perf: sort vocab before merge parsing + rebuild WASM with ASYNCIFY (#22)
Two changes:
1. Move sorted_indices build before GGUF BPE merge parsing in both
tq_tokenizer.c and quant.h. str_lookup() during merge parsing was
falling back to O(n) linear scan because sorted_indices wasn't built
yet. For Qwen3 (248K vocab × 50K merges × 3 lookups) this was ~10 s
of init time. Now uses binary search: ~100 ms.
2. Rebuild quant.js (72K) and quant.wasm (256K) with -sASYNCIFY.
The previous binaries were compiled before the ASYNCIFY flags were
added to build.sh, so wasm_generate_async() didn't exist and the
JS fallback ran the synchronous path (blocking the browser event
loop, all tokens appearing at once). The new binary contains
asyncify runtime + emscripten_sleep, enabling real-time per-token
streaming in the browser demo.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 2396027 commit c717832
4 files changed
Lines changed: 23 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8033 | 8033 | | |
8034 | 8034 | | |
8035 | 8035 | | |
| 8036 | + | |
| 8037 | + | |
| 8038 | + | |
| 8039 | + | |
| 8040 | + | |
| 8041 | + | |
| 8042 | + | |
| 8043 | + | |
| 8044 | + | |
| 8045 | + | |
8036 | 8046 | | |
8037 | 8047 | | |
8038 | 8048 | | |
| |||
8072 | 8082 | | |
8073 | 8083 | | |
8074 | 8084 | | |
8075 | | - | |
| 8085 | + | |
8076 | 8086 | | |
8077 | 8087 | | |
8078 | 8088 | | |
| |||
8092 | 8102 | | |
8093 | 8103 | | |
8094 | 8104 | | |
8095 | | - | |
8096 | | - | |
8097 | | - | |
8098 | | - | |
8099 | | - | |
8100 | | - | |
8101 | | - | |
8102 | | - | |
8103 | | - | |
8104 | | - | |
8105 | 8105 | | |
8106 | 8106 | | |
8107 | 8107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
884 | 894 | | |
885 | 895 | | |
886 | 896 | | |
| |||
920 | 930 | | |
921 | 931 | | |
922 | 932 | | |
923 | | - | |
| 933 | + | |
924 | 934 | | |
925 | 935 | | |
926 | 936 | | |
| |||
940 | 950 | | |
941 | 951 | | |
942 | 952 | | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | 953 | | |
954 | 954 | | |
955 | 955 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
0 commit comments