Skip to content

Clean up code conversions of Profile enum - #1511

Merged
Kobzol merged 1 commit into
rust-lang:masterfrom
GuillaumeGomez:cleanup-profile-conversions
Jan 19, 2023
Merged

Kobzol merged 1 commit into
rust-lang:masterfrom
GuillaumeGomez:cleanup-profile-conversions

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

This cleans up a bit some conversion of the Profile type and allow to have it in one place.

Another thing I wondered: this type is also present in both collector/src/benchmark/profile.rs and database/src/lib.rs. Is there a reason why it is duplicated like this? collector/src/benchmark/ has database as a dependency, so is there a particular reason why Profile was also created in collector/src/benchmark? If not I'm planning to merge both types in a follow-up PR.

@Kobzol Kobzol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Before the recent refactoring, the collector Profile was slightly different from the database Profile, but after the refactoring their "layout" is indeed the same.

That being said, I'm not sure if it's needed to unify them just because they have the same layout/attributes. The collector uses the profile/scenario enums in a slightly different way than the database (it's subtle, but it can be seen by the different methods and derived trait implementations). I consider the database enums to be "implementation details" of how is this information stored in the database, which should be able to be changed independently of the collector's way of representing profiles (and in theory it's possible that this will change once we will change the DB layout to accommodate runtime benchmarks). And since the conversion between them is trivial, I think it's fine if it stays the way it is.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

As you prefer. I wondered about it because I'm currently working on something that needed to add a new entry into Profile and I basically had to do it twice, so not great.

@Kobzol

Kobzol commented Jan 10, 2023

Copy link
Copy Markdown
Member

I see. I still think that it's safer to just add the thing twice rather than to unify it (the scenario enums are also not unified, which is an example of "the same enum", which has different representations in DB and in collector).

What are you working on? :)

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

To answer your question: #1512 (this is very much open to debate and not ready at all, just wanted to see if it was worth it before going any further).

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Is there anything else to be done here @Kobzol ?

@Kobzol
Kobzol merged commit 3af3ba1 into rust-lang:master Jan 19, 2023
@Kobzol

Kobzol commented Jan 19, 2023

Copy link
Copy Markdown
Member

Sorry for the delay, merged.

@GuillaumeGomez
GuillaumeGomez deleted the cleanup-profile-conversions branch January 19, 2023 13:24
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Thanks!

@nnethercote

Copy link
Copy Markdown
Contributor

That being said, I'm not sure if it's needed to unify them just because they have the same layout/attributes. The collector uses the profile/scenario enums in a slightly different way than the database (it's subtle, but it can be seen by the different methods and derived trait implementations). I consider the database enums to be "implementation details" of how is this information stored in the database, which should be able to be changed independently of the collector's way of representing profiles (and in theory it's possible that this will change once we will change the DB layout to accommodate runtime benchmarks).

This would be great information to put in a comment on each Profile definition!

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.

3 participants