lade...

Dave.cheney.net

Dave.cheney.net

an avatar

Dave Cheney | The acme of foolishness

🌐 Visit Dave.cheney.net 🌐 Dave.cheney.net besuchen

✍️Write rieview ✍️Rezension schreiben 🏷️Get Badge! 🏷️Abzeichen holen! ⚙️Edit entry ⚙️Eintrag bearbeiten 📰News 📰Neuigkeiten

Webfan Website Badge

Tags:

Rieviews

Bewertungen

not yet rated noch nicht bewertet 0%

Be the first one
and write a rieview
about dave.cheney.net.
Sein Sie der erste
und schreiben Sie eine Rezension
über dave.cheney.net.

Dave.cheney.net News

Microblog: TestMain can cause one to question reality

https://dave.cheney.net/2024/02/...

This morning a one line change had several of us tearing up the fabric of reality trying to understand why a failing test wasn’t failing, or, in fact, being run at all. Increasingly frantic efforts to upgrade/downgrade Go, run the tests on another machine, run the tests in CI, all served to only unnerve us […]

21.2.2024 21:04Microblog: TestMain can cause one to question reality
https://dave.cheney.net/2024/02/...

A few bytes here, a few there, pretty soon you’re talking real memory

https://dave.cheney.net/2021/01/...

Today’s post comes from a recent Go pop quiz. Consider this benchmark fragment. A convenience wrapper around sort.Sort(sort.StringSlice(s)), sort.Strings sorts the input in place, so it isn’t expected to allocate (or at least that’s what 43% of the tweeps who responded thought). However it turns out that, at least in recent versions of Go, each […]

5.1.2021 12:39A few bytes here, a few there, pretty soon you’re talking real memory
https://dave.cheney.net/2021/01/...

The story of the one line fix

https://dave.cheney.net/2020/12/...

Picture yourself, an engineer working at the hottest distributed microservices de jour, assigned to fix a bug. You jump into an unfamiliar codebase and quickly locate the line where the problem occurred. The fix is simple, just return early or substitute a default value in the case that one cannot be determined from your input. […]

15.12.2020 04:45The story of the one line fix
https://dave.cheney.net/2020/12/...

How to dump the GOSSAFUNC graph for a method

https://dave.cheney.net/2020/06/...

The Go compiler’s SSA backend contains a facility to produce HTML debugging output of the compilation phases. This post covers how to print the SSA output for function and methods. Let’s start with a sample program which contains a function, a value method, and a pointer method: Control of the SSA debugging output is via […]

19.6.2020 03:36How to dump the GOSSAFUNC graph for a method
https://dave.cheney.net/2020/06/...

Diamond interface composition in Go 1.14

https://dave.cheney.net/2020/05/...

Per the overlapping interfaces proposal, Go 1.14 now permits embedding of interfaces with overlapping method sets. This is a brief post explain what this change means: Let’s start with the definition of the three key interfaces from the io package; io.Reader, io.Writer, and io.Closer: Just as embedding a type inside a struct allows the embedded type’s […]

24.5.2020 08:49Diamond interface composition in Go 1.14
https://dave.cheney.net/2020/05/...

Fatih’s question

https://dave.cheney.net/2020/05/...

A few days ago Fatih posted this question on twitter. I’m going to attempt to give my answer, however to do that I need to apply some simplifications as my previous attempts to answer it involved a lot of phrases like a pointer to a pointer, and other unhelpful waffling. Hopefully my simplified answer can […]

16.5.2020 11:31Fatih’s question
https://dave.cheney.net/2020/05/...

Ensmallening Go binaries by prohibiting comparisons

https://dave.cheney.net/2020/05/...

Conventional wisdom dictates that the larger the number of types declared in a Go program, the larger the resulting binary. Intuitively this makes sense, after all, what’s the point in defining a bunch of types if you’re not going to write code that operates on them. However, part of the job of a linker is […]

9.5.2020 10:23Ensmallening Go binaries by prohibiting comparisons
https://dave.cheney.net/2020/05/...

Mid-stack inlining in Go

https://dave.cheney.net/2020/05/...

In the previous post I discussed how leaf inlining allows the Go compiler to reduce the overhead of function calls and extend optimisation opportunities across function boundaries. In this post I’ll discuss the limits of inlining and leaf vs mid-stack inlining. The limits of inlining Inlining a function into its caller removes the call’s overhead […]

2.5.2020 05:09Mid-stack inlining in Go
https://dave.cheney.net/2020/05/...

Inlining optimisations in Go

https://dave.cheney.net/2020/04/...

