Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
haberman
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
47 ms
·
481.
▲
by
haberman
6y ago
I haven't implemented the fallback yet, but my thought was to keep most of the structure the same (dispatch function tail calls to the function for an individual operation) but then have the individual operation just return instead of
482.
▲
by
haberman
6y ago
If the optimization is not performed, you blow the stack because your stack usage is now O(n) instead of O(1). That's why it's important to get the optimization in debug mode.
483.
▲
by
haberman
6y ago
> I assume that's for good use of the CPU's instruction and microcode caches. I don't think that is the reason. These are microbenchmark results, where realistically all the code will be hot in caches anyway. The problem
484.
▲
by
haberman
6y ago
It's exposed in the API. When you access a string field in protobuf, say foo.my_str_field(), the return type is const std::string&. We have to have a real std::string internally to return a reference to it.
485.
▲
by
haberman
6y ago
It sounds like the main question in the proposal is: how can we reliably get the compiler to generate threaded/replicated dispatch? While that is important, it is only one small part of what we were trying to achieve with tail calls.
486.
▲
by
haberman
6y ago
The C++ parser has been completely rewritten in the last few years to push the current code generation design to its limits. The biggest obstacle in the way of optimizing it further is legacy APIs, especially std::string for string fields,
487.
▲
by
haberman
6y ago
We use the "noinline" attribute to get control over inlining, which gives a reasonable assurance that we'll get a normal standard ABI call with six parameters in registers on x64/ARM64.
488.
▲
by
haberman
6y ago
Article author here. I dumped my test protobuf payload (7506 bytes) to JSON and got 19283 bytes. So parsing this particular payload at 2GB/s would be equivalent to parsing the JSON version at 5.1GB/s. SIMD doesn't end up help
489.
▲
by
haberman
6y ago
So I was not able to get simdjson going in time, but I did dump my test payload to JSON. In protobuf the payload was 7506 bytes, in JSON 19283 bytes. So parsing this particular payload at 2GB/s would be equivalent to parsing it at 5.1
490.
▲
by
haberman
6y ago
From your link: > Support for Protobuf buffer serialization was a multi-year effort between Microsoft and Google engineers. Changes were spread across multiple repositories. The implementation being discussed there is the main C# impleme
491.
▲
by
haberman
6y ago
Wow thanks for the pointer! That seems unfortunate, I wonder if there is a way to evaluate whether the extra jump is actually worth it, and whether this optimization could be allowed.
492.
▲
by
haberman
6y ago
Tail calls are a very common optimization, both Clang and GCC have been performing this optimization successfully for a while. What is new is getting a guarantee that applies to all build modes, including non-optimized builds.
493.
▲
by
haberman
6y ago
You really wouldn't. We tried many approaches, including computed goto, but none of them were able to generate satisfactory code when compared with tail calls: https://gcc.gnu.org/pipermail/gcc/2021-April
494.
▲
by
haberman
6y ago
Yep, that's exactly the right takeaway. :) I have verified this on ARM64 also, but architectures that pass parameters on the stack will make this technique not really worth it. Re: PHP, Ruby, etc. yes, computed gotos help some, but I
495.
▲
by
haberman
6y ago
That would defeat the entire purpose: they need to be six parameters to ensure that they are all in registers. However I was considering whether they could be a struct with six members passed by value. If the ABI would pass that in six reg
496.
▲
by
haberman
6y ago
That is true, but there is always https://rr-project.org for easy reverse debugging if you're having trouble figuring out where you came from. If the alternative is to drop to assembly, a C-based approach seems quite easy t
497.
▲
by
haberman
6y ago
Article author here. I agree that would be a very englightening benchmark. Protobuf can dump to JSON, so it shouldn't be too much work to dump my benchmark data to JSON and benchmark the parsing with simdjson. Maybe I'll see if I
498.
▲
by
haberman
6y ago
The musttail attribute performs several checks to ensure that a tail call can be guaranteed, and rejects the program if these rules are violated. The documentation has the details: https://github.com/llvm/llvm-project&
499.
▲
by
haberman
6y ago
Wasm3 calls its interpreter design a "meta machine": https://github.com/wasm3/wasm3/blob/main/docs/Interpreter.md... It is heavily based around tail calls. I recently wrote a blog article
500.
▲
Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Calls in C
(blog.reverberate.org)
6 points
by
haberman
6y ago
|
0 comments
501.
▲
by
haberman
6y ago
> OK, the pclntab is large. Why is it large? What are the specific things in it that are large? Is it reasonably easy to attribute individual entries in pclntab to specific symbols? If so I'd love to add this capability to https:&
502.
▲
by
haberman
6y ago
> The sum of the sizes reported by go tool nm does not add up to the final size of the Go executable. > At this time, I do not have a satisfying explanation for this “dark” file usage. The author's journey of starting with "
503.
▲
by
haberman
6y ago
Why does desalination produce brackish water (this is a new term to me)? From context I expected "brackish water" to mean water that is saltier than seawater. But when I look it up, it's apparently water with salinity betwe
504.
▲
by
haberman
6y ago
This is a really gracious comment, thanks for being so understanding.
505.
▲
by
haberman
6y ago
I won't pretend to be familiar with the academic literature, but here is one paper I found: https://www.sciencedirect.com/science/article/abs/pii/002210... > The field situation consisted of a pa
506.
▲
by
haberman
6y ago
How much evidence is there that insulting others is an effective way to get them to change their opinions and support the policies you favor? If the basis of your annoyance is ineffectiveness, then I would expect you to feel a lot of annoy
507.
▲
by
haberman
6y ago
> STFU with all of the moralizing Parent is responding to accusations of "conservative prejudice." That is its own moralizing. You can make the pragmatic argument that it's pointless to try to control the risky behaviors
508.
▲
by
haberman
6y ago
I was responding to your claim/question (not the article): > Isn't the "work should just be for work" attitude simply a political statement of its own—one in support of the status quo? If we accept your premise, it al
509.
▲
by
haberman
6y ago
Of course there are important social changes that have happened with respect to weddings and marriage. The question is: did those things change because of political confrontations that happened at weddings themselves ? A wedding is a cele
510.
▲
by
haberman
6y ago
Is a wedding supporting the status quo by asking guests to dress appropriately and sit quietly during the ceremony? Is a movie theater supporting the status quo by running the movie from beginning to end without an intermission for politic
More ›