On Sun, 25 Nov 2018 at 19:17, <lary...@gmail.com> wrote: > These are great tips! Thank you! > This is the context for the code above > https://github.com/larytet/binlog/blob/master/binlog.go#L548 >
I took a look at this code. It seems that you have a deep understanding of how the runtime works, but to me it really seems like you're prematurely optimising here, and running serious risk of broken code. The code is full of unsafe and non-portable operations that will almost certainly break in the future. For example, reading /proc to determine the base offset for static strings is... inadvisable. Just because you know what's going on under the covers doesn't mean that you should write code that relies on that information. If you want to see a highly performant logging implementation that does not seriously rely on unsafe practices, I'd encourage you to take a look at the zap package (https://godoc.org/go.uber.org/zap). By the way, your SingleInt benchmark is misleading. You're using a constant argument to Log, which means that the runtime can use a single interface value for every call, with no allocation required. If you change the loop so that it passes a different number each time: for i := 0; i < b.N; i++ { binlog.Log(fmtString, i) } you are likely to find that the performance gap is considerably smaller. cheers, rog. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.