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

Switch PluralRules Data to ZeroVec #1240

Merged
merged 30 commits into from
Nov 15, 2021
Merged

Conversation

zbraniecki
Copy link
Member

^^^^^^^^^^^

@zbraniecki
Copy link
Member Author

Fixes #615.

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • components/datetime/src/datetime.rs is different
  • components/datetime/src/format/datetime.rs is different
  • components/datetime/src/zoned_datetime.rs is different
  • components/plurals/examples/elevator_floors.rs is no longer changed in the branch
  • components/plurals/examples/unread_emails.rs is no longer changed in the branch
  • components/plurals/src/lib.rs is different
  • components/plurals/src/rules/runtime/ast.rs is different
  • components/plurals/tests/categories.rs is now changed in the branch
  • components/plurals/tests/fixtures/categories.json is now changed in the branch
  • components/plurals/tests/fixtures/mod.rs is now changed in the branch
  • components/plurals/tests/plurals.rs is different
  • provider/testdata/data/testdata.postcard is different
  • utils/zerovec/src/zerovec/mod.rs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@zbraniecki
Copy link
Member Author

@Manishearth @sffc - can you skim through for sanity check before I start polishing?

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

Looks like you're on the right track so far!

components/plurals/src/lib.rs Outdated Show resolved Hide resolved
components/plurals/src/lib.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Show resolved Hide resolved
#[derive(Clone, Debug, PartialEq)]
pub struct Relation<'data> {
pub(crate) and_or: AndOr,
pub(crate) polarity: Polarity,
Copy link
Member

Choose a reason for hiding this comment

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

thought (also a note to self, really): if these are refactored into an AndOrPolarityOperand struct on the non-ULE side and we just implement ULE on that (instead of doing the andor_polarity_operand field) this becomes something much more amenable to the custom derive that I hope to have

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • Cargo.lock is different
  • components/plurals/Cargo.toml is different
  • components/plurals/src/lib.rs is different
  • components/plurals/src/rules/runtime/ast.rs is different
  • provider/cldr/src/transform/plurals.rs is different
  • provider/testdata/data/testdata.postcard is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@zbraniecki zbraniecki requested a review from sffc November 4, 2021 22:52
@zbraniecki
Copy link
Member Author

I applied Manish feedback and tested using exponent for modulo and cutting RangeOrValueULE to be PlainOldULE<4> - neither really impacts performance (the former deteriorates perf, the latter gives ~1-2% win), so I'd prefer not to overoptimize it right now.

@sffc @Manishearth - can I get second round of feedback? After that, I'd like to polish the code and submit for full review.

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

A few comments to start; more coming soon

components/plurals/src/lib.rs Show resolved Hide resolved
components/plurals/src/rules/mod.rs Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

Next round of feedback. I finished runtime/ast.rs which seems to be one of the bigger files.

components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
type Error = &'static str;

#[inline]
unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self {
Copy link
Member

Choose a reason for hiding this comment

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

Request: please verify this impl with @Manishearth

Copy link
Member

Choose a reason for hiding this comment

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

Hehehe I wrote this code but yes I should have a closer look, will mention when I've reviewed

components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
@zbraniecki zbraniecki changed the title Zibi's PR ZV PR ZB PR ZV PR Nov 5, 2021
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

Good! Nothing big, just a few more small things.

components/plurals/src/rules/runtime/ast.rs Outdated Show resolved Hide resolved
components/plurals/src/rules/runtime/resolver.rs Outdated Show resolved Hide resolved
utils/zerovec/src/zerovec/mod.rs Outdated Show resolved Hide resolved
@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • components/plurals/src/rules/runtime/ast.rs is different
  • utils/zerovec/src/ule/pair.rs is no longer changed in the branch

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@zbraniecki
Copy link
Member Author

I applied the next round of feedback and I think I'm ready to clean up the code, document fix tests and put for full review.

But before I do, I noticed something concerning:

The performance is good - plurals/pluralrules/overview goes from 27us on my machine to 24us for an 11% win! Yay!

But the memory is much less affected.

unread_emails on main:

[memory] > dhat: Total:     15,573 bytes in 12 blocks
[memory] > dhat: At t-gmax: 15,311 bytes in 5 blocks

unread_emails on pr-zv:

[memory] > dhat: Total:     15,078 bytes in 4 blocks
[memory] > dhat: At t-gmax: 15,070 bytes in 3 blocks

elevator_flooors on main:

[memory] > dhat: Total:     16,601 bytes in 28 blocks
[memory] > dhat: At t-gmax: 15,732 bytes in 15 blocks

elevator_flooors on pr-zv:

[memory] > dhat: Total:     15,077 bytes in 4 blocks
[memory] > dhat: At t-gmax: 15,069 bytes in 3 blocks

@sffc @Manishearth - is that expected? Is it VZV cost, or should we investigate further?

@Manishearth
Copy link
Member

Note that those examples use a static data provider so they're both loading all of the data as part of the binary, which is probably where most of that number comes from.

@Manishearth
Copy link
Member

It would be worth diffing the amount the memory usage increases between the start of main() and the construction of the PluralRules object

@zbraniecki zbraniecki marked this pull request as ready for review November 10, 2021 00:38
@zbraniecki zbraniecki requested review from sffc and Manishearth and removed request for filmil, gregtatum and nordzilla November 10, 2021 00:39
@jira-pull-request-webhook
Copy link

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-reviewer PRs waiting for action from the reviewer for >7 days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants