Comments (3)
I think sending back the response, even encoded as
Vec<u8>
is quite costly in terms of performance, right? Unless we add something like Erlang's immutable binary data to just pass around pointers of large data. I think it's better if the handler writes to the response.
I was thinking the same, but it would not work in practice to have two writers. For example, if the supervisor has a timeout of 60 sec. It will send itself a message using send_after
that is delayed for 60 seconds. The sub-process might already start writing something to the TcpStream
and suddenly the supervisor is also writing a 408 Request Timed Out
mixed together to the same stream. The response needs to stay atomic and only answered by one process.
As you mentioned, in the future we will need a way to share bigger buffers with low overhead in lunatic. So, it's a problem that we will need to solve once this becomes a bottleneck, but I think we need to solve it in a more general way and not just as part of this web framework. I have some ideas on how to do this already that could also be combined with vectored i/o and avoiding serialisation and it would be completely safe to do so in scenarios like this, where one process is "ending" and giving up control over its linear memory to another.
Philipax was doing something similar in the past and turns out for a 4MB response it only takes 4ms.
Philpax — 05/23/2022
Switched over toserde_bytes
and it's much better now, thank you!
4 milliseconds, 4743875 bytes
might be nice to have that in a FAQ somewhere
I would just go with a simple solution for now, before we start optimising for message size.
from submillisecond.
Yeah, having just a single writer is of course better. But I was thinking maybe the supervisor could receive a start_writing
request and "allow" the handler to write. That being said, if it's only 4ms for a 4MB response we can just send a message to the supervisor and that should not be a problem for a long time. If/when we later optimise sharing large data in the vm this problem will cease to exist.
We should however look into using serde_bytes
for encoding the data for this
from submillisecond.
Once the Response data is available, it should send it as a message to the supervisor.
I think sending back the response, even encoded as Vec<u8>
is quite costly in terms of performance, right? Unless we add something like Erlang's immutable binary data to just pass around pointers of large data. I think it's better if the handler writes to the response.
from submillisecond.
Related Issues (20)
- RUSTSEC-2020-0071: Potential segfault in the time crate HOT 1
- RUSTSEC-2021-0139: ansi_term is Unmaintained HOT 2
- RUSTSEC-2021-0145: Potential unaligned read
- middleware compatibility HOT 1
- Examples don't work HOT 2
- RUSTSEC-2023-0065: Tungstenite allows remote attackers to cause a denial of service
- Session data
- Add a cookie extractor
- Where to put Guards? HOT 6
- Rename `static_dir!` macro to `static_router!`
- Router params don't work in params example HOT 7
- Support `[...]` syntax for multiple middleware in macro
- `params router` benchmark fails, route not matched
- Add support for wildcard routing `/*` HOT 2
- Add WebSocket support
- Create lunatic cli HOT 2
- Allow State passed into handler HOT 1
- Static router doesn't work with `"/"` path
- Support for dependency injection? HOT 2
- Server-Sent Events 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 submillisecond.