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

build: minor fix for 32-bit archs #11726

Merged
merged 9 commits into from
Jul 9, 2020
Merged

Conversation

goaway
Copy link
Contributor

@goaway goaway commented Jun 24, 2020

Commit Message: build: minor fix for 32-bit archs
Additional Description: Fixes an implicit cast error building for 32-bit Android here.
Risk Level: Low
Testing: Builds locally

Signed-off-by: Mike Schore mike.schore@gmail.com

Signed-off-by: Mike Schore <mike.schore@gmail.com>
@@ -466,7 +466,8 @@ class StatName {
* hasher and comparator.
*/
absl::string_view dataAsStringView() const {
return {reinterpret_cast<const char*>(data()), dataSize()};
return {reinterpret_cast<const char*>(data()),
static_cast<absl::string_view::size_type>(dataSize())};
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the underlying problem the abuse of uint64_t in line 409 above for dataSize()?

There's a significant penalty for using a 64 bit int in 32 bit contexts.

Copy link
Member

Choose a reason for hiding this comment

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

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 don't mind changing the underlying type of dataSize, but I don't really have any context on the original choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I'd prefer size_t for this; IIUC Envoy style has veered toward using uint64_t. @mattklein123 may have more context.

I'm fine with either:

  • this change, which makes sense in the context of returning a string_view
  • changing dataSize() et al to return size_t, which makes sense generally IMO

I slightly prefer the latter but I'm OK with this. @mattklein123 what do you prefer?

Copy link
Member

Choose a reason for hiding this comment

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

Sure we can use size_t. Typically we have used explicit types for things that can wrap, but for something like this size_t seems fine.

/wait

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uint64_t seems to be used extensively here to represent a number of bytes. dataSize() is also called in a number of locations. Just to clarify, is the proposal to switch size_t for all of these cases?

Copy link
Member

Choose a reason for hiding this comment

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

Yes size_t seems appropriate for number of bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Despite updating the type used for representing byte counts throughout the file, I left this cast in; I don't know what sort of contract absl::string_view::size_type has with respect to size_t.

If folks feel it's redundant though now, I can remove it.

@asraa asraa assigned jmarantz and unassigned junr03 Jun 26, 2020
jmarantz
jmarantz previously approved these changes Jun 27, 2020
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

this is OK with me but I'd like @mattklein123 to be the final approver.

@@ -466,7 +466,8 @@ class StatName {
* hasher and comparator.
*/
absl::string_view dataAsStringView() const {
return {reinterpret_cast<const char*>(data()), dataSize()};
return {reinterpret_cast<const char*>(data()),
static_cast<absl::string_view::size_type>(dataSize())};
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I'd prefer size_t for this; IIUC Envoy style has veered toward using uint64_t. @mattklein123 may have more context.

I'm fine with either:

  • this change, which makes sense in the context of returning a string_view
  • changing dataSize() et al to return size_t, which makes sense generally IMO

I slightly prefer the latter but I'm OK with this. @mattklein123 what do you prefer?

Signed-off-by: Mike Schore <mike.schore@gmail.com>
const uint64_t size = src.size();
MemBlockBuilder<uint8_t> storage(size);
const size_t size = src.size();
MemBlockBuilder<uint8_t> storage(size); // Note: MemBlockBuilder takes uint64_t.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory MemBlockBuilder could be updated to use size_t, too, and I suspect there may be other places we could switch over as well. My feeling is that that's a bit outside the scope of this change, however.

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed; outside the scope for now.

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
jmarantz
jmarantz previously approved these changes Jul 2, 2020
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

basically looks good, modulo a naming issue you need to fix to pass CI. Also merge master.

const uint64_t size = src.size();
MemBlockBuilder<uint8_t> storage(size);
const size_t size = src.size();
MemBlockBuilder<uint8_t> storage(size); // Note: MemBlockBuilder takes uint64_t.
Copy link
Contributor

Choose a reason for hiding this comment

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

agreed; outside the scope for now.

@@ -128,8 +127,7 @@ SymbolVec SymbolTableImpl::Encoding::decodeSymbols(const SymbolTable::Storage ar
}

void SymbolTableImpl::Encoding::decodeTokens(
const SymbolTable::Storage array, uint64_t size,
const std::function<void(Symbol)>& symbolTokenFn,
const SymbolTable::Storage array, size_t size, const std::function<void(Symbol)>& symbolTokenFn,
Copy link
Contributor

Choose a reason for hiding this comment

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

not your fault, but clang-tidy is dinging you for a pre-existing naming mistake here.

s/symbolTokenFn/symbol_token_fn/ here and in the header. Sorry about that.

That will help you pass CI.

@jmarantz
Copy link
Contributor

jmarantz commented Jul 2, 2020

/wait

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

@envoyproxy/senior-maintainers

@junr03
Copy link
Member

junr03 commented Jul 8, 2020

@ggreenway do you mind doing a last pass here?

Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

LGTM

@ggreenway ggreenway merged commit ec431a0 into envoyproxy:master Jul 9, 2020
goaway added a commit to envoyproxy/envoy-mobile that referenced this pull request Jul 15, 2020
Description: Pulls in multiple fixes committed to upstream Envoy.

- Update for resolution to TLSContext crash: envoyproxy/envoy#10030
- Fixes for 32 bit archs: envoyproxy/envoy#11726
- Fix for missing posix call on Android: envoyproxy/envoy#12081
- Additional zlib stats: envoyproxy/envoy#11782

Signed-off-by: Mike Schore <mike.schore@gmail.com>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
Fixes an implicit cast error building for 32-bit Android here.

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: Pulls in multiple fixes committed to upstream Envoy.

- Update for resolution to TLSContext crash: #10030
- Fixes for 32 bit archs: #11726
- Fix for missing posix call on Android: #12081
- Additional zlib stats: #11782

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Pulls in multiple fixes committed to upstream Envoy.

- Update for resolution to TLSContext crash: #10030
- Fixes for 32 bit archs: #11726
- Fix for missing posix call on Android: #12081
- Additional zlib stats: #11782

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
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.

7 participants