This is a post about how the Go compiler implements inlining and how this optimisation affects your Go code. n.b. This article focuses on gc, the de facto Go compiler from golang.org. The concepts discussed apply broadly to other Go compilers like gccgo and tinygo but may differ in implementation and efficacy. What is inlining? […]

25.4.2020 06:38Inlining optimisations in Go
https://dave.cheney.net/2020/04/...

go test -v streaming output

https://dave.cheney.net/2020/03/...

The testing package is one of my favourite packages in the Go standard library, not just because of its low noise approach to unit testing, but, over the lifetime of Go, it has received a steady stream of quality of life improvements driven by real world usage. The most recent example of this is, in […]

10.3.2020 07:03go test -v streaming output
https://dave.cheney.net/2020/03/...

Are large slices more expensive than smaller ones?

https://dave.cheney.net/2020/03/...

Programmers have a tendency to be superstitious. Particularly, when a programmer hears that copies are expensive, they start to see them everywhere, especially when they learn that, in Go, every assignment is a copy. Consider this code; x is three orders of magnitude larger than y, is the assignment of x to a more expensive […]

1.3.2020 05:35Are large slices more expensive than smaller ones?
https://dave.cheney.net/2020/03/...

The Zen of Go

https://dave.cheney.net/2020/02/...

This article was derived from my GopherCon Israel 2020 presentation. It’s also quite long. If you’d prefer a shorter version, head over to the-zen-of-go.netlify.com. A recording of the presentation is available on YouTube. How should I write good code? Something that I’ve been thinking about a lot recently, when reflecting on the body of my […]

23.2.2020 06:46The Zen of Go
https://dave.cheney.net/2020/02/...

Dynamically scoped variables in Go

https://dave.cheney.net/2019/12/...

