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

Modify patterns from a skeleton match to have the correct width #832

Merged
merged 5 commits into from
Jul 21, 2021

Conversation

gregtatum
Copy link
Member

Resolves #584.

@gregtatum gregtatum requested a review from sffc June 28, 2021 17:09
@gregtatum gregtatum requested a review from zbraniecki as a code owner June 28, 2021 17:09
@coveralls
Copy link

coveralls commented Jun 28, 2021

Pull Request Test Coverage Report for Build a51364a4f74669190872dd6e0ea8e3bd91dac4bb-PR-832

  • 20 of 23 (86.96%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.06%) to 74.938%

Changes Missing Coverage Covered Lines Changed/Added Lines %
components/datetime/src/skeleton.rs 20 23 86.96%
Files with Coverage Reduction New Missed Lines %
components/datetime/src/skeleton.rs 2 82.04%
Totals Coverage Status
Change from base Build 67bd340dd7cb6e1a958ceb36f8f1d4e73c63742e: 0.06%
Covered Lines: 9694
Relevant Lines: 12936

💛 - Coveralls

@codecov-commenter
Copy link

Codecov Report

Merging #832 (2ba7ad7) into main (67bd340) will increase coverage by 0.06%.
The diff coverage is 86.95%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #832      +/-   ##
==========================================
+ Coverage   74.80%   74.86%   +0.06%     
==========================================
  Files         198      198              
  Lines       12762    12778      +16     
==========================================
+ Hits         9546     9566      +20     
+ Misses       3216     3212       -4     
Impacted Files Coverage Δ
components/datetime/src/options/components.rs 76.72% <ø> (+0.86%) ⬆️
components/datetime/src/skeleton.rs 82.03% <86.95%> (+0.47%) ⬆️
experimental/provider_ppucd/src/parse_ppucd.rs 93.13% <0.00%> (+0.13%) ⬆️
components/datetime/src/fields/symbols.rs 68.82% <0.00%> (+0.76%) ⬆️
components/datetime/src/provider/helpers.rs 80.18% <0.00%> (+0.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67bd340...2ba7ad7. Read the comment docs.

gregtatum added a commit to gregtatum/icu4x that referenced this pull request Jul 2, 2021
…skeleton match to have the correct width"
gregtatum added a commit to gregtatum/icu4x that referenced this pull request Jul 12, 2021
…skeleton match to have the correct width"
@sffc sffc added this to the ICU4X 0.3 milestone Jul 15, 2021
sffc
sffc previously requested changes Jul 20, 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.

Not really requesting changes, but I have a question before I approve

// There's no match, or this is a string literal return the original item.
item.clone()
})
.collect::<Vec<PatternItem>>(),
Copy link
Member

Choose a reason for hiding this comment

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

Thought: I wish we could do this without alloc. I liked how before this function was basically a projection from &'a SkeletonsV1 to &'a Pattern. The extra allocation is going to hurt basically every benchmark we're after: memory usage, code size, and performance.

Suggestion: Could this be architected in a way that involves a map on the pattern itself? Like, you could attach a mapping function to the pattern, such that when you loop over the pattern while formatting, you run the PatternItems through the mapping function.

Alternatively, is this in the part of the code that we won't use at runtime after the new CLDR 70 skeleton algorithm is implemented? I don't care about the Vec if it's run in the transformer.

Copy link
Member Author

Choose a reason for hiding this comment

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

The extra allocation is going to hurt basically every benchmark we're after.

Yes, I agree that the allocation isn't great, and what I tried to design around in the initial implementation.

Suggestion: Could this be architected in a way that involves a map on the pattern itself.

The pattern must be mutated in order to support all of the features for DateTimeFormat. Beyond just the widths, there's also the hour cycle to consider. There's also append items support for things like time zones or week. The latter is even trickier, as a simple mapping function wouldn't work.

I would prefer to accept the perf/memory regression for 0.3, and follow-up with exploring some approaches. Especially as pattern mutation is a new requirement for other features such as the hour cycle, and append items. Then for 0.4 I can track fixing it.

Alternatively, is this in the part of the code that we won't use at runtime after the new CLDR 70 skeleton algorithm is implemented? I don't care about the Vec if it's run in the transformer.

I don't think well want a literal pattern for every width adjustment, as it will greatly affect the provider data. I'd say let's follow-up with looking for perf wins here. I'm nervous about the trade off between runtime characteristics and data payload size. I think it's something we should definitely try and work out.

Copy link
Member Author

Choose a reason for hiding this comment

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

I filed #877 as a follow-up, if you are OK with moving forward with this patch.

Copy link
Member

Choose a reason for hiding this comment

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

Okay. I won't block this PR but I'm a bit disappointed that we're going in this direction. I feel like we're repeating the problems of ICU4C rather than solving them. I hope we can follow up in #877.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, this at least gets us a baseline metric that we can track, and tests in place that make sure we are compliant with the behavior. The code is mutable, so we can course correct to fewer allocations. I also filed #879 to make sure we track this area better. I realize now that the benchmark is still needed.

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.

Modify patterns from a skeleton match to have the correct width
5 participants