A few months ago, as users started throwing more API traffic at the Akita client, we started seeing multi-GB memory spikes. 🙀

At first, we hoped for an easy solution. There was none.

This is the story of @markgritter's 25-day journey taming memory usage in a #golang client. 1/ Memory spikes in the Akita CLI
@markgritter The first thing @markgritter did, as you would do in most languages, was to profile the system for obvious bottlenecks.

There was one, in the #gopacket reassembly buffer. Memory was persisting even though it wasn't getting used.

Mark fixed this, but the problem persisted. 2/ Profile showing bottleheck in reassembly
@markgritter At this point, the team and I weighed possible next steps.

Since #golang is memory-managed (2x memory overhead no matter what 🙀) and does not expose much control over the garbage collector, we were worried that it was not possible to be able to get memory usage low enough. 3/
@markgritter When I asked about other solutions, @markgritter said, "One solution is to rewrite the CLI in #Rust."

As Rust gives control over memory management and our code base was not huge, a rewrite was viable.

We ended up talking through the pros and cons of this option seriously. 4/
The major factor in our rewrite decision was speed to a functional, scaling CLI.

A #Rust rewrite was bounded time, but a lot of it. We didn't know how long it would take to fix our #golang memory issues.

A rewrite meant that we'd be trading off one set of issues for another. 5/
And some people think we're joking here, but "ability to hire good people and build faster" was a very real factor in our decisions.

Recently, we've noticed that not only have Rust rewrites become a Startup Thing, they're actually working in terms of attracting talent! 🙀 6/ Why is Rust so popular with people joining startups?
We ended up deciding @markgritter would spend a bounded number of weeks fixing the memory issues in #golang.

If memory usage remained too high, we would seriously consider a rewrite.

If Mark could fix the issues, then we could tell everybody how we managed to buck the trend. 7/
After a couple of weeks in the depths of despair, @markgritter finally got our #golang CLI to an acceptable level of memory usage.

While identifying fixes often required understanding the Go GC, many of the fixes themselves had to do with using libraries more efficiently. 8/
It turns out that @markgritter's initial reaction that rewriting in #Rust would have traded one set of problems for another was right.

If we had done a rewrite from #golang to #Rust, we would have had to go through an analogous process of finding inefficient library usage. 9/
Now @markgritter has suffered so you don't have to! He's written this EXCELLENT blog post about his experience taming #golang memory here:
akitasoftware.com/blog-posts/tam…

And I've actually been learning quite a bit about the discussion in the HN comments:
news.ycombinator.com/item?id=286080…

end/

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with ⚡️ Jean Yang ⚡️

⚡️ Jean Yang ⚡️ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @jeanqasaur

15 Sep
Been talking with a lot of people who are burned out at work right now. I got quite burned out at the end of college and in the middle of my PhD. Today, I work way more than I did back then and am able to feel really fulfilled. Here are some lessons that helped me get here. 🧵 1/
First and foremost, it's helpful to recognize that you're burned out. Are you feeling less creative? More irritable? Over the years, I've learned to recognize micro-burnouts (from "I need lunch" to "I need a vacation") and I like to believe that's kept me from macro-burnout. 2/
Working sustainably is key to preventing burnout. For me, i's not about limiting hours but about building in recovery. The recovery needed depends on the intensity and duration of the work. If I go for longer without recovery, the recovery will need to be longer/more involved. 3/
Read 6 tweets
6 Aug
Every now and then, I see a thread about how functional programming languages are The Way, wondering why they aren't more popular.

A big problem is that people talk about functional programming as The Way for Everything. FP has its place. All tools have their roles. 🧵 1/
The elegance of functional programming makes it an appealing "silver bullet" candidate.

But here are the domains where FP really shines:
1. Programming education
2. Prototyping language features and analyses
3. Domains where you're mostly specifying transformations

2/
I fell in love with Scheme and SML in undergrad. I taught myself Haskell and extended it for my senior thesis. In grad school I worked in Haskell, then OCaml, then Scala.

But by the end of grad school, I was mostly using Python.

Here's what happened.

3/
Read 9 tweets
14 Jul
Why aren't there more startups based on programming languages and software analysis?

There's definitely a need for SOMETHING, as developers have so much pain.

I was recently on a panel where someone asked this question. I didn't have time to answer then, so here's a thread. 1/
There's often a gap between the creators of "principled" programming tools and the needs of working developers.

There are two common technical assumptions: 1) code correctness is a top priority and 2) it's possible to understand the whole system.

Often, neither hold. 2/
In programming languages and formal methods there's the dream of "soundness:" if there's a bug, the tool will find it.

People don't want to know all of their problems. They want a prioritized list of problems that matter. This technical goal is often at odds with user needs. 3/
Read 7 tweets
13 May
Taylor Swift as notable #AAPI computer scientists. 🧵

Andrew Yao, 2000 Turing Award Winner. Known for proving Yao's Principle. See also: Yao's Millionaire's problem.

#AAPIMonth
Raj Reddy, winner of the 1994 Turing Award for pioneering work in artificial intelligence. Mentor to @kaifulee.

#AAPIMonth
@kaifulee Jeannette Wing, who co-developed the Liskov Substitution Principle. Leader in formal methods research. Head of @SCSatCMU 2004-2007 and 2010-2012.

#AAPIMonth
Read 6 tweets
6 May
Earlier today, @the_prion asked me what the hardest part about starting @AkitaSoftware was.

My answer: figuring out how to build a team that balances user-focused product thinking with the deep technical expertise required to power it (in our case).

Thread. 🧵
@the_prion @AkitaSoftware At Akita, we're making it easier to detect the API regressions that matter. We want to do this as non-invasively as possible, with the highest information content possible.

This means keeping code changes/perf overhead as minimal as possible, while keeping false positives low.
@the_prion @AkitaSoftware Keeping code changes and perf overhead as low as possible is not easy, and constantly requires balancing software architecture decisions with user-facing tradeoffs.

Keeping false positives low is also a really hard trace analysis problem that also has many user-facing tradeoffs.
Read 5 tweets
6 May
A professor friend told me that some female students in her dept asked her how she dealt with being in a male-dominated field. She told them she was an internalized misogynist and didn't have any female friends, but then I taught her to be friends with women again.

Thread. 👇
It's a very human phenomenon to distance yourself from the traits that other people don't respect in you! Think about all the high school movies where the nerd ditches their nerd friends to be cool. 🥸

For any woman who needs to hear it: befriend and champion other women.
Related: I was recently talking to a group of younger female CS alums from my university and they said it was rare for them to have such a technical conversation with a woman.

I was taken aback, but realized that I also felt that way before I found other technical woman friends.
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(