53 Matching Annotations
  1. Nov 2023
    1. // & takes the address of an object.

      so what happens here ? are all variables not maintained in call stack, so that they can be maintained even when the call stack is popped. does the compiler/garbage cleaner clean up other variables, but not these, as it detects that these variables are still in use that's kinda cool, but also unnecessarily putting pressure on the compiler

    2. // +build prod, dev, test
  2. Jul 2023
    1. Containerization solves these proble

      integration test with containerization looks like exactly what I need

    1. lets you to control the sampling rate of the CPU profiler

      better to use Go1.18 versions to avoid these limitations

    2. The example above is highly simplified and omits many details around return values, frame pointers, return addresses and function inlining. In fact, as of Go 1.17, the program above may not even need any space on the stack as the small amount of data can be managed using CPU registers by the compiler

      interesting so if data is small, it is managed by the cpu registers by the compiler, stack is not used

    1. recommend disabling optimizations when building the code being debugged

      debugging should be done with compiler optimizations disabled

    2. Go users can create their custom profiles via pprof.Profile and use the existing tools

      do we have any custom implementations of these profiles available publicly

    1. I want a tiny binary, for a monitoring/logging agent, or a systems tool like docker agent, or kubectl, fantastic, Go (or Rust) is the best language to go for. I want to make REST APIs, and some DB calls - no worse choices than Go to do that. Even Python and Node are far better

      would like to know more on why Go isn't suited for webservers

  3. Oct 2022
    1. 在新版本(起码 1.15 及以后)的 Go 当中,sync.Pool 里的临时对象需要两次 GC 才会被真正清除掉。 // 只一次 GC 的话只会让其中的临时对象被“打上记号”。 // 更具体的说,只做一次 GC 只会使得 sync.Pool 里的临时对象被移动到池中的“备用区域”(详见 victim 字段)。 // 在我们调用 sync.Pool 的 Get 方法时,如果 sync.Pool 的“本地区域”(详见 local 字段)当中没有可用的临时对象, // 那么 sync.Pool 会试图从这个“备用区域”中获取临时对象。 // 如果“备用区域”也没有可用的临时对象,sync.Pool 才会去调用 New 函数。 // 所以,这里的例子需要再添加一行对 runtime.GC() 函数的调用,才能使它的结果与最初的相同,并起到准确示范的作用。

      runtime.GC()

  4. Aug 2022
  5. Jul 2022
  6. May 2022
  7. Apr 2022
    1. 如果直接使用 DllCall 会报错,那么使用 DllLoad 先将 dll 文件加载有时就可以解决问题

      猜测难道是 golang 编译的 dll 文件太大(2-3Mb)导致DllCall 会直接导致 ahk 程序退出?

  8. Mar 2022
  9. Nov 2021
  10. Oct 2021
    1. It’s important to understand that even though a slice contains a pointer, it is itself a value. Under the covers, it is a struct value holding a pointer and a length. It is not a pointer to a struct.

      slice 是一个包含指针的结构体,他是一个具体值而不是指针

    1. 那为什么在上面的场景中,atomic会比mutex性能好很多呢?作者 Dmitry Vyukov 总结了这两者的一个区别: Mutexes do no scale. Atomic loads do. Mutex由操作系统实现,而atomic包中的原子操作则由底层硬件直接提供支持。在 CPU 实现的指令集里,有一些指令被封装进了atomic包,这些指令在执行的过程中是不允许中断(interrupt)的,因此原子操作可以在lock-free的情况下保证并发安全,并且它的性能也能做到随 CPU 个数的增多而线性扩展。

      多核场景中, atomic 性能优于 mutex 的原因

  11. Sep 2021
  12. Apr 2021
    1. Style definitions for nice terminal layouts. Built with TUIs in mind.

  13. Jan 2021
  14. Dec 2020
  15. Oct 2020
  16. Jun 2020
  17. May 2020
    1. we should never blindly apply dogmatic advice, and that we should use our judgment each and every time.

      menjadi manusia berkesedaran, memiliki pemikiran sendiri, jangan menelan mentah-mentah apa yang dibaca

  18. Apr 2020
    1. If the word “share” doesn’t come out of your mouth, you don’t need to use a pointer

      key point

    2. The benefit of passing data “by value” is readability. The value you see in the function call is what is copied and received on the other side

      no hidden cost, eg., memory growth on the heap or pauses during garbage collection. but there is a cost in stack memory usage and "scoping" among multiple stack frames, CPU caching, etc.

    3. Functions execute within the scope of frame boundaries that provide an individual memory space for each respective function. Each frame allows a function to operate within their own context and also provides flow control. A function has direct access to the memory inside its frame, through the frame pointer, but access to memory outside its frame requires indirect access. For a function to access memory outside of its frame, that memory must be shared with the function.

      eg., shared via the "pointer" to an address in heap memory

  19. Oct 2019
    1. The log will become something of a commoditized interface, with many algorithms and implementations competing to provide the best guarantees and optimal performance.

      Are golang channels an implementation of log?

  20. Aug 2019
  21. May 2019
    1. Go Programming Language publicly in 2009 they were also looking to solve certain challenges of the existing Computer languages. Of the many features that it demonstrated (we will get to those soon enough) it was also helpful in addressing the strange dilemma of hardware and software that was emerging.

      Golang is a modern computing language, designed especially for modern computing needs.

  22. Mar 2019
  23. Jan 2018
  24. Sep 2017
  25. Jul 2017
    1. (It's usually a mistake to pass back the concrete type of an error rather than error, for reasons discussed in the Go FAQ, but it's the right thing to do here because ServeHTTP is the only place that sees the value and uses its contents.)

      Good clarifying comment on when to pass back the concrete type of an error.

  26. Jan 2017
  27. Jul 2016
    1. There are two reasons for having no warnings. First, if it's worth complaining about, it's worth fixing in the code.
  28. Aug 2015