GitHub Copilot

I have been using GitHub Copilot for several days. I didn’t expect it to work well, before trying it out, I was very opposed to this kind of machine-learning based code generation tools. However, GitHub Copilot really gave me a pleasant surprise this time. It did much better than I had thought it could. Often times it would guess my intentions correct, and produce code that is of passing quality. And it makes coding more fun, having an AI companion is cool, it’s like a buddy you can discuss with, on how to best write pieces of code (I guess the AI buddy is a manifestation of the collective intelligence of millions of developers who use GitHub, so sometimes it can produce good code and even teach me something)....

June 28, 2022 · Ke Wang

Protobuf is so much faster than JSON

At work, I have a program that needs to load an external JSON file that is 1.4GB in size, it takes about 45 seconds for it to load and json.Unmarshal. I took that 45 second start-up time for granted. Today, I thought, what if I convert that data to protobuf? Will it speed up the start-up time? (P.S. there’s a very good benchmark of different go serialization here: https://github.com/alecthomas/go_serialization_benchmarks) So I did the switch....

June 28, 2022 · Ke Wang

Clash enhanced mode

Clash works very well for programs that support socks5 proxy. It’s becoming an indispensable part of my life (without it, I can’t even use Google or access GitHub, or install any dependency for projects I work on). However, not all programs understand / support socks5 proxy. I used to solve this problem with: Proxifier proxychains-ng The problem with Proxifier is that it is a paid app, the price isn’t really the issue, the real issue is that it doesn’t work with M1 Macs....

June 19, 2022 · Ke Wang

Kubernetes APIServer Adaptive Concurrency Limit

Kubernetes controllers use informers to connect to APIServers, it has a famous LIST-WATCH mechanism in it. The problem with this is, when an APIServer crashes / restarts, all controllers connected to the APIServer will be forced to reconnect, and send the LIST request again to APIServer. LIST requests are very expensive, while WATCH requests are quite cheap. All controllers sending LIST requests to an APIServer in a short time window will make sure that APIServer is overwhelmed again, and never succeed in starting up....

April 20, 2022 · Ke Wang

Killing a Goroutine

Is it possible to kill a goroutine just like you could use Thread.Abort to kill a thread in Java? I opened this issue: https://github.com/golang/go/issues/50678 The conclusion is that, if we patch Golang’s src/runtime, it is possible. But in doing so, we may break some of Golang’s invariants, and make introduce bugs that are very difficult to troubleshoot. So, be very careful! I will share in this blog, how I hacked Golang to support killing goroutine, how to publish the hacked Golang as a docker image (so that it will be easy to build programs with this hacked Golang), and how to make the code compatible with non-hacked Golang (so the kill method will be a no-op and just return false)....

March 5, 2022 · Ke Wang

Monkey-patching golang code

Monkey patching Golang code with https://github.com/bouk/monkey or go.mod replace directive. (to be continued)

December 1, 2021 · Ke Wang

Kubernetes Shell Scripting

We sometimes need to do large-scale Kubernetes ops. Shell script is a great way to automate this. I think the combination of kubectl + shell / nodejs is hugely underrated. I decided to write a blog to share my best practices. (to be continued)

November 2, 2021 · Ke Wang

A good way to show modals in React

Is it only me who think that the Modal APIs provided by popular frameworks such as antd (https://ant.design/components/modal/) are awkward and cumbersome to use? It’s just not intuitive (like confirm() or prompt('input a number')), and how do you show multiple instances of a same type of modal? I have a trick to display modals in an imperative way. import React, { useState } from 'react'; import ReactDOM from 'react-dom'; import { Button, Modal } from 'antd'; /* class Modal extends React....

October 2, 2021 · Ke Wang

Using JavaScript to process data

I used to ask a fellow developer, what would you do if you had some data represented in a JSON array, and you’d like to do some very quick and simple processing, to find out the information you are interested in? He said he’d write a Golang program to do that. While there’s nothing wrong with that approach, I think this method is too slow. It will take you at least 10 minutes to write and test a Golang program, especially considering you will need to define all the structs before you can parse the JSON data....

September 30, 2021 · Ke Wang

Visualizing hierarchical data

At work, my team managed 10,000+ machines, distributed across regions, AZs, clusters. We wanted to visualize what version a certain software is running across all the machines we manage. I implemented a visualization using foamtree, however, it is a paid component, and it’s not cheap. So, when I got some free time, I decided to implement a new treebox visualization component, from scratch. https://github.com/KevinWang15/treebox (to be continued)

May 24, 2021 · Ke Wang