Back

Arijit Ray

ย โ€ขย 

Twilioย โ€ขย 12m

Did you know that you can optimise memory by changing the order of struct fields in Go? Its fascinating! Right? I didn't know this until I saw this for myself in a reddit thread's example. Now this is not a new thing. Programming languages like C/C++ already has this concepts up and running for decades. Turns out, most processors access data more efficiently when data is aligned to certain byte boundaries (e.g., 2, 4, 8 bytes). For instance, an int64 (which is 8 bytes) is most efficiently accessed when stored at a memory address that is a multiple of 8. To achieve this alignment, Go automatically adds padding between fields in a struct. This padding can increase the size of a struct if fields are not ordered optimally. By ordering fields from largest to smallest, you minimise the amount of padding required between fields, resulting in a smaller overall memory footprint. Here are the links that where I found this: The Example: https://go.dev/play/p/MBXg4UBOerp The Thread: https://www.reddit.com/r/golang/comments/qcab7p/you_can_optimize_memory_by_changing_the_order_of/

Reply
3

More like this

Recommendations from Medial

Image Description
Image Description

Chamarti Sreekar

Fcuk imposter syndro...ย โ€ขย 10d

Why So Many Billion-Dollar Startups Start With โ€œCโ€ Coinbase. Canva. Calm. Coursera. Crunchbase. Cloudflare. Clubhouse. Even ChatGPT. This isnโ€™t just a coincidence. In branding, patterns like this are rarely accidents โ€” theyโ€™re often rooted in how o

See More
8 Replies
18
Image Description

Anmol Narang

Engineer, Entreprene...ย โ€ขย 1y

Many engineers wrongly blamed Microsoft for the outage. In reality, it was due to a buggy update from Crowdstrike for Windows. This update ran in Kernel mode, trying to access an invalid memory location, causing a Blue Screen of Death. The problemati

See More
2 Replies
4

Indhiran M

Co-founder at social...ย โ€ขย 1m

๐Ÿš€ Big Moves from Social Struct! Weโ€™re thrilled to announce that Social Struct, our growing influencer marketing agency, is expanding its reach to Kolkata! From connecting powerful local influencers to forward-thinking brands, weโ€™re building real

See More
Reply
5

Sheikh Ayan

Founder of VistaSec:...ย โ€ขย 4m

Bypassing EDR with Custom Shellcode Loaders โ€“ A Red Teamer's Approach Modern EDRs use user-mode hooks, behavioral analysis, and memory scanning to flag malicious activity. To bypass them, you need precision-crafted tooling. This deep-dive explores

See More
Reply
3
Image Description

Mridul Das

Introvert!ย โ€ขย 6m

Here is everything you need to know about the startup BYTES, which has secured a Rs 20 lakh๐Ÿ’ฐ non-dilutive grant from Nikhil Kamathโ€™s WTFund as part of its second cohort . โžก๏ธ This Bengaluru-based startup๐Ÿ’ก focused on AI-powered Advanced Driver Ass

See More
1 Reply
2
5

Manit

Young mind. Bold cod...ย โ€ขย 2m

I want to share my side-project. I'm currently exploring, and I'm very curious about technology, especially old tech and the future of new tech. It's my summer vacation, and I want to deep dive into low-level programming. I know C and C++, and I'm tr

See More
Reply
2

Comet

#freelancerย โ€ขย 1y

CSS Pro Tips, Day 1: Simplify Your CSS with a CSS Reset A CSS reset is a helpful tool in ensuring consistent styling across various browsers. It allows you to start with a clean slate for styling elements. Instead of searching for pre-made reset pat

See More
Reply
3
Image Description
Image Description

Jeet Sarkar

Technology, Developm...ย โ€ขย 1y

Western Digital recently launched a groundbreaking 4 TB digital memory card for mobile devices. This cutting-edge memory card is slated to be available from next year onward and boasts a data transfer speed capable of reaching up to 104 MB per second

See More
2 Replies
1
11
Image Description
Image Description

prakhar agrawal

Co-founder BYTESย โ€ขย 6m

Announcing BYTES: Indiaโ€™s First AI-Powered ADAS for Safer Two-Wheeler Mobility After months in stealth mode, I am thrilled to unveil BYTES, our venture dedicated to transforming mobility with innovation and safety at its core. Why This Matters: -

See More
3 Replies
5

Rohit joshi

Dev dev devย โ€ขย 4m

๐ŸŽฅ AI agent YouTube Automation Series: VIDEO to AUDIO in C#! (Part 1) In **Part 1**, weโ€™re laying the foundation for an *AI agent* that automatically generates **titles and descriptions** for your videos โ€” starting with the *crucial first step*: **c

See More
Reply
1

Download the medial app to read full posts, comements and news.