Repository navigation
Performance
Major performance improvements to pattern generation, achieving up to 40x speedup on warm queries and matching or exceeding kensaku.vim (jsmigemo + denops IPC) performance.
Warm queries (dictionary caches populated)
| Input | v1.2.0 | v1.3.0 | Speedup |
|---|---|---|---|
"a" |
130ms | 3ms | 43x |
"jo" |
24ms | 1ms | 24x |
"joutai" |
0.6ms | 0.03ms | 20x |
Key optimizations
- Eliminate coroutine overhead — Replace
coroutine.wrap/yieldwith callback-based iteration, enabling LuaJIT JIT compilation of hot rank/select loops - Iterative AA-tree insertion — Convert recursive
insert_node/add_to_treeto iterative loops, enabling LuaJIT JIT compilation (previously caused NYI trace aborts) - Multi-level caching:
- Parent cache (FFI array) for LOUDSTrie
reverse_lookup - Reverse lookup result cache per trie node
- Mapping result cache per dictionary node (critical for incremental search)
- Flat search result cache per query key
- Query result memoization (repeated queries return in ~0.002ms)
- Parent cache (FFI array) for LOUDSTrie
- Pre-build parent cache at dictionary load time, shifting ~20ms from first query to load time
- Inline UTF-8 decoding in TernaryRegexGenerator, avoiding table allocation per word
- utf8_char result caching for repeated Unicode-to-UTF8 encoding
Compatibility
- jsmigemo pattern compatibility — Fix predictive romaji conversion to not recursively expand sokuon (っ). With the same dictionary, luamigemo now produces identical patterns to jsmigemo (only difference is kensaku.vim's
\mprefix).- Before:
じょう\%([たちつてと]\|っ[たちつてと]\) - After:
じょう[たちっつてと](matches jsmigemo)
- Before:
Benchmarks
Added benchmark and comparison scripts in bench/:
profile.lua— Internal phase-level profilingpractical_bench.lua— Diverse query benchmark (80+ queries, incremental typing simulation)compare_patterns.lua— Pattern output comparison vs kensakufind_differences.lua— Comprehensive pattern difference scanner
See bench/README.md for usage.
API
No breaking changes. All public APIs remain backward compatible.