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

review of dmehala/remote-config-impl (#74) #76

Conversation

dgoffredo
Copy link
Contributor

Each commit in this pull request is effectively a review comment for #74.

This pull request is a work in progress.

So far, my suggestions are all stylistic.

Please note specifically any TODO(@dgoffredo) comments that I've added.

@dgoffredo dgoffredo requested a review from dmehala December 7, 2023 18:36
@pr-commenter
Copy link

pr-commenter bot commented Dec 7, 2023

Benchmarks

Benchmark execution time: 2023-12-07 19:38:44

Comparing candidate commit 06aace8 in PR branch david.goffredo/reviews/dmehala/remote-config-impl with baseline commit 973bf3a in branch dmehala/remote-config-impl.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@@ -138,18 +149,16 @@ void RemoteConfigurationManager::process_response(const nlohmann::json& json) {

const auto& config_metadata =
targets.at("/signed/targets"_json_pointer).at(config_path);
if (!contains(config_path, k_apm_product) ||
if (!contains(config_path, k_apm_product_path_substring) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Idea from Caleb: Write a partial parser that reads the first path component, and based on its value either retrieves the appropriate component, or returns some "n/a" value.

Comment on lines +82 to +83
decoder.buffer = 0 | c0 << (32 - 6 * 1) | c1 << (32 - 6 * 2) |
c2 << (32 - 6 * 3) | c3 << (32 - 6 * 4);
Copy link
Collaborator

@dmehala dmehala Dec 8, 2023

Choose a reason for hiding this comment

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

I find the extensive use of arithmetic not helpful, it does the opposite. Ultimately, the reader is required to understand the base64 algorithm to grasp the rationale behind those bit shifting.

Either static_cast<uint32_t>(c0) << 26 or c0 << (32 - 6 * 1), is equivalent but the later require mental calculation to find out how much we are shifting, add on top of it a lack of parenthesis and I guarantee lots of people will fail to interpret it correctly compared to << 26. Can we avoid this confusion and revert to the proposed solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can write it however you prefer it, but my preference is expressed in the diff.

More important to me is that we choose an algorithm that does not assume little-endian.

Comment on lines +22 to +24
struct Update {
Optional<TraceSamplerConfig> trace_sampler;
};
Copy link
Collaborator

@dmehala dmehala Dec 8, 2023

Choose a reason for hiding this comment

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

An Update is capable of being consumed by the ConfigManager, even though it is likely and perhaps exclusively intended to be consumed by the ConfigManager, that does not means there is a compelling reason to tighly couple both concept. It can also be interpreted as an Update of the ConfigManager, which is not the intended meaning.

I suggest to keep it outside of the ConfigManager, it offers room for flexibility, probably future usage and semantically is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw three options:

  1. Leave it as you had it.
  2. Put struct ConfigUpdate in its own component (its own .h). Good place for documentation!
  3. Consider ConfigUpdate as part of ConfigManager's public interface.

(1) and (3) are compatible, but so too are (3) and my proposed change.

My reasoning was "if I see ConfigUpdate used in RemoteConfigManager, where do I go looking for its definition?" I might look for a config_update.h, but there is none. ConfigUpdate is a parameter to ConfigManager, so I might look there, but the connection is even stronger if it's spelled ConfigManager::Update.

It can also be interpreted as an Update of the ConfigManager, which is not the intended meaning.

That's a good point. I prefer (2) to (1) if you're looking for a compromise. I'm also fine with (1). This PR is illustrative only.

Copy link
Collaborator

@dmehala dmehala left a comment

Choose a reason for hiding this comment

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

Except the two comment this looks good to me. Thank you for fixing those little details I forgot like the documentation, better comment, moving stuff to .cpp and more.

Copy link
Contributor Author

@dgoffredo dgoffredo left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look. I left some responses as inline comments.

Thoughts:

  • If you disagree with my style suggestions, go with your gut. This is your rodeo.
  • Please see my comment mentioning "Idea from Caleb." This is related to the griping I did on slack yesterday about the config path concept.
  • One opinion that I do hold strongly is endian agnosticism. Please choose an alternative base64 decoding algorithm. I won't be picky about the style.

Comment on lines +82 to +83
decoder.buffer = 0 | c0 << (32 - 6 * 1) | c1 << (32 - 6 * 2) |
c2 << (32 - 6 * 3) | c3 << (32 - 6 * 4);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can write it however you prefer it, but my preference is expressed in the diff.

More important to me is that we choose an algorithm that does not assume little-endian.

Comment on lines +22 to +24
struct Update {
Optional<TraceSamplerConfig> trace_sampler;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw three options:

  1. Leave it as you had it.
  2. Put struct ConfigUpdate in its own component (its own .h). Good place for documentation!
  3. Consider ConfigUpdate as part of ConfigManager's public interface.

(1) and (3) are compatible, but so too are (3) and my proposed change.

My reasoning was "if I see ConfigUpdate used in RemoteConfigManager, where do I go looking for its definition?" I might look for a config_update.h, but there is none. ConfigUpdate is a parameter to ConfigManager, so I might look there, but the connection is even stronger if it's spelled ConfigManager::Update.

It can also be interpreted as an Update of the ConfigManager, which is not the intended meaning.

That's a good point. I prefer (2) to (1) if you're looking for a compromise. I'm also fine with (1). This PR is illustrative only.

@dmehala
Copy link
Collaborator

dmehala commented Dec 14, 2023

Squashed and cherry-picked 52375e0 in #74

@dmehala dmehala closed this Dec 14, 2023
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