Zero-copy in Go: sendfile, splice, and the cost of io.Copy

(segflow.github.io)

47 points | by mrngm 3 hours ago

5 comments

  • sanxiyn 1 hour ago
    A good reminder. It is surprising first time you encounter it.

    Same for Rust. As https://doc.rust-lang.org/stable/std/io/fn.copy.html says, std::io::copy can use copy_file_range(2), sendfile(2), or splice(2).

  • inigyou 13 minutes ago
    This is almost like the expression problem. Copy is a new operation, and you introduced a new type, thus creating a new grid cell nobody from either side could have reasonably known about - except for the fact Copy is in the standard library so you could have known about it but not done anything.
  • mike_hock 1 hour ago
    Zero-Copy in Go: Why magic is an antipattern, and: performance is observable behavior.
    • sanxiyn 1 hour ago
      What would you prefer?

      I do think it is criminal this is not documented (https://pkg.go.dev/io#Copy), but I think io.Copy is fine as an API.

      • arccy 13 minutes ago
        it is documented by saying it calls ReadFrom or WriteTo
  • throwrioawfo 1 hour ago
    Ugh, AI slop writing.
  • joaohaas 36 minutes ago
    Interesting premise for a post, but I had to stop midway due to the AI slop writing adding meaningless information.