rust - Memory cost of sending items over mpsc channel
问题描述
I have two threads that read a stream of messages from two sources and then forward them to a third sink where they get processed in order.
I'm concerned about the overhead of copying data as my messages are on each thread's stack and to move them through mpsc
, every bit has to be copied over to the sink's stack.
If I try to mitigate this by putting my message in a Box
, then only the pointer would be sent over to the new stack but still a copy happens from source's stack to heap.
And I'm not entirely sure if my message is on heap or stack, as I saw a blog post in rust-lang.org the other day which claimed a vec![1,2,3]
lives on stack, which if true, is something I wouldn't have guessed.
解决方案
推荐阅读
- javascript - 如何使用 Jest 测试速率限制?
- linux - 参数 -r 在 ShellScript 中重新启动程序
- c# - C#位置()处没有行
- c# - 文本更改完成后,WPF 运行 TextChanged 触发器
- arrays - Numpy 数组从列到行向量被翻转
- javascript - 下一个带有 Vercel 的 js 自定义目录
- python - 为什么在尝试使用 .kv 文件时出现语法错误,即使我安装了 kivy?
- reactjs - 使用 react-snap 时出现页面崩溃错误
- groovy - 如何将 Groovy 输出写入 JIRA 字段?
- java - 如何以及在何处使用 JWT 在 Spring Boot 中实现基于角色的访问