Back

Arijit Ray

 • 

Twilio • 8m

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/

0 replies3 likes

More like this

Recommendations from Medial

Image Description

Anmol Narang

Engineer, Entreprene... • 9m

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 replies4 likes

Sheikh Ayan

Founder of VistaSec:... • 17d

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
0 replies3 likes
Image Description

Mridul Das

Introvert! • 1m

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 replies5 likes
2
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 replies11 likes
1

Comet

#uiux designer #free... • 9m

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
0 replies3 likes
Image Description
Image Description

prakhar agrawal

Co-founder BYTES • 2m

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 replies5 likes
Image Description

Nalin Kumar Srivastava

B.Tech Student | Dat... • 19d

Looking for Co-Founders & Team: Building AI-Powered Synthetic Memory for Humans! Imagine a future where you never forget an important conversation, an idea, or a moment. We’re building an AI-powered Synthetic Memory System—a revolutionary way to cap

See More
2 replies3 likes
Anonymous
Image Description
Image Description

Posting this as anonymous for a reason. Does anyone suffer from memory related issues? I have terrible working memory where I can hold short term information in my memory for long. This affects me from performing day to day activities. I can't do men

See More
19 replies11 likes
2

Rohit joshi

Dev dev dev • 15d

🎥 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
0 replies1 like
Image Description
Image Description

Startup Savvy

Entrepreneur is What... • 1y

Stages of A Startup 1)Ideation Stage 2)Planning Stage 3)Commitment Stage 4)Pre Seed Stage 5)Validation Stage(Pivot) 6)Seed Stage 7)Series Stage A/B/C/D................n 8)Growth Stage 9)Scaling Stage OR 9) Exit Stage

2 replies9 likes
4

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