Why Programmers Need to Know Data Structures and How I Saved Uber $22,000 a Year

Proper use of data structures will help optimize code speed/memory. In large products, each optimization is multiplied by millions/billions of users. This is how I saved Uber $22,000 a year using basic knowledge of the Set data structure.

Problem

A commonly used app screen was sending impression analytics when scrolling through the screen with duplication. For example, if you saw “XYZ” on the screen 10 times, scrolling the content up and down several times, then the analytics were sent 10 times. At least once was enough.

Decision

I added deduplication analytics before sending. Below is a simplified pseudo code:

// Было
logAnalytics(for: uuid)

// Стало
let uuids = Set<String>()
...
if !uuids.contains(uuid) {
    uuids.add(uuid)
    logAnalytics(for: uuid)
}

Result

The chart below shows the volume of analytics for a particular event. Since the release of the optimized code (red arrow), you can see a drop in the number of events. The new code reduced the cost of analytics for this event by $22,000 per year.

Conclusion

Knowledge of data structures will help you optimize your code. The larger the product, the greater the optimization effect.


Thanks for reading the draft version of the article to Azizbek Matchanov, Aigul Jumanazarova, Muslimbek Abduganiyev.

About me

My name is Darkonbek. IT blog author 10x Engineer. I’m an iOS developer in San Francisco for Uber.

You can contact me by mail: darkhonbek.interview@gmail.com

Similar Posts

Leave a Reply