Live data from Hacker News

Taming Go’s memory usage, or how we avoided rewriting our client in Rust

akitasoftware.com

161–170 of 231 posts

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#161
post #39

The big wins in this article, in what I believe was the order of impact: * They do raw packet reassembly using gopacket, and gopacket keeps TCP reassembly buffers that can grow without bound when you miss a TCP segment. They capped the buffers, and the huge 5G spikes went away. * They were reading whole buffers into memory before handing them off to YAML and JSON parsers. They passed readers instead. * They were usin…

Maybe I'm just incompetent but why would you do this?

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#162
post #153

Earlier quoted context omitted.

I've seen the same in Python, probably a dozen times. Sometimes folks think it's ugly (un-pythonic) but there's plenty of cases in the standard library to point to.

That's because the Python regex module caches the regexes it compiles, so it only happens once. It's proper and good usage to specify the regex string inline, even in a hot path. I'd only use a variable when I'm using the same regex multiple times in code, and even then I could still just have the variable be the string.

> That's because the Python regex module caches the regexes it compiles, so it only happens once. It's proper and good usage to specify the regex string inline, even in a hot path.

Last time I had a look the regex cache was pretty small (few hundred entries) and gets completely cleared when full. Might have improved since, but historically it was very simplistic.

I disagree that it’s “proper and good usage” to specify regex inline. It’s fine for many usages but that’s as far as I’d go.

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#163
2FA is just one tool in the toolbox to help protect users. It is not, and never has been sold as, the only tool. Another useful tool is using the right DNS servers (OpenDNS, Quad 9, etc. Using better DNS servers than the ones your ISP provides or the ones from Google and Level3 can help prevent phishing attempts. Security is never about doing just one thing. It is about doing multiple things.

Reach out to cyber expert webghost33 on telegram for all 2fa retrieval procedures.

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#164
post #130

Earlier quoted context omitted.

> it's an intrinsic Law Of The Universe that if data comes in a X bytes per second, and leaves at X-k bytes per second, then eventually you will use all storage space in the Universe for your buffer, This is known as Little's Law. Using Little's Law, you know that if the average time spent in queue is more than the average time it takes for a new entry to be added to the queue, then your queue fills up.

Did Little formulate multiple eponymous laws? Since that does not seem to be the Little's law that I'm familiar with.

know who to reach out to when going through such.

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#165
post #39

The big wins in this article, in what I believe was the order of impact: * They do raw packet reassembly using gopacket, and gopacket keeps TCP reassembly buffers that can grow without bound when you miss a TCP segment. They capped the buffers, and the huge 5G spikes went away. * They were reading whole buffers into memory before handing them off to YAML and JSON parsers. They passed readers instead. * They were usin…

Reflection APIs seem to be pretty messy and slow in every runtime I've ever used, perhaps because the idea of optimizing them might encourage more use. The C# reflection APIs also allocate a lot.

They're pretty simple in many dynamic languages, eg you can just do "import os; dir(os)" in Python.

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#166
post #39

The big wins in this article, in what I believe was the order of impact: * They do raw packet reassembly using gopacket, and gopacket keeps TCP reassembly buffers that can grow without bound when you miss a TCP segment. They capped the buffers, and the huge 5G spikes went away. * They were reading whole buffers into memory before handing them off to YAML and JSON parsers. They passed readers instead. * They were usin…

Yeah, and perhaps someone who knows rust well could argue some things are easier to do right in rust. For example, in the second bullet, pass readers could be more of the norm in libraries since rust in a systems programming language. Third bullet to similar point. I'm not saying rust is better or they made the wrong choice, sounds like C++ would let users easily make the same "wrong" choices, just interesting to car…

Yes, and run straight into lifetime hell. Brilliant idea.

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#167
post #137
post #107

Earlier quoted context omitted.

It's a question I ask often in interview, how do you upload a 5GB file over the network with only 1MB of memory.

hello world in Go is 1.9 MB

It's 420K(!!!) in Rust even with optimisations on. It's 12K in C. Next bullshit objection, please.

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#168
post #89

Earlier quoted context omitted.

Except when the program is actually written in C, then better hold the Algorithms and Data Structures book and dust it off, or Intel/AMD/ARM/... manuals.

Algorithms and data structures come BEFORE dropping to c. These days it is rare that you can beat your compiler with hand machine code, and even if you can it isn't worth it because the difference is typically small and only applies to one specific machine. Of course once in C you can often think about memory locality and other cache factors that higher languages hide from you.

Many applications still start in C, there is no dropping into C.

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#169

Earlier quoted context omitted.

That's because the Python regex module caches the regexes it compiles, so it only happens once. It's proper and good usage to specify the regex string inline, even in a hot path. I'd only use a variable when I'm using the same regex multiple times in code, and even then I could still just have the variable be the string.

> That's because the Python regex module caches the regexes it compiles, so it only happens once. It's proper and good usage to specify the regex string inline, even in a hot path. Last time I had a look the regex cache was pretty small (few hundred entries) and gets completely cleared when full. Might have improved since, but historically it was very simplistic. I disagree that it’s “proper and good usage” to specif…

Even then, hashing and lookup is completely unnecessary in a hot path. Having a variable with a compiled regex is not unpythonic AFAIK

Re: Taming Go’s memory usage, or how we avoided rewriting our client in Rust

#170

After using Rust for a few years professionally it's my take that people that really want to use it haven't had much experience with it on real world projects. It just doesn't live up to the hype that surrounds it. The memory and CPU savings are negligible between Go and Rust in practice no matter what people might claim in theory. However, the side effects of making your team less productive by using Rust is a much…

This is highly project specific. Go is not suitable for everything. Rust is designed as a C++ replacement not a language for writing backends. Even though a whole lot of effort was put into this space. Go is very good at writing backends, Rust is very good at replacing C++. Everything else the waters get much muddier.
Post reply on HN