Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Lensm: Go Assembly and Source Viewer (github.com/loov)
161 points by kristianp on July 18, 2022 | hide | past | favorite | 13 comments


We just got the blog post accompanying this posted here: https://news.ycombinator.com/item?id=32138111


I like the visual style of this. I did find that on my M1 mac, I needed to clone and then run:

go build && go install


Why not `go install github.com/loov/lensm@latest`?


Thanks for sharing; this is lovely. I once tried to dig into compiled Go code using Compiler Explorer[0] when I was reading about Go range expressions[1]. I found it tough to keep track of the colors. The hover feature was neat but the "branching" in this tool will help me.

But the major reason I had difficulty understanding is I don't know Assembly except some basic operations. Are there any resources to learn Assembly, at least to a level that I understand output like this: https://go.godbolt.org/z/P4jW1bG6z ?

  0: https://go.godbolt.org/
  1: https://abhijithota.me/go-range/


A recent YC article mentioned this [site] (https://github.com/hackclub/some-assembly-required/)


Note that Go uses its own, largely platform-independent, assembler syntax.

https://go.dev/doc/asm

https://talks.golang.org/2016/asm.slide

https://www.youtube.com/watch?v=KINIAgRpkDA


There is also GOSSAFUNC, which is built into the Go compiler, and has a web explorer. See this example: https://golang.design/gossa?id=16f6eee9-065d-11ed-adb4-0242a...

I used a lot of their HTML and CSS when building https://trycinder.com/


Pardon me for being layman on this topic.

How/What is this used for?

I've used a similar tool for Shaders and it was very useful for understanding where the GPU spends time. However, do we need that level of details for CPU based applications.


Anyone writing code where perfomance matters, surely needs them, they are even willing to pay for such tools down to micro-ops. e.g. Intel VTune.


If you can understand it's useful for understanding how the GPU spends its time, why wouldn't that same understanding be useful for the CPU? Or anything else? Doing optimizations requires good tooling, no matter what it runs on.


My doubt is, what kind of application needs this level of optimisation on CPU based application?

Shaders are very bad at certain things like conditional statements. So we usually do that level of analysis to avoid. And the application is for Games or graphics heavy applications. In the same manner, what kind of application goes through this level of details?


In my own experience, tools like this are most useful when I write something and it's unexpectedly fast/slow and I don't understand why without diving deeper. Especially when it comes to unexpected slowdowns (expected something to take 1x time but it takes 100x time instead).

Being able to inspect the generated assembly usually reveals the cause, and this tool improves being able to jump to the right place, as there tends to be a lot of assembly generated even for small snippets of code, so finding the right place can take some time.


I guess it works as long as optimizations are disabled? Because any mildly optimized code shouldn't match it@s input as linearily as shown on the pictures.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: