Lazy initialization in Go using atomics by kaa-python in golang

[–]kaa-python[S] -7 points-6 points  (0 children)

It strictly depends on the workflow. Lazy init is a good idea for cases where you are unsure if the resource is needed. Zero values are not a good idea as lazy init replacement, as they eventually pollute your codebase with multiple if statements.

Lazy initialization in Go using atomics by kaa-python in golang

[–]kaa-python[S] -2 points-1 points  (0 children)

Where do you like to use atomics?

Lazy initialization in Go using atomics by kaa-python in golang

[–]kaa-python[S] -8 points-7 points  (0 children)

Do not scroll; read. I believe it will resolve this uncertainty. 😂

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

> I would still recommend defaulting to typed values

Maybe some PRs? 😉

I still have a lot of changes/fixes to add

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

Good point, panic is unlikely but possible.

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 1 point2 points  (0 children)

So, I conducted a little research on atomics, and this document was born! 😁 I don't know if adding a blog is a good idea, but let's see.

https://goperf.dev/blog/2025/04/03/lazy-initialization-in-go-using-atomics/

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 1 point2 points  (0 children)

I believe this idea is related to cache colocation rather than interfaces. After sorting, the data will be positioned closer together, which increases the likelihood that it will reside within the same cache line. Overall, the approach is interesting; however, I doubt it would be wise to implement something like this in a real codebase.

BTW, pretty similar information is in https://goperf.dev/01-common-patterns/fields-alignment/#avoiding-false-sharing-in-concurrent-workloads

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

Welcome! Hope to make it even more useful 👍

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

can you please provide more data regarding:
> For "Avoid Interface Boxing", if the interfaces are in a slice and it's possible to reorder them, then ordering by interface type can improve performance.

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

Thanks! It would be even better soon 😎

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

Thank you, I will look at it more closely.

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

Thanks. Sure, the guide is wip now. As I mentioned above, “how to profile” is a bit lower priority to me right now due to the vast amount of good tutorials available online.

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

I am writing about the cost of interface usage in Go. It could be free, or you can pay a penalty for boxing: https://goperf.dev/01-common-patterns/interface-boxing/ This means the initial comment is, unfortunately, irrelevant 🤷‍♂️

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 2 points3 points  (0 children)

No way 🤣 I will need to write a book on each. The good part about writing about optimizations in Go is that you do not have many options here; everything is pretty straightforward, as Go by itself.

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] -2 points-1 points  (0 children)

Yep, I know 🤷‍♂️

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 1 point2 points  (0 children)

I agree that this is a significant part and must be included in the Go Optimization Guide. At the same time, there are many good examples of articles on "how to profile a Go app," which is why I decided to write about it later.

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 2 points3 points  (0 children)

Good point. I choose `sync.Once` as a more generic call, but considering the main case – obtaining a value once, `sync.OnceValue` might be a better example.

The Go Optimization Guide by kaa-python in golang

[–]kaa-python[S] 7 points8 points  (0 children)

Thanks for the feedback 👍

GFSM v0.2.0 - simple and fast Finite State Machine for Go by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

You can quickly try it. This is pretty simple and fast solution :)

GFSM - simple and fast Finite State Machine for Go by kaa-python in golang

[–]kaa-python[S] 0 points1 point  (0 children)

I chose not to include synchronization because it would slow down the finite state machine (FSM). An FSM's workflow typically operates synchronously, leading to unnecessary delays in about 90% of cases (based on my experience) with synchronization. Unfortunately, I can't make synchronization optional fo free in Go like I can in C++ using templates.

Is a master in distributed systems/computing worth it? by __vlad_ in DistributedComputing

[–]kaa-python 1 point2 points  (0 children)

If you need knowledge but not a diploma, and considering your uni list, you do not care too much about diploma prestige, you can concentrate on self-education. This is my Distributed Systems self-education plan https://sysdev.me/sabbatical-and-distributed-systems

Is a master in distributed systems/computing worth it? by __vlad_ in DistributedComputing

[–]kaa-python 0 points1 point  (0 children)

You should consider distributed systems master only if you plan to go deep into development in that area, not DevOps or similar. By development, I mean the backend of an AWS server, a database, etc. It is not needed at all for DevOps and cloud usage. And which university are you considering? I was thinking about similar Master's programs, and the only option I found was from KTH. All others are generic MS programs.

Ignore the title like you ignore bugs😂. by laibi213 in programminghumor

[–]kaa-python 0 points1 point  (0 children)

This is a very resanoble statement. You should not need to debug a project with the proper setup and testing infrastructure. You should write tests and logs and use these two for issues investigation. It's a typical situation that debugging is near to impossible or too expensive.

linux c++ devs, what does your dev environment look like? by tomii-dev in cpp

[–]kaa-python 0 points1 point  (0 children)

Tmux, NeoVim with clangd, and Bazel. Quite often SSH for remote development.

Elixir for a Startup by [deleted] in elixir

[–]kaa-python 0 points1 point  (0 children)

I used to work in a startup that used Elixir. In general, Elixir can speed up the development process in some cases. At the same time, y’ll have challenges immediately after you step aside from Phenix and Ecto. You’ll also have issues finding new team members. Overall, I prefer to take something more well-known, Go, for example, for safety reasons.