Inline Char16Trie traversal methods#8142
Draft
Xuanwo wants to merge 1 commit into
Draft
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR isolates the Char16Trie traversal inline annotations from #8113.
The change is intentionally small: it only adds
#[inline]to the hotChar16TrieIteratortraversal entry points and helper paths incomponents/collections/src/char16trie/trie.rs. It does not change public APIs and does not include the ResultCache, zero-copy complex segmentation, or benchmark implementation changes from the larger performance branch.Why separate:
Char16TrieIteratoris shared by published segmenter code and the in-progressneosegmenter.Benchmark setup:
origin/mainat4f4c9f1fa068b6e4e0331b385104a7b2872489c5.665a7db7fa Inline Char16Trie traversal methods.Add segmenter comparison benchmarks, head044cc38edec9ae46d03db66e9f5016bcd85e5835.origin/main, run the command below; then apply the same patch to this branch and rerun the same command.cargo bench -p icu_segmenter --bench bench --features unstable -- dictionary --sample-size 10 --measurement-time 1 --warm-up-time 0.5.dictionaryfilter. This was a short local run, so small single-digit changes and short English/Latin1 paths should be treated as noisy; the table is intended to show the current published andneodictionary/Char16Trie-path direction under the latest benchmark code.Representative dictionary / Char16Trie-related results:
Segmenter_word_segment_str/published_dictionary_thaiSegmenter_word_segment_str/published_dictionary_japaneseSegmenter_word_segment_str/published_dictionary_hanSegmenter_word_segment_str/neo_dictionary_thaiSegmenter_word_segment_utf8/neo_dictionary_thaiSegmenter_word_segment_utf16/neo_dictionary_thaiSegmenter_line_segment_str/published_dictionary_thaiSegmenter_line_segment_str/neo_dictionary_thaiSegmenter_line_segment_utf8/published_dictionary_thaiSegmenter_line_segment_utf8/neo_dictionary_thaiDictionary benchmark delta:
Segmenter_line_segment_latin1/neo_dictionary_css_englishSegmenter_line_segment_latin1/neo_dictionary_englishSegmenter_line_segment_latin1/published_dictionary_css_englishSegmenter_line_segment_latin1/published_dictionary_englishSegmenter_line_segment_str/neo_dictionary_css_englishSegmenter_line_segment_str/neo_dictionary_englishSegmenter_line_segment_str/neo_dictionary_hanSegmenter_line_segment_str/neo_dictionary_japaneseSegmenter_line_segment_str/neo_dictionary_thaiSegmenter_line_segment_str/neo_dictionary_thai_hanSegmenter_line_segment_str/neo_dictionary_thai_japaneseSegmenter_line_segment_str/published_dictionary_css_englishSegmenter_line_segment_str/published_dictionary_englishSegmenter_line_segment_str/published_dictionary_hanSegmenter_line_segment_str/published_dictionary_japaneseSegmenter_line_segment_str/published_dictionary_thaiSegmenter_line_segment_str/published_dictionary_thai_hanSegmenter_line_segment_str/published_dictionary_thai_japaneseSegmenter_line_segment_utf16/neo_dictionary_css_englishSegmenter_line_segment_utf16/neo_dictionary_englishSegmenter_line_segment_utf16/neo_dictionary_hanSegmenter_line_segment_utf16/neo_dictionary_japaneseSegmenter_line_segment_utf16/neo_dictionary_thaiSegmenter_line_segment_utf16/neo_dictionary_thai_hanSegmenter_line_segment_utf16/neo_dictionary_thai_japaneseSegmenter_line_segment_utf16/published_dictionary_css_englishSegmenter_line_segment_utf16/published_dictionary_englishSegmenter_line_segment_utf16/published_dictionary_hanSegmenter_line_segment_utf16/published_dictionary_japaneseSegmenter_line_segment_utf16/published_dictionary_thaiSegmenter_line_segment_utf16/published_dictionary_thai_hanSegmenter_line_segment_utf16/published_dictionary_thai_japaneseSegmenter_line_segment_utf8/neo_dictionary_css_englishSegmenter_line_segment_utf8/neo_dictionary_englishSegmenter_line_segment_utf8/neo_dictionary_hanSegmenter_line_segment_utf8/neo_dictionary_japaneseSegmenter_line_segment_utf8/neo_dictionary_thaiSegmenter_line_segment_utf8/neo_dictionary_thai_hanSegmenter_line_segment_utf8/neo_dictionary_thai_japaneseSegmenter_line_segment_utf8/published_dictionary_css_englishSegmenter_line_segment_utf8/published_dictionary_englishSegmenter_line_segment_utf8/published_dictionary_hanSegmenter_line_segment_utf8/published_dictionary_japaneseSegmenter_line_segment_utf8/published_dictionary_thaiSegmenter_line_segment_utf8/published_dictionary_thai_hanSegmenter_line_segment_utf8/published_dictionary_thai_japaneseSegmenter_word_segment_str/neo_dictionary_englishSegmenter_word_segment_str/neo_dictionary_hanSegmenter_word_segment_str/neo_dictionary_japaneseSegmenter_word_segment_str/neo_dictionary_thaiSegmenter_word_segment_str/neo_dictionary_thai_hanSegmenter_word_segment_str/neo_dictionary_thai_japaneseSegmenter_word_segment_str/published_dictionary_englishSegmenter_word_segment_str/published_dictionary_hanSegmenter_word_segment_str/published_dictionary_japaneseSegmenter_word_segment_str/published_dictionary_thaiSegmenter_word_segment_str/published_dictionary_thai_hanSegmenter_word_segment_str/published_dictionary_thai_japaneseSegmenter_word_segment_utf16/neo_dictionary_englishSegmenter_word_segment_utf16/neo_dictionary_hanSegmenter_word_segment_utf16/neo_dictionary_japaneseSegmenter_word_segment_utf16/neo_dictionary_thaiSegmenter_word_segment_utf16/neo_dictionary_thai_hanSegmenter_word_segment_utf16/neo_dictionary_thai_japaneseSegmenter_word_segment_utf16/published_dictionary_englishSegmenter_word_segment_utf16/published_dictionary_hanSegmenter_word_segment_utf16/published_dictionary_japaneseSegmenter_word_segment_utf16/published_dictionary_thaiSegmenter_word_segment_utf16/published_dictionary_thai_hanSegmenter_word_segment_utf16/published_dictionary_thai_japaneseSegmenter_word_segment_utf8/neo_dictionary_englishSegmenter_word_segment_utf8/neo_dictionary_hanSegmenter_word_segment_utf8/neo_dictionary_japaneseSegmenter_word_segment_utf8/neo_dictionary_thaiSegmenter_word_segment_utf8/neo_dictionary_thai_hanSegmenter_word_segment_utf8/neo_dictionary_thai_japaneseSegmenter_word_segment_utf8/published_dictionary_englishSegmenter_word_segment_utf8/published_dictionary_hanSegmenter_word_segment_utf8/published_dictionary_japaneseSegmenter_word_segment_utf8/published_dictionary_thaiSegmenter_word_segment_utf8/published_dictionary_thai_hanSegmenter_word_segment_utf8/published_dictionary_thai_japaneseValidation:
cargo fmt -p icu_collections -p icu_segmentergit diff --checkcargo test -p icu_collections --features serde,databakecargo test -p icu_segmenter --features unstableChangelog
icu_collections: Improve Char16Trie traversal performance with inline annotations.