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

Adopt absl common libraries #1754

Closed
htuch opened this issue Sep 27, 2017 · 8 comments
Closed

Adopt absl common libraries #1754

htuch opened this issue Sep 27, 2017 · 8 comments
Labels
area/build enhancement Feature requests. Not bugs or questions. tech debt

Comments

@htuch
Copy link
Member

htuch commented Sep 27, 2017

Google's common C++ libraries are now OSS: https://github.com/abseil/abseil-cpp. This a lightweight alternative to something like Boost which can replace existing adhoc utils such as string join/split with standard implementations.

This issue will track a proposal to:

  1. Add absl as an external dependency to Envoy (it already has Bazel support).
  2. Replace existing implementation of duplicate functionality with absl alternatives. Places to look at include common/common/utility.h, Optional, mutexes, make_unique, (others?)
  3. Use absl utilities going forward.
@htuch htuch added area/build enhancement Feature requests. Not bugs or questions. tech debt labels Sep 27, 2017
@mattklein123
Copy link
Member

@htuch are there any API docs? I can't find any? Or should I just browse the source?

@htuch
Copy link
Member Author

htuch commented Sep 27, 2017

https://abseil.io/docs/

@mattklein123
Copy link
Member

I took a brief look through and the code looks sane and not Boost like to me so no objections from me. I have a small preference to wait until there is a thing we really want to use from here (string view sounds pretty useful, not sure what else there is), but not a big deal.

@ggreenway
Copy link
Contributor

I looked at some of the thread annotations, and it would allow annotating the lock-ordering I committed yesterday, and it looks like clang would warn if the order is violated, so that would be useful (

// These locks are always acquired in the following order if multiple locks are held:
)

@mattklein123
Copy link
Member

I looked at the annotation stuff very briefly. How does that work? Does clang have pluggable annotations? Or these are annotations already implemented by clang?

@ggreenway
Copy link
Contributor

There's some nifty stuff built into clang: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html

abseil adds macros for using it, and has the appropriate checks for if the compiler supports the annotations.

@mattklein123
Copy link
Member

Cool that's pretty neat. SGTM.

htuch pushed a commit that referenced this issue Nov 20, 2017
Description:
-Adds a ThreadSafe singleton class which can be accessed from all threads and overridden with an injected instance for custom implementations for test code or custom Envoy builds.
-Replaces OsSysCallsImpl being plumbed everywhere it is needed with a new ThreadSafe singleton as a sample use case (and to avoid having to plumb the OsSysCallsImpl to all users for test overrides)
-Adds abseil as a dependency

Fixes #1808
Step 1 of #1754

Risk Level: Low: mainly a refactor to how OsSysCallsImpl is accessed

Testing:
Existing OS tests continue to pass, now using an inject-able mock singleton
test/common/common/singleton_test.cc unit testing the new class

Signed-off-by: Alyssa Wilk <[email protected]>
@mattklein123
Copy link
Member

This is done. We can start using ABSL now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build enhancement Feature requests. Not bugs or questions. tech debt
Projects
None yet
Development

No branches or pull requests

3 participants