This is a thought experiment in API design. It starts with the classic Go unit testing idiom: func TestOpenFile(t *testing.T) { f, err := os.Open("notfound") if err != nil { t.Fatal(err) } // ... } What’s the problem with this code? The assertion. if err != nil { ... } is repetitive and in the […]

8.12.2019 01:36Dynamically scoped variables in Go
https://dave.cheney.net/2019/12/...

Internets of Interest #15: The Queen of the Skies

https://dave.cheney.net/2019/12/...

If, like me, you’re a commercial aviation otaku, this walkthrough of an enthusiast built 747 cockpit simulator should be highly relevant to your interests.

5.12.2019 06:49Internets of Interest #15: The Queen of the Skies
https://dave.cheney.net/2019/12/...

Complementary engineering indicators

https://dave.cheney.net/2019/12/...

Last year I had the opportunity to watch Cat Swetel’s presentation The Development Metrics You Should Use (but Don’t). The information that could be gleaned from just tracking the start and finish date of work items was eye opening. If you’re using an issue tracker this information is probably already (perhaps with some light data […]

4.12.2019 09:46Complementary engineering indicators
https://dave.cheney.net/2019/12/...

Internets of interest #14: UNIX v0

https://dave.cheney.net/2019/11/...

Read more over at the Living Computer Museum’s restoration page.

17.11.2019 16:04Internets of interest #14: UNIX v0
https://dave.cheney.net/2019/11/...

Internets of interest: Warner Losh on the first ten years of UNIX

https://dave.cheney.net/2019/11/...

UNIX turns 50 this year which means 7th edition Research UNIX is that 40.

16.11.2019 11:21Internets of interest: Warner Losh on the first ten years of UNIX
https://dave.cheney.net/2019/11/...

Use internal packages to reduce your public API surface

https://dave.cheney.net/2019/10/...

In the beginning, before the go tool, before Go 1.0, the Go distribution stored the standard library in a subdirectory called pkg/ and the commands which built upon it in cmd/. This wasn’t so much a deliberate taxonomy but a by product of the original make based build system. In September 2014, the Go distribution […]

6.10.2019 04:43Use internal packages to reduce your public API surface
https://dave.cheney.net/2019/10/...

Be wary of functions which take several parameters of the same type

https://dave.cheney.net/2019/09/...

APIs should be easy to use and hard to misuse. — Josh Bloch A good example of a simple looking, but hard to use correctly, API is one which takes two or more parameters of the same type. Let’s compare two function signatures: What’s the difference between these functions? Obviously one returns the maximum of […]

24.9.2019 10:20Be wary of functions which take several parameters of the same type
https://dave.cheney.net/2019/09/...

Don’t force allocations on the callers of your API

https://dave.cheney.net/2019/09/...

This is a post about performance. Most of the time when worrying about the performance of a piece of code the overwhelming advice should be (with apologies to Brendan Gregg) don’t worry about it, yet. However there is one area where I counsel developers to think about the performance implications of a design, and that […]

5.9.2019 10:44Don’t force allocations on the callers of your API
https://dave.cheney.net/2019/09/...

Comment on Make your own Apple 1 replica by Dave Cheney

https://dave.cheney.net/2014/12/...

In reply to <a href="https://dave.cheney.net/2014/12/26/make-your-own-apple-1-replica#comment-3496">Garrett</a>. That is true, but in my case the period of the clock is defined by how quickly I can respond to the r/w request from the 6502. At the moment I can only do that around 350khz. I could use a PWM timer to generate a ~350khz clock signal, but then i'd have to move my code into an interrupt routine to trigger on the rising pulse.

4.1.2015 00:57Comment on Make your own Apple 1 replica by Dave Cheney
https://dave.cheney.net/2014/12/...

Comment on Make your own Apple 1 replica by Todd Decker

https://dave.cheney.net/2014/12/...

Very nice!

3.1.2015 20:26Comment on Make your own Apple 1 replica by Todd Decker
https://dave.cheney.net/2014/12/...

Comment on Building an atmega1284p prototype by Phillip Stevens

https://dave.cheney.net/2014/12/...

Dave, I updated the Goldilocks 1284p support to the Arduino BETA 1.5.8 IDE recently. In hindsight, It is just a matter of getting the config files right. You can find a bootloader that will work for you there. http://feilipu.me/2013/03/08/goldilocks-1284p-arduino-uno-clone/ check for the 20150101 zip file. You'll just need to adjust the F_CPU in the bootloader to what you've chosen to build. There is enough space in the 1284p to include a boot monitor, which can help debugging hardware, etc. Phillip

2.1.2015 04:35Comment on Building an atmega1284p prototype by Phillip Stevens
https://dave.cheney.net/2014/12/...

Comment on Make your own Apple 1 replica by Garrett

https://dave.cheney.net/2014/12/...

In reply to <a href="https://dave.cheney.net/2014/12/26/make-your-own-apple-1-replica#comment-3496">Garrett</a>. http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM Actually, now that I think about it, I used PWM and not timer int.

1.1.2015 14:44Comment on Make your own Apple 1 replica by Garrett
https://dave.cheney.net/2014/12/...

Comment on Make your own Apple 1 replica by Garrett

https://dave.cheney.net/2014/12/...

You can generate a stable 1mhz clock for a 6502 with Arduino without looping, using a timer. I have done just this, worked great. http://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS

1.1.2015 14:40Comment on Make your own Apple 1 replica by Garrett
https://dave.cheney.net/2014/12/...

Comment on Visualising the Go garbage collector by Dave Cheney

https://dave.cheney.net/2014/07/...

In reply to <a href="https://dave.cheney.net/2014/07/11/visualising-the-go-garbage-collector#comment-3447">Matt Proud</a>. The latter.

13.7.2014 10:53Comment on Visualising the Go garbage collector by Dave Cheney
https://dave.cheney.net/2014/07/...

Comment on Visualising the Go garbage collector by Matt Proud

https://dave.cheney.net/2014/07/...

I haven't studied the implementation closely, but would it be possible to extract object tenure or heap/span fragmentation information from the runtime, or is the reporting basically constrained to what <code>runtime.Memstats</code> and the base information the collector presently offer?

13.7.2014 10:03Comment on Visualising the Go garbage collector by Matt Proud
https://dave.cheney.net/2014/07/...

Comment on Visualising the Go garbage collector by chewxy

https://dave.cheney.net/2014/07/...

definitely useful. Beats having to insert `runtime.MemStats` everywhere and then logging it and writing a server to tail a log file. Thanks for this.

11.7.2014 15:01Comment on Visualising the Go garbage collector by chewxy
https://dave.cheney.net/2014/07/...

Comment on On declaring variables by Dave Cheney

https://dave.cheney.net/2014/05/...

In reply to <a href="https://dave.cheney.net/2014/05/24/on-declaring-variables#comment-3249">JZA</a>. <blockquote>I am a bit confused with the use of := in what situations this is preferred and which others should I use var foo. </blockquote> To summarise the post above, in a nutshell use <code>var SOMEVARIABLE SOMETYPE</code> when you want to declare <code>SOMEVARIABLE</code> as <code>SOMETYPE</code> for later us in your function. Conversely, use <code>SOMEVARIABLE := SOME EXPRESSION</code> to both declare <em>and</em> initialise <code>SOMEVARIABLE</code> to the result of <code>SOME EXPRESSION</code>.

25.5.2014 04:22Comment on On declaring variables by Dave Cheney
https://dave.cheney.net/2014/05/...

Comment on On declaring variables by JZA

https://dave.cheney.net/2014/05/...

I am a bit confused with the use of := in what situations this is preferred and which others should I use <i>var foo</i>. Also could you give a quick definition of slice and structs (or link to it?), regards.

24.5.2014 23:01Comment on On declaring variables by JZA
https://dave.cheney.net/2014/05/...

Comment on Go 1.3 linker improvements by Dave Cheney

https://dave.cheney.net/2014/05/...

In reply to <a href="https://dave.cheney.net/2014/05/22/go-1-3-linker-improvements#comment-3217">reader</a>. I'd imagine that the filesystem cache does play a part in improving the incremental build time, but as we're doing the same steps for both versions of Go, I don't think the cache is favouring one or the other. If you wanted to experiment, and are using linux, you could try inserting <code>sync && echo 3 > /proc/sys/vm/drop_caches</code> between each test.

23.5.2014 08:39Comment on Go 1.3 linker improvements by Dave Cheney
https://dave.cheney.net/2014/05/...

Comment on Go 1.3 linker improvements by reader

https://dave.cheney.net/2014/05/...

Does OS (filesystem) cache affect the time results?

22.5.2014 14:46Comment on Go 1.3 linker improvements by reader
https://dave.cheney.net/2014/05/...

Comment on Go 1.3 linker improvements by Dave Cheney

https://dave.cheney.net/2014/05/...

In reply to <a href="https://dave.cheney.net/2014/05/22/go-1-3-linker-improvements#comment-3209">JS</a>. My GOPATH is set to $HOME, so ~/pkg is the cache of compiled packages. This does not include the Go standard library itself, so the uncache test is only the code from $GOPATH/src

22.5.2014 06:02Comment on Go 1.3 linker improvements by Dave Cheney
https://dave.cheney.net/2014/05/...

Comment on Go 1.3 linker improvements by JS

https://dave.cheney.net/2014/05/...

Wow, you "benchmarked" the build times by doing a full package installation..?

22.5.2014 05:59Comment on Go 1.3 linker improvements by JS
https://dave.cheney.net/2014/05/...

Comment on Resources for new Go programmers by Getting Started with Go

https://dave.cheney.net/resource...

[…] Resources for new Go programmers […]

17.4.2014 22:25Comment on Resources for new Go programmers by Getting Started with Go
https://dave.cheney.net/resource...

Comment on Associative commentary follow up by Andrew Gerrand

https://dave.cheney.net/2014/03/...

I believe the language neutral rule also applies to Go source files, so if your copyright notice is inside a /* */ comment and includes blank lines, you'll need to put // +build comments above the copyright notice.

1.4.2014 04:15Comment on Associative commentary follow up by Andrew Gerrand
https://dave.cheney.net/2014/03/...

Comment on The empty struct by Xanana

https://dave.cheney.net/2014/03/...

In reply to <a href="https://dave.cheney.net/2014/03/25/the-empty-struct#comment-2938">Dave Cheney</a>. Thanks Dave. That clears it up

31.3.2014 18:07Comment on The empty struct by Xanana
https://dave.cheney.net/2014/03/...

Comment on Associative commentary follow up by Russ Cox

https://dave.cheney.net/2014/03/...

"Build tags must occur early in the file. Only the first few lines of the file are scanned when filtering files by build tags." is a little vague. In Go source files, the rule is that the // +build comment must occur before the package statement and must not be in the package doc comment. (Because +build comments can appear in non-Go source files as well, the equivalent language-neutral rule is that scanning stops at the last blank line before the first non-blank, non-// line in the file.)

31.3.2014 11:19Comment on Associative commentary follow up by Russ Cox
https://dave.cheney.net/2014/03/...

Comment on The empty struct by Dave Cheney

https://dave.cheney.net/2014/03/...

In reply to <a href="https://dave.cheney.net/2014/03/25/the-empty-struct#comment-2918">Xanana</a>. Yes and No. Types with different names have different methods sets even if they share the same base type. Instances of type S struct{} and type T struct will have the same value for their receiver, but then so will two instances of S.

31.3.2014 00:46Comment on The empty struct by Dave Cheney
https://dave.cheney.net/2014/03/...

Comment on The empty struct by Xanana

https://dave.cheney.net/2014/03/...

In reply to <a href="https://dave.cheney.net/2014/03/25/the-empty-struct#comment-2819">Andy Balholm</a>. This is scary for me. If I create 2 different named aliases of the empty struct, & each are the receivers of methods, does it mean that the method set of each named type are equal ? <a href="http://play.golang.org/p/3EERnxsbrl" rel="nofollow">http://play.golang.org/p/3EERnxsbrl</a>

30.3.2014 03:51Comment on The empty struct by Xanana
https://dave.cheney.net/2014/03/...
Subscribe

🔝

Datenschutzerklärung    Impressum