Josh Haberman Profile
Josh Haberman

@JoshHaberman

Followers
607
Following
356
Media
5
Statuses
299

I work on the Protocol Buffers team at Google. I created upb (a small C protobuf implementation) and Bloaty (an ELF/Mach-O/PE/WASM binary size profiler).

Seattle, WA
Joined May 2011
Don't wanna be here? Send us removal request.
@WalterBright
WalterBright
7 days
This debugging technique should be common knowledge, but I run across it all the time. When an error message is confusing, by far the most practical method to figure it out is to: 1. copy the file to a new file, save the original 2. delete code until the message goes away 3.
16
12
169
@kenjin4096
Ken Jin
11 months
I just merged a new interpreter into Python 3.14. This interpreter promises -3-30% better performance on newer compilers. https://t.co/8EQUMrdjkP Thanks to Mark Shannon, Donghee Na, Diego Russo, Garrett Gu, Haoran Xu, and @JoshHaberman for ideas and help.
3
29
270
@JoshHaberman
Josh Haberman
11 months
New from me: "No-Panic Rust: A Nice Technique for Systems Programming":
blog.reverberate.org
Parsing, performance, and low-level programming.
1
0
3
@JoshHaberman
Josh Haberman
2 years
I'm getting more and more spam texts these days. I can imagine a future where texting platforms don't allow cold calls from unknown contacts without an extra token. The extra token could come from a mutual friend who shared the contact, or an in-person contact exchange.
0
0
2
@JoshHaberman
Josh Haberman
2 years
I wish there was a way to factor code internally such that you can enforce a strict DAG shape when you want to.
0
0
0
@JoshHaberman
Josh Haberman
2 years
You can break a crate into private modules. But modules are allowed to have circular dependencies between them. So within a crate, there is no enforced discipline to prevent the crate from being arbitrarily tangled spaghetti.
1
0
0
@JoshHaberman
Josh Haberman
2 years
Rust doesn't seem to have the concept of an internal/private crate. Any dependency of a public crate must also be publicly published on https://t.co/1MO6kmo5hr. There's no way to split a library into multiple crates in a way that is invisible to end users.
1
0
0
@JoshHaberman
Josh Haberman
2 years
When I inspect the Rust extension, a lot of the file size seems to come from Gimli (DWARF parser), backtrace code, and addr2line. In other words, debugging functionality. Maybe this means that pyo3 will have amazing output when something goes wrong. Here's to hoping.
0
0
1
@JoshHaberman
Josh Haberman
2 years
File size of a trivial Python extension (Rust/pyo3): 401kB File size of the protobuf Python extension (C): 277kB The Rust extension has a single function that adds two numbers. The C extension implements all of protobuf. Both figures exclude debug info.
1
0
2
@JoshHaberman
Josh Haberman
4 years
Unfortunately this makes it more difficult to avoid copies and allocations. I'm rewriting some code to use Vec+indexes instead of arenas+references. It's working ok, but Vec is less efficient than an arena in multiple ways.
0
0
1
@JoshHaberman
Josh Haberman
4 years
My biggest takeaway from Rust so far is that borrows should be relatively short-lived. While it is possible to put references in a long-lived struct, it creates spiraling complexity and is overall not worth it. Rust wants structs to own their members.
1
0
5
@JoshHaberman
Josh Haberman
4 years
More ideas: - *printf() variants that are *not* affected by locale - setjmp()/longjmp() variants that do *not* touch the signal mask - qsort_r() - dtoa() (print shortest string that will round-trip a double)
0
1
3
@JoshHaberman
Josh Haberman
4 years
I hear C is adding new stuff like lambdas. Here is what I'd rather see: - musttail for guaranteed tail calls ( https://t.co/Mv3easbmi3) - arithmetic with overflow checking ( https://t.co/kg55qDJ305) - uint128_t (or at least _umul128()) Less sugar, more low level capabilities.
1
1
7
@JoshHaberman
Josh Haberman
4 years
Another Rust-focused post: my experience trying out arenas in Rust:
blog.reverberate.org
Parsing, performance, and low-level programming.
1
3
10
@JoshHaberman
Josh Haberman
4 years
This is a fleshed-out version of my previous Twitter thread on the same subject:
@JoshHaberman
Josh Haberman
4 years
It appears that Rust's "Sync" trait is equivalent to the C++ concept of thread-compatible: https://t.co/M3TiHtJjbK Sync does *not* map to C++'s concept of thread-safe. Example: Vec is Sync, but would not be considered thread-safe in C++.
1
0
1
@JoshHaberman
Josh Haberman
4 years
I wrote a blog entry that compares thread-safety concepts between C++ and Rust:
blog.reverberate.org
Parsing, performance, and low-level programming.
1
1
5
@JoshHaberman
Josh Haberman
4 years
You can create a Rust type that provides mutable operations that can be performed on a non-mutable reference. If you also made such a type Sync, that would be the best equivalent of a C++ thread-safe type.
0
0
2
@JoshHaberman
Josh Haberman
4 years
Thread-safe in C++ means "allows shared mutable access". But Rust forbids this at the language level. So it would be useless to implement a Rust type that implements the C++ concept of thread-safe.
1
0
2
@JoshHaberman
Josh Haberman
4 years
It appears that Rust's "Sync" trait is equivalent to the C++ concept of thread-compatible: https://t.co/M3TiHtJjbK Sync does *not* map to C++'s concept of thread-safe. Example: Vec is Sync, but would not be considered thread-safe in C++.
1
0
2
@JoshHaberman
Josh Haberman
4 years
The ELF/DWARF naming scheme makes for some odd Google results when you're looking for technical information. I'm implementing Fission / split DWARF for https://t.co/E7yu8L3twB. When I Googled "dwarf skeleton" I did not get the results I was looking for.
Tweet card summary image
github.com
Bloaty: a size profiler for binaries. Contribute to google/bloaty development by creating an account on GitHub.
0
0
7