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

Add payload conversion and heap measurement tool #1670

Merged
merged 20 commits into from
Mar 10, 2022

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Mar 5, 2022

Fixes #1512, fixes #1661

This adds icu4x-verify-zero-copy, that loads testdata.postcard and deserializes each entry that it knows to look for to its specific data struct type, while measuring heap usage. It then reports which keys have non-zero-copy data structs. (this is #1661)

This also updates impl_dyn_provider!() to be able to provide DataConverter impls that act as a "data registry" (#1512), allowing one to convert between different dynamic marker types via intermediate downcasting.

Todo:

  • docs and comments
  • run this in CI

@Manishearth Manishearth requested review from sffc, nordzilla and a team as code owners March 5, 2022 03:16
@Manishearth Manishearth changed the title Add payload conversion and heap measurement code Add payload conversion and heap measurement tool Mar 5, 2022
@Manishearth Manishearth removed request for a team and nordzilla March 5, 2022 05:10
@Manishearth
Copy link
Member Author

cc @robertbastian @zbraniecki

@Manishearth
Copy link
Member Author

cc @robertbastian btw

.help("Load input data from the icu_testdata project."),
)
.arg(
Arg::with_name("KEYS")
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 added this because I found it useful to be --keys specifickey -v to debug things

Copy link
Member

Choose a reason for hiding this comment

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

Also add ALL_KEYS?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's currently no difference and we can add that as needed I think

Copy link
Member

Choose a reason for hiding this comment

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

The difference with ALL_KEYS over TEST_KEYS is that in line 220 we wouldn't ignore key errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

That means all-keys would always error, datagen doesn't have proper support for this either. I'm only adding features that'll actually be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Overall I don't want this to just duplicate that other set of flags until we need those features

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • Cargo.lock is different
  • tools/datagen/src/bin/verify-zero-copy.rs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

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.

First batch; more in the morning

provider/core/src/dynutil.rs Show resolved Hide resolved
provider/core/src/datagen/heap_measure.rs Outdated Show resolved Hide resolved
provider/core/src/datagen/data_conversion.rs Show resolved Hide resolved
tools/datagen/src/bin/datagen.rs.orig Outdated Show resolved Hide resolved
tools/datagen/src/bin/datagen.rs Outdated Show resolved Hide resolved
tools/datagen/src/bin/verify-zero-copy.rs Outdated Show resolved Hide resolved
provider/core/src/datagen/data_conversion.rs Outdated Show resolved Hide resolved
provider/core/src/datagen/heap_measure.rs Outdated Show resolved Hide resolved
/// A blanket-implemented trait that allows for all the datagen-relevant traits
/// to be used in trait objects. The type parameter is the marker type needed for
/// [`IterableDynProvider`].
pub trait OmnibusDatagenProvider<M: DataMarker>:
Copy link
Member

Choose a reason for hiding this comment

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

Can we just call this DatagenProvider?

Actually in #1092 we said that IterableDynProvider is not the right trait for runtime, so maybe we can just rename that DatagenProvider and make it extend the DataConverter impls? It should also be behind the datagen feature now that that exists.

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'd rather do wider refactors around what's under what feature as a result of #1320 (which I plan to get done soon)

Copy link
Member

Choose a reason for hiding this comment

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

Still, what do buses have to do with this

Copy link
Member Author

Choose a reason for hiding this comment

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

"Omnibus" is just a term used in English to talk about things that contain more things than usual, typically in the case of media around anthologies and "3-in-1 books".

In this case, this is really just "a lot of traits in one trait", hence the trait name.

Copy link
Member

Choose a reason for hiding this comment

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

I have never seen it used that way, maybe it's an American thing. I'd prefer if we avoid such words, we should keep our code accessible to non-Americans and non-native English speakers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, gotcha. It is convenient to be able to have the list of all sub-providers in one place though

Copy link
Member Author

Choose a reason for hiding this comment

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

(perhaps we could have that list be in the datagen crate)

Copy link
Member

Choose a reason for hiding this comment

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

(perhaps we could have that list be in the datagen crate)

This would be fine with me. Alternatively: #1684

Copy link
Member

Choose a reason for hiding this comment

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

That is a cool solution, can you incorporate #1684 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not sufficient in and of itself without further work: you either need to name the really complex type over the boundary or you need to do a bunch of manual passthrough implementations. I'd rather land this first, I don't consider this additional trait to be that much overhead.

@@ -189,6 +204,52 @@ macro_rules! impl_dyn_provider {
$crate::serde::SerializeMarker
);
};
($provider:ty, [ $($struct_m:ty),+, ], SERDE_SE, impl DataConverter) => {
Copy link
Member

Choose a reason for hiding this comment

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

This macro is getting massive. Now that we have a datagen feature we could split it into what it was before #1595, and a second macro (impl_datagen_provider) that additionally implements IterableDynProvider and DataConverter (and which we can also put behind the datagen feature).

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'm waiting for the ResourceProvider stuff to happen before making further changes here

Copy link
Member

Choose a reason for hiding this comment

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

What ResourceProvider stuff?

Copy link
Member Author

@Manishearth Manishearth Mar 10, 2022

Choose a reason for hiding this comment

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

#1554 was the main thing, but I believe there's more stuff to be done here around Buffer and Any providers, especially using the new Convert infrastructure. Shane's got a whole plan 😄 (I can't find the right issue at the moment)

.help("Load input data from the icu_testdata project."),
)
.arg(
Arg::with_name("KEYS")
Copy link
Member

Choose a reason for hiding this comment

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

Also add ALL_KEYS?

tools/datagen/src/bin/verify-zero-copy.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.

(touch)

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • Cargo.lock is different
  • components/properties/src/provider.rs is different
  • provider/cldr/src/transform/list/mod.rs is different
  • provider/uprops/src/enum_uniset.rs is different
  • tools/datagen/Cargo.toml is different
  • tools/datagen/src/bin/datagen.rs is different
  • tools/datagen/src/lib.rs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@Manishearth
Copy link
Member Author

Rebased over segmenter changes, no changes between your last review and this except for 4c8b208 and merge conflict resolution

@Manishearth Manishearth requested review from robertbastian and removed request for aethanyc and makotokato March 9, 2022 21:52
.help("Load input data from the icu_testdata project."),
)
.arg(
Arg::with_name("KEYS")
Copy link
Member

Choose a reason for hiding this comment

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

The difference with ALL_KEYS over TEST_KEYS is that in line 220 we wouldn't ignore key errors.

/// A blanket-implemented trait that allows for all the datagen-relevant traits
/// to be used in trait objects. The type parameter is the marker type needed for
/// [`IterableDynProvider`].
pub trait OmnibusDatagenProvider<M: DataMarker>:
Copy link
Member

Choose a reason for hiding this comment

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

That is a cool solution, can you incorporate #1684 ?

@@ -189,6 +204,52 @@ macro_rules! impl_dyn_provider {
$crate::serde::SerializeMarker
);
};
($provider:ty, [ $($struct_m:ty),+, ], SERDE_SE, impl DataConverter) => {
Copy link
Member

Choose a reason for hiding this comment

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

What ResourceProvider stuff?

@Manishearth Manishearth merged commit 37118aa into unicode-org:main Mar 10, 2022
@Manishearth Manishearth deleted the verify-zero-copy branch March 10, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants