TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Pb-jelly – A Protobuf code generation framework for Rust, developed at Dropbox

162 点作者 dochtman超过 4 年前

7 条评论

haberman超过 4 年前
I work on the protobuf team at Google, and I&#x27;m a big fan of Rust, though I haven&#x27;t written much actual Rust except a bunch of Project Euler solutions.<p>For protobuf in C++, we&#x27;ve been moving more and more in the direction of using arenas for memory allocation. When you parse a protobuf, it creates a tree of objects that are usually all deleted at the same time. Freeing an arena is much, much cheaper than traversing the tree of objects and calling free() on each one.<p>My dream has been that Rust protobuf could support arenas as well as C++, but use Rust&#x27;s type system to make it all provably correct at compile time (in C++ the lifetime management is inherently manual and unsafe). For absolute top performance, arenas will always beat trees of unique pointers (which I think corresponds to Rust&#x27;s Box&lt;&gt; type).<p>I don&#x27;t know Rust&#x27;s type&#x2F;lifetime system well enough to know if this is possible. I was looking recently at arenas in Rust and I noticed that Rust&#x27;s version of placement new seems to be stalled:<p>&quot;Unfortunately the path forward for placement new in Rust does not look good right now, so I&#x27;ve reverted this crate to work more like a memory heap where stuff can be put, but not constructed in place.&quot;<p><a href="https:&#x2F;&#x2F;docs.rs&#x2F;light_arena&#x2F;1.0.1&#x2F;light_arena&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;light_arena&#x2F;1.0.1&#x2F;light_arena&#x2F;</a><p>Does anyone know more about this?
评论 #24495266 未加载
评论 #24494915 未加载
评论 #24494960 未加载
评论 #24495894 未加载
评论 #24494851 未加载
评论 #24497657 未加载
评论 #24498167 未加载
q3k超过 4 年前
From pb-jelly-gen:<p>&gt; The core of this crate is a python2 script codegen.py that is provided to the protobuf compiler, protoc as a plugin.<p>That&#x27;s... surprisingly janky. Not only Python tooling is always painful to deal with (compared to Go&#x2F;Rust&#x2F;...), but Python 2? And in a project that otherwise has no reason to depend on Python? :(<p>In comparison, the Go protoc plugin is written in Go, the alternatice rust-protobuf protoc plugin is witten in Rust, the Typescript one is written in Typescript...
评论 #24495029 未加载
评论 #24494085 未加载
评论 #24494247 未加载
评论 #24496650 未加载
评论 #24494068 未加载
deepsun超过 4 年前
There&#x27;s already 6 different protobuf libraries for Rust: [1]<p>I&#x27;ve chosen Prost for our project, but see the whole list:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;stepancheg&#x2F;rust-protobuf#related-projects" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;stepancheg&#x2F;rust-protobuf#related-projects</a>
评论 #24494651 未加载
staticassertion超过 4 年前
This is great. AFAIK this is the only protobuf library in Rust that supports zero copy. Maybe this&#x27;ll help some of the other libraries implement similar features?
评论 #24494874 未加载
评论 #24494787 未加载
zxv超过 4 年前
Cool. It would be interesting to compare benchmarks the RPC latency under heavy load for pb-jelly compared to other RPC methods.<p>Rust has such great support for performant zero copy serialization and de-serialization in various formats (bincode, message pack, cbor, bson). Seeing this for protobuf feels very encouraging.
jl2718超过 4 年前
Is there really any good reason for code-gen? Just because “google did it” doesn’t mean it’s a good idea.
评论 #24494498 未加载
评论 #24494732 未加载
评论 #24494491 未加载
评论 #24498960 未加载
james412超过 4 年前
I know it&#x27;s common and perhaps even fashionable, but FWIW language like &quot;We take an opinionated stance&quot; utterly puts me off caring about this package<p>It&#x27;s a piece of software, it has a design that is either fit for purpose or not. When ego becomes entangled in that design process, it&#x27;s a strong indicator of the kind of experience one might have trying to get fixes or enhancements merged, or even the kind of attitude you&#x27;d find when attempting to report a bug.
评论 #24494725 未加载
评论 #24494766 未加载