Day 28: Response Headers in Go
😎 Mood: Ready for a 3 day weekend
📚 Reading Github Issues
Back to my normally scheduled sabbatical plans. I got a little lazy though and only read the most recent 25 issues. None of them stuck out.
📌 Contribution Updates
Yesterday another contribution of mine was merged!
📬 Response Headers in Go
Today I opened up a new issue related to the bug I was investigating two days
ago. Before go 1.16 the reverse proxy would always use Content-Length
when sending small responses. After go 1.16 the reverse proxy will keep the
Transfer-Encoding: chunked
header if that is what the backend sent. This
broke some clients that don’t support Transfer-Encoding: chunked
. (Yes. I
know. I read the RFC for HTTP/1.1. All clients must support Transfer-Encoding:
chunked
.)
Nothing in the release notes was obviously the cause of this change, so I wrote a little script and used git bisect to figure out the commit that caused this. In the end, we determined that it is not a bug for go, but that it would be nice to document this change in the release notes. So I opened this issue.
🎥 Back to “Assembly Language & Computer Architecture”
I returned for the 3rd (and final) time to this MIT lecture on “Assembly Language & Computer Architecture”.
Today I learned about:
- how 5 stage processors work
- Instruction Fetch (IF), Instruction Decode (ID), Execute (EX), Memory (MA), Write Back (WB)
- how 5 stage processors are nothing but white lies
- instruction-level parallelism (ILP)
- dependency hazards
- structural - when 2 instructions attempt to use the same functional unit at the same time
- data - when an instruction depends on the result of a prior instruction in the pipeline
- control - when the processor can’t be sure of what comes next because of conditional jumps, etc
- “How do you free yourself from the tyranny of one instruction after the other???”
- 🤯 Then there was a 10 second overview of using graphs to determine when there is a false/true dependence to speed things up.
🧩 Assembly in Go
Back to playing around with Go’s assembly!
First I re-did my “odd” function using bitwise math like my internet friend suggested.
💻 oddWithBitwiseAnd takes an integer input and prints if it is even or odd. This function uses bitwise math and is O(1) unlike my last odd function which was O(n).
TEXT ·oddWithBitwiseAnd(SB),NOSPLIT,$0
MOVQ val+0(FP), BX
ANDQ $1, BX
JZ PRINT_EVEN // check the zero flag set by the bitwise AND
PRINT_ODD:
CALL ·printOdd(SB)
JMP END
PRINT_EVEN:
CALL ·printEven(SB)
END:
RET
Then I tried to do a handful of things that failed. Including:
- Using arrays
- Using strings
- Waiting for user input
- Making syscalls
The frustrating thing about writing in Go’s assembly is that there are nearly no docs on it and very few examples. Most of the older examples don’t work for reasons I don’t understand. The examples in the std library don’t work when I copy them into my code because the std library is able to do different things. It has been annoying to try to learn about how to do things in a different assembly language using great resources and then try to piece together how to translate that into Go’s assembly.
I really want to make a little game in assembly! So I think when I get back Monday (thanks for another 3 day weekend for no reason vmware) I am going to start back using only x86-64 since I like this book so much.
😎 Heading out an hour early to make up for some of the time I spent being paged this week.