Comments (5)
Thank you for your suggestion!
The efficiency of the default executor is largely dependent on the platform and use case. When we first started this project, I went on the assumption that the operating system implementation is the best default. In modern linux kernels and the modern windows kernels thread creation has been optimized by orders of magnitude to say.... 5 or more years ago, and it is often advisable to let the OS manage this task. In systems programming tasks, my advice is to use thread pools only for throttling but not for efficiency. I remember watching a talk from Bjarn Strosroup and Herb Sutter on this topic from C++ con last year which made this recommendation, but for the life of me I can't find a transcript of it anywhere at the moment.
In general, by choosing C++ 11 and later we have taken the general guiding principle that you should use the defaults unless you have a compelling, and verifiable with profiler metrics, reason to do otherwise.
For embedded systems or gaming, this is a completely different scenario. Hence, we want sane defaults that can be overridden for each use case. Boost, for example has an excellent pooled thread executor implementation (at least it did when I was looking at it a year or so ago).
One more thing I just thought about is that one of our core goals with this api is to not introduce any invasive dependencies. However, if you are using something like boost, you could just write a thin wrapper to marshall into boost and use that.
Furthermore, I am aware that just about every argument in C++ ends up being some sort of religious zealot argument based on theory and preference. To counter this trend we tend to be quite data driven in our development process. If you could provide some metrics on different implementations on modern operating systems, that would be helpful in our next iteration in providing better value to our customers.
I would welcome a pull request with a new pooled executor--along with your profiler metrics-- that someone could easily install, which we could offer to our customers. Remember, that it cannot have any additional dependencies beyond the core c++ libraries or the operating system apis in order for us to include it into this offering.
from aws-sdk-cpp.
Thank you for kind answer.
One more question,
Why did you divide the interface into two types: **Callable and **Async?
Rather, how about using std::async instead of thread creation and detaching? (let the OS manage thread-pooling..)
In gaming area, the performance of dispatching tasks is important. So you'd better give in detail in a ReadMe page like you mentioned: "Hence, we want sane defaults that can be overridden for each use case."
FYI:
In the past, we also used a custom executor like this: https://github.com/zeliard/Dispatcher
from aws-sdk-cpp.
The callable makes a std::async call. This seems most useful to me for batching with futures and things of that nature. However overriding the behavior of std::async is non-trivial and it doesn't really have the elegance of style that using closures has.
Async supports a more functional interface and it is trivial to implement a custom executor. They are two very different use-cases IMHO hence, two separate interfaces.
You can see both use cases in code in the dynamodb integration tests.
from aws-sdk-cpp.
I understood the intention about interface and use-case issues.
One more thing:
How about below YetAnotherDefaultExecutor as an another option?
This satisfies the conditions above. (no dependency, no thread creation every time, easy to change, ...)
https://github.com/zeliard/aws-sdk-cpp/blob/master/aws-cpp-sdk-core/include/aws/core/utils/threading/YetAnotherDefaultExecutor.h
https://github.com/zeliard/aws-sdk-cpp/blob/master/aws-cpp-sdk-core/source/utils/threading/YetAnotherDefaultExecutor.cpp
https://github.com/zeliard/aws-sdk-cpp/blob/master/aws-cpp-sdk-core/include/aws/core/utils/memory/ObjectPool.h
from aws-sdk-cpp.
I can only speak for myself here, but I lack the expertise to be able to confidently evaluate the correctness of a lockless queue implementation; I would far prefer to use an industrial-strength, well-vetted implementation like what you can find in boost or tbb.
This seems like a premature optimization: the cost of locking/unlocking a mutex is insignificant compared to the round trip time of an http request-response. A much-simpler mutex-based solution might be more appropriate.
Ultimately, we think these kinds of details and decisions are probably best left to the application or middleware programmer using the SDK.
from aws-sdk-cpp.
Related Issues (20)
- Build error: CURLINFO_APPCONNECT_TIME_T available only after v. 7.61.0 HOT 2
- How to disable Content-MD5 header with S3 PutObject request HOT 1
- Build failed for version 1.9.379 HOT 2
- Add C++20 modules support HOT 1
- Aws::Crt::ApiAllocator()", referenced from: Aws::Client::AWSAuthV4Signer::SignRequestWithSigV4a(Aws::Http::HttpRequest&, char const*, char const*, bool, long long, Aws::Crt::Auth::SignatureType) const in libaws-cpp-sdk-core.a[2](ub_core.cpp.o) HOT 3
- DefaultRateLimiter get stuck indefinitely HOT 4
- 10M memory leave after ShutdownAPI called for 1000 client created HOT 1
- AWS C++ SDK not compiling in Visual Studio 2019 HOT 4
- Http request failes due to WinHTTP error code 87 HOT 9
- S3-CRT Client signature error on s3 object keys with special characters HOT 5
- Using AWS C++ SDK with gcc-g++11 HOT 5
- Segmentation fault occured in Aws::InitAPI when called by static object , previsously working for aws sdk version 1.8.186 HOT 3
- libcrypto linking issue with AWS SDK 1.11.285 HOT 2
- Missing debug PDB files when building and installing with cmake HOT 4
- Unable to compile SDK with older windows SDK HOT 6
- fatal error: CommonCrypto/CommonDigest.h: No such file or directory HOT 16
- There is no possibility to omit double file reading caused by checksum calculation HOT 4
- Destructor S3CrtClient::~S3CrtClient() hangs, as of release 1.11.195 HOT 7
- S3 crt client timeouts and retry strategy are not working. HOT 9
- S3 client ignores http configuration HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sdk-cpp.