Back to feeds

Arijit Ray

ย โ€ขย 

Twilioย โ€ขย 4m

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

Stealthย โ€ขย 6m

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

Jeet Sarkar

Stealthย โ€ขย 9m

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

Payal Manghnani

Stealthย โ€ขย 5m

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

Rajat Garg

Stealthย โ€ขย 9m

Is it good to store fields which are used to calculate or the final calculated information in the DB? Example I have a table XYZ I need to find the area of the rectangle so should I have a field called area or should I have the fields called lengt

See More
1 replies4 likes
Image Description

Varun J Shenoy

Stealthย โ€ขย 10m

Kya Haal Chaal! A new beginning on this new professional social media platform. Looking forward in interacting with the industry experts on various fields....

3 replies8 likes
Image Description

Voyage vista Tour and events

Stealthย โ€ขย 25d

This is a B2B offer for individuals to earn part-time while helping students explore new fields such as aviation engineering and safety engineering. We have tie-ups with several institutions specializing in these fields. If a student enrolls, we wil

See More
1 replies4 likes
Image Description
Image Description

TechTrendsTodaY

Stealthย โ€ขย 9m

Every sunrise, Iโ€™m out in the fields, ready to tend to the land that feeds us. But itโ€™s a punch in the gut when I see my crops suffering. These silent thieves are stripping away what weโ€™ve painstakingly grown. This isnโ€™t just my struggle, itโ€™s a stru

See More
5 replies9 likes
Image Description
Image Description

Hiral Jain

Stealthย โ€ขย 7m

Hey there everyone! Day 1 of uncovering businesses that continue to operate even after being deemed illegal! The most illegal and common business is HAWALA its used by many big businesses(money laundering) and terrorist groups( to fund their groups

See More
19 replies17 likes

Muttu Havalagi

Stealthย โ€ขย 5m

1. PHP: - History: PHP was created by Rasmus Lerdorf in 1994. Originally, PHP stood for "Personal Home Page," but it now stands for "PHP: Hypertext Preprocessor." - Unique Fact: PHP was originally developed as a set of Common Gateway Interface

See More
0 replies1 like
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

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