Bloaty: A super handy linux binary analysis
Yi Zhang Blog
by Yi Zhang
3y ago
bloaty is a great tool from Google for binary size analysis. We were just wondering why the binary size became so large for our code in production and bloaty is great at that. For example, if you run it against a release build of bloaty itself, just for fun: ./bloaty -d sections ./bloaty FILE SIZE VM SIZE -------------- -------------- 35.8% 16.2Mi 0.0% 0 .debug_info 25.3% 11.4Mi 0.0% 0 .debug_loc 11.6% 5.26Mi 0.0% 0 .debug_str 6.5% 2.93Mi 0.0% 0 .debug_ranges 6.3% 2.83Mi 42.5% 2.83Mi .rodata 5.7% 2.60Mi 0.0 ..read more
Visit website
Std::atomic vs volatile, disassembled
Yi Zhang Blog
by Yi Zhang
3y ago
This came up during a code review and the code was using volatile to ensure the access to the pointer variable is atomic and serialized, and we were sort of debating whether it is sufficient, in particular: Is it safer to switch to std::atomic<T>, and if so, why? Is volatile sufficiently safe for a strong memory model CPU like x86? Most of us can probably agree that std::atomic<T> would be safer, but we need to dig a bit deeper to see why is it safer, and even for x86. What is the difference? std::atomic provides atomic access to variables and provides different memory model acce ..read more
Visit website
Paper Reading: In Search of an Understandable Consensus Algorithm (Extended Version)
Yi Zhang Blog
by Yi Zhang
3y ago
This paper is the paper to read about Raft consensus algorithm and a good way to build intuition for consensus algorithms in general. The “consensus” about consensus algorithms is that they are hard to understand / build / test, and not surprisingly having an understandable consensus algorithm has a lot of value for system builders. I think Raft is designed for today’s mainstream single leader multi-follower log-replicated state machine model so it is a great starting point for building a practical distributed system around it. I’ve read about raft before but this is the first time I went thro ..read more
Visit website
Writing your own NES emulator Part 3 - the 6502 CPU
Yi Zhang Blog
by Yi Zhang
3y ago
It’s been a while since the last update - I was mostly focusing on database technologies. Beginning of the year 2021 is a bit slow (that’s when many big companies start their annual / semi-annual review process), so I had a bit of time to write this up. All the code referenced in this post is in my simple NES emulator github repo NesChan. It’s fun to go back and look at my old code and the 6502 CPU wiki. The 6502 CPU NES uses 8-bit 6502 CPU with 16-bit address bus, meaning it can access memory range 0x0000~0xffff - not much, but more than enough for games back in the 80s with charming dots and ..read more
Visit website
Doctest - my favorite lightweight, zero-friction unit test framework
Yi Zhang Blog
by Yi Zhang
3y ago
In my personal C++ projects I’ve always been using doctest. It’s simply awesome. It takes a few seconds to get bootstrapped and you are ready to run your tests. And it should really be the first thing you do when you start a new project. For example, I’ve been using it in neschan which is a NES emulator that I wrote for fun last year, and one such example is a few unit test that validates the emulated 6502 CPU works correctly: cpu_test.cpp TEST_CASE("CPU tests") { nes_system system; SUBCASE("simple") { INIT_TRACE("neschan.instrtest.simple.log"); cout << "Running [CPU][simple]..." < ..read more
Visit website
Putting Fedora 33 Workstation on X1 Carbon 7th gen
Yi Zhang Blog
by Yi Zhang
3y ago
I’ve had a Lenovo X1 Carbon 7th gen for a while and tried putting Ubuntu 20.04 on it, but had quite a bit of trouble. Mostly the problem was this model has 4 speakers (two front and two bottom) so linux had quite a bit of trouble with it. The sound was tinny, and volume up / down doesn’t work either. The microphone jack also pops. There are other minor issues like finger print sensor doesn’t work, though I don’t care about it much. There is a long thread discussing problems with ubuntu. I spend quite a while browsing forums and find some work arounds, but none are satisifactory. So I gave up a ..read more
Visit website
Paper Reading - Hekaton: SQL Server’s Memory-Optimized OLTP Engine
Yi Zhang Blog
by Yi Zhang
3y ago
This is a great paper covering Microsoft Hekaton storage engine. There are a lot of meaty stuff here - lock-free Bw-tree indexing, MVCC, checkpointing, query compilation. I’m especially interested in its query compilation given my background in the .NET runtime and I’ve also spent some non-trivial amount of time focusing on optimizing query performance in my current job. Bw-tree is a very interesting direction for B+ tree as well and we’ll also be looking at a few papers that covers Bw tree in more depth in future posts. Overview Hekaton is an alternative SQL server storage engine optimized fo ..read more
Visit website
InnoDB Internals - Consistent Reads
Yi Zhang Blog
by Yi Zhang
3y ago
Overview I’ve been doing some research in this area trying to understand how this works in databases (for my upcoming project), so I thought I’d share some of my learnings here. InnoDB internally uses ReadView to establish snapshots for consistent reads - basically giving you the point-in-time view of the database at the time when the snapshot it is created. In InnoDB, all changes are immediately made on the latest version of Database regardless whether it has been committed or not, so if you don’t have MVCC, everybody will see the latest version of rows and it’ll be a disaster for consistency ..read more
Visit website
Trying and setting up WSL 2
Yi Zhang Blog
by Yi Zhang
3y ago
The year of Linux desktop has finally come. It’s Windows + WSL 2. Seriously. I use a MBP 16 for my daily work and SSH into linux machines for development/testing. While it’s a fantastic machine (and the track pad is second to none), I just hate the Apple trying to lock down the system so much that even setting up gdb to work is a nightmare, and running any simple script it tries to phone home for validation. So I tried installing Linux on my machines. I do have a personal laptop X1 Carbon Gen7, but it doesn’t work well with Linux: mostly Linux just doesn’t like the 4 Channel Dolby Surround Spe ..read more
Visit website
SWIG and Python3 unicode
Yi Zhang Blog
by Yi Zhang
3y ago
Anyone familiar with Python probably knew its history of Unicode support. If you add Python3, Unicode, and SWIG together, imagine what might go wrong? Python3, Unicode, SWIG, and me I was debugging a test failure written in Python just now and it is failing with this error: Many of the end-to-end tests here are written in Python because they are convenient - no one wants to write a C++ code to drive MySql and our infra service to do a series of stuff. UnicodeEncodeError: 'latin-1' codec can't encode character '\udcfa' in position 293: ordinal not in range(256) The code looks like this ..read more
Visit website

Follow Yi Zhang Blog on FeedSpot

Continue with Google
Continue with Apple
OR