Comments (1)
I've narrowed the problem down to two buffers:
write_buf
in actix-http's h1 dispatcherbuf
in actix-web-actors' WebsocketContextFut
These buffers each use BytesMut
, which is designed to keep its capacity around as long as possible to optimize for bytes moving in and out.
Unfortunately, this means that once a BytesMut
grows to fit a set of continuous bytes, it won't shrink back down. In order to send a message over a websocket, these two buffers are filled with the entire contents of the file, the first after passing through the websocket encoder, and the second after passing through the http encoder.
I verified that if I std::mem::take
these buffers rather than write_buf.clear()
and buf.split()
them, memory use returns to basically nothing after the large file is sent.
Since the default behavior is to reuse existing allocations, i'm hesitant to actually mem::take
them as a fix here.
It does seem somewhat unfortunate that these buffers are needed at all when it seems that, at least for the http encoder, the actual message contents are not modified at all, and are simply copied verbatim. The ws encoder sometimes copies verbatim although sometimes there is a 4 byte mask applied at the start.
I don't know if I'd be confident enough to try to eliminate these extra buffers myself, though.
I'd be interested to hear @robjtede 's thoughts on potential solutions here
from actix-web.
Related Issues (20)
- Add pattern syntax for optional trailing slash HOT 2
- [How to] Middleware `Response body` manipulation.
- Add support to be able to test the route tree using `match_pattern` and `match_name`. HOT 2
- Connecting to the database from an external network causes a spike in connections HOT 1
- actix-http: Compilation fails HOT 1
- Err(NoWebsocketUpgrade) HOT 1
- 在 c++开发中,使用ws进行请求。会因为路径上有中文而报错,In c++ development, using ws for requests will result in an error due to Chinese characters in the path. HOT 1
- 在 c++开发中,使用ws进行请求。会因为路径上有中文而报错,In c++ development, using ws for requests will result in an error due to Chinese characters in the path. HOT 1
- actix-web doesn't compile with rustls 0.23.1 HOT 3
- target mips-unknown-linux-musl compilation failed
- Unexpected routing HOT 1
- Seems like web::Json can't deserilize json with nested keys as payload inside requests into rust structs
- Unable to get app_data information in middleware HOT 1
- match_pattern/match_info/match_name may return incorrect values when using route guards
- HTTP to HTTPS redirection not working?
- debug your demo hello world,An error occurred HOT 3
- Missing documentation regarding actix-web's default error responses
- actix-web v1.0.8 & actix-http-0.2.11 issue HOT 3
- awc deadlock on some network connections
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 actix-web.