Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the performance of base/trie.h.
The following changes are introduced to optimize performance: 1) For SubTrie, change its key type from std::string to char32. Since the key of SubTrie is one UTF8 character, we can encode the key to char32 to avoid string copies on lookup operations. 2) Use absl::flat_hash_map instead of std::map for SubTrie for faster lookup (note: the sorted property is lost but it seems unnecessary). The composer/composer_benchmark_test shows -19.3% improvement (note: the contribution of change 1 is significant in this improvement): [Baseline@410677084] Benchmark Time(ns) CPU(ns) Iterations BM_Composer_mean 16561 16552 41877 BM_Composer_stddev 408 408 41877 [This CL] BM_Composer_mean 13361 13357 51990 BM_Composer_stddev 517 517 51990 PiperOrigin-RevId: 410948001
- Loading branch information
1 parent
fbeee81
commit 0eed307
Showing
2 changed files
with
51 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters