Comments (6)
But new does not return nullptr, it throws an exception.
This is "standard" correct, but not real world correct -- not everyone uses C++ exceptions (at the compiler level), therefore it could be nullptr. It's better to be safe than sorry.
from oatpp.
@FooBarWidget
Thank you so much for your code review, and your time!
It is very valuable input!
More documentation is really an issue and I am working on it right now.
Here is a brief answer and I will get back to you with the full answer a bit later:
What I do in Passenger is using smart pointers that do not use atomic counters.
I used to have custom smart-pointers in oat++ before but gave-up this idea in advantage for compatibility. So end-user could easier work with the framework.
Also performance impact was really very very small
I do not understand what ChunkedBuffer is supposed to be and how that's different from FifoBuffer
ChunkedBuffer
is basically a chain of chunks. It provides possibility to grow buffer without copying the memory. Also chunks are pool allocated in order to reduce memory fragmentation.FifoBuffer
is for the future feature and not used currently.
On the conceptual level, I have no idea how the coroutine stuff works and is supposed to be used. I have also no idea what concurrency model you are using. Is it one-client-per-thread?
Currently there are two concurrency models implemented:
- Multithreaded (1 connection - 1 thread)
- Async (fixed number of threads for all connections)
more is here https://oatpp.io/docs/simple-vs-async
Coroutines and Async:
Are used in the async model together with non-blocking IO (non-blocking sockets).
Coroutines are served by oatpp::async::Processor.
These are stateless coroutines. On each iteration coroutine returns Action
which is basically an action of what to do next. Action
provides possibility for additional prioritization like put to "waiting queue" coroutine which waits for IO.
You may treat this approach like app-level implementation of epoll/kqueue. But this gives additional space for experiments and it makes end-user API a bit easier.
Did you manage to run some performance tests on your machine?
Thank you for the code-review once again!
from oatpp.
I added some edits. In particular, I added feedback about zero-copy.
Also performance impact was really very very small
In my experience with Passenger, such impact was indeed small on its own. But I optimized Passenger by solving a thousand paper cuts — optimizing 1% here, 0.5% there, 1.2% there, etc. They all added up.
from oatpp.
This is "standard" correct, but not real world correct -- not everyone uses C++ exceptions (at the compiler level), therefore it could be nullptr
I just tried with both GCC and clang : adding -fno-exceptions
still makes new
throw an exception so I guess the number of cases where new
would return nullptr in real-world code is very very close from zero.
#include <cstdio>
int main()
{
constexpr auto max = 100000000000;
auto blob = new char[max];
// the following added to ensure that the compiler does not
// optimize the allocation if it's not used
auto f = fopen("/dev/null", "w");
fwrite(blob, 1, max, f);
}
->
$ g++ -O3 foo.cpp -fno-exceptions
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
the generated assembly does not even change : https://gcc.godbolt.org/z/YCrwAX - looking how it's done in libc++ you would have to recompile it with an additional define for instance, and how many people are actually able to recompile their stdlib ?
from oatpp.
I was mainly referring to MSVC (not sure if this is the same behaviour as GCC now, it never used to be) and people who may override new with their own memory stuff in future.
from oatpp.
My point w.r.t. operator new and exceptions is that the calling code only checks for nullptr, but does not attempt to catch an exception.
from oatpp.
Related Issues (20)
- Regarding oatpp::async::CoroutineWithResult HOT 9
- How to add default values to the QUERY parameters of an ENDPOINT?
- Enhance Deserializer's "Error. Unknown field"
- How can I use OATPP to handle web browser request download file. HOT 2
- Memory leak in Object mapping HOT 1
- Deserialize json when not include required field only gives error when the field is specified as null
- [Question] readBodyIntoDTO when there's a list in the body
- API question
- how to make dynamic sql use oatpp-sqlite HOT 1
- LazyStringMapTemplate::get returns Nullptr wich is not in oatpp.io Documentation
- Please add support for CMake 3.16
- Cannot test if required integer query parameter is empty
- [Question] Is it possible during compilation to write out the generated oas-3.0.0.json file?
- May memory leak
- How should I make my process send requests to the target when using OATPP HOT 4
- Stack corruption issue in ConnectionProvider.cpp
- Can not build project successfully
- Is it possible make oatpp::network::tcp::client::ConnectionProvider support bind client IP?
- specific async pattern implementation query HOT 4
- io_uring support request HOT 1
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 oatpp.