Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ot-tags] Avoid strcmp in hb_ot_tags_from_language #3592

Closed
wants to merge 1 commit into from

Conversation

dscorbett
Copy link
Collaborator

I thought of this while reviewing #3591. I don’t know whether the speed improvement is worth the extra space from LangTag’s two new fields.

@dscorbett
Copy link
Collaborator Author

And this is already redundant. Oh well. I think I will stop thinking about performance till I am sure you are done making changes.

@behdad
Copy link
Member

behdad commented May 17, 2022

Can you check again with master? I removed the strcmp's already.

@behdad
Copy link
Member

behdad commented May 17, 2022

Namely: 909f00a

@behdad
Copy link
Member

behdad commented May 17, 2022

I believe I'm done. :)

benchmark-ot, before:

------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       14.1 ns         14.1 ns     46055359
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         81.8 ns         81.7 ns      8543566
BM_hb_ot_tags_from_script_and_language/COMMON en_US         32.4 ns         32.3 ns     21148356
BM_hb_ot_tags_from_script_and_language/LATIN en_US          32.5 ns         32.4 ns     21519987
BM_hb_ot_tags_from_script_and_language/COMMON none          6.60 ns         6.60 ns    104238020
BM_hb_ot_tags_from_script_and_language/LATIN none           6.68 ns         6.67 ns    102315248

After:

------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       14.0 ns         14.0 ns     48500637
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         81.1 ns         80.9 ns      8687343
BM_hb_ot_tags_from_script_and_language/COMMON en_US         34.2 ns         34.1 ns     20483588
BM_hb_ot_tags_from_script_and_language/LATIN en_US          34.2 ns         34.1 ns     20876827
BM_hb_ot_tags_from_script_and_language/COMMON none          6.77 ns         6.75 ns    101890802
BM_hb_ot_tags_from_script_and_language/LATIN none           6.73 ns         6.72 ns    102786996
@@ -217,6 +217,8 @@ lang_matches (const char *lang_str, const char *limit, const char *spec, unsigne
struct LangTag
{
hb_tag_t language;
unsigned int idx_for_same_tag;
unsigned int total_for_same_tag;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint16_t please.

@behdad
Copy link
Member

behdad commented May 17, 2022

A bit wasteful. Let me see the numbers and decide. Trying it now. Thanks.

@behdad
Copy link
Member

behdad commented May 17, 2022

Size increase is 5.5kb and there's no measurable time improvement. I'd abandon.

@dscorbett dscorbett closed this May 17, 2022
@dscorbett dscorbett deleted the avoid-strcmp branch May 17, 2022 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants