[{"data":1,"prerenderedAt":1014},["ShallowReactive",2],{"content:\u002Fen\u002Ffiddling\u002Fgo-os":3,"series:content_en":304},{"id":4,"title":5,"authorship":6,"body":7,"categories":271,"date":273,"description":274,"draft":275,"extension":276,"image":277,"meta":278,"navigation":280,"path":281,"permalink":282,"published":282,"readingTime":283,"recommend":282,"references":282,"seo":288,"seoDescription":289,"seoTitle":290,"sitemap":291,"stem":295,"tags":296,"type":302,"__hash__":303},"content_en\u002Fposts\u002Ffiddling\u002Fgo-os.md","A Project That Failed: Seven Not-So-Happy Days over Chinese New Year","human-only",{"type":8,"value":9,"toc":264},"minimark",[10,15,32,53,56,59,63,66,69,76,79,87,90,105,108,117,128,131,141,144,152,155,158,161,167,170,178,185,188,196,199,207,210,213,217,220,223,231,234,246,252,258,261],[11,12,14],"h3",{"id":13},"how-it-started","How it started",[16,17,18,19,26,27,31],"p",{},"On the high-speed train home for Chinese New Year, I came across this Zhihu article: ",[20,21,25],"a",{"href":22,"rel":23},"https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F265806072",[24],"nofollow","Running Go Programs on Bare Metal",". The idea was to reimplement system interfaces and take over Go programs' system calls, interrupts, and so on. I found it fascinating. The author also wrote an impressively complete x86 OS in Go, ",[20,28,30],{"href":22,"rel":29},[24],"eggos",". The Go runtime is modified underneath, invisibly to user programs, so third-party Go libraries work directly. There is even a TCP\u002FIP stack, allowing networking libraries to work too. I was fired up.",[16,33,34,35,40,41,46,47,52],{},"Looking at earlier work, I found the idea had been around for a long time. An OSDI 2018 paper discussed the benefits and costs of implementing an OS in a high-level language; the slides are ",[20,36,39],{"href":37,"rel":38},"https:\u002F\u002Fwww.usenix.org\u002Fsites\u002Fdefault\u002Ffiles\u002Fconference\u002Fprotected-files\u002Fosdi18_slides_cutler.pdf",[24],"here",". Recent implementations include ",[20,42,45],{"href":43,"rel":44},"https:\u002F\u002Fgithub.com\u002Fgopher-os\u002Fgopher-os",[24],"gopher-os",", a proof-of-concept kernel intended simply to show that writing an OS in Go is feasible. MIT's PhD project ",[20,48,51],{"href":49,"rel":50},"https:\u002F\u002Fgithub.com\u002Fmit-pdos\u002Fbiscuit",[24],"Biscuit"," takes the approach of hacking the compiler to target bare metal. It is more complete, implements some POSIX interfaces, and can even run Redis and nginx.",[16,54,55],{},"I noticed a common feature: all targeted x86. I had previously written a small C kernel for RISC-V, whose assembly and mechanisms are simple and pleasant to work with. That gave me an idea: write a RISC-V operating system in Go.",[16,57,58],{},"No time like the present! I started the day after getting home.",[11,60,62],{"id":61},"lets-do-this","Let's do this!",[16,64,65],{},"An important part of any project is naming it. Kidding. Mostly.",[16,67,68],{},"But I really did think of a brilliant name first: goose.",[16,70,71],{},[72,73],"img",{"alt":74,"src":75},"README","https:\u002F\u002Fblog-img.774352199.xyz\u002F2025\u002F736f6c389e54c1327775f1aa95dad597.png",[16,77,78],{},"Genius, folks!",[16,80,81,82,86],{},"Go natively supports cross-compilation to 64-bit RISC-V executables, which is good news. Just prefix go build with ",[83,84,85],"code",{"code":85},"GOOS=linux GOARCH=riscv64",". Very convenient.",[16,88,89],{},"As usual, I used QEMU and its virt platform. In virt's memory layout, addresses above 0x80000000 are physical RAM, while those below are MMIO: device memory is mapped there, so accessing it operates the device. virt sets the PC to 0x80000000 on startup.",[16,91,92,93,96,97,100,101,104],{},"Normally compiled Go executables run at user-space virtual addresses, with low entry addresses around 0x10000. Fortunately, Go provides the linker flag ",[83,94,95],{"code":95},"-T"," to specify the TEXT segment's starting address, allowing all code to be placed high in memory. ",[83,98,99],{"code":99},"-E"," selects the entry symbol, so I could write a function to take over Go's startup process. A Go program's entry is not main but ",[83,102,103],{"code":103},"_entry",", which performs initialization.",[16,106,107],{},"One serious problem remained: specifying the entry function does not specify its address. I could not place it at 0x80000000, so virt might start executing who-knows-what there. In C, a linker script solves this trivially: one line sets the entry symbol's address. But this is Go.",[16,109,110,111,116],{},"Research led me to ",[20,112,115],{"href":113,"rel":114},"https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F69111979\u002Fusing-custom-linker-script-with-go-build",[24],"this Stack Overflow question",", suggesting an external linker instead of Go's built-in linker to allow a custom script. I tried it, but it was impractical. Besides the familiar text, bss, rodata, and data sections, Go executables contain all sorts of special sections that must be explicitly listed in the linker script. Nearly impossible.",[16,118,119,120,123,124,127],{},"So I changed approach: write a C entry routine that dynamically finds the Go entry point and jumps to it. That address exists in the ELF file, not in the loaded memory image. I could therefore link the entire ELF as binary data into the C program's data segment, naming its beginning and end ",[83,121,122],{"code":122},"_binary_kernel_elf_start"," and ",[83,125,126],{"code":126},"_binary_kernel_elf_end"," for easy access. The C code parses the embedded ELF, copies its loadable segments to their target memory addresses, and jumps to the entry point from the ELF header.",[16,129,130],{},"Here is the entry assembly. It sets up the stack, calls a C function, and embeds the compiled Go executable between two symbols in the data segment:",[132,133,139],"pre",{"className":134,"code":136,"language":137,"meta":138},[135],"language-asm","    .section .text.entry\n    .globl _start\n    # 仅仅是设置了 sp 就跳转到 main\n_start:\n    la sp, bootstacktop\n    call bootmain\n\n# 启动线程的内核栈 bootstack 放置在 bss 段的 stack 标记处\n    .section .bss.stack\n    .align 12\n    .global bootstack\nbootstack:\n    # 以下 16K 字节的空间作为 OS 的启动栈\n    .space 0x4000\n    .global bootstacktop\nbootstacktop:\n\n    .section .data\n    .globl _binary_kernel_elf_start\n    .globl _binary_kernel_elf_end\n_binary_kernel_elf_start:\n    .incbin \"kernel.elf\"\n_binary_kernel_elf_end:\n","asm","",[83,140,136],{"__ignoreMap":138},[16,142,143],{},"The C function bootmain is simple too: parse the ELF, read its program header table, and load each segment at the required physical address:",[132,145,150],{"className":146,"code":148,"language":149,"meta":138},[147],"language-c","void\nbootmain()\n{\n    struct elfhdr *elf;\n    struct proghdr *ph, *eph;\n    void (*entry)(void);\n    uchar *pa;\n \n    elf = (struct elfhdr *)(_binary_kernel_elf_start);\n \n    if (elf->magic != ELF_MAGIC)\n        return;\n \n    ph = (struct proghdr *)((uchar *)elf + elf->phoff);\n    eph = ph + elf->phnum;\n    for (; ph \u003C eph; ph++)\n    {\n        pa = (uchar *)ph->paddr;\n        readseg(pa, ph->filesz, ph->off);\n        if (ph->memsz > ph->filesz)\n            clearMem(pa + ph->filesz, ph->memsz - ph->filesz);\n    }\n \n    entry = (void (*)(void))(elf->entry);\n    entry();\n}\n","c",[83,151,148],{"__ignoreMap":138},[16,153,154],{},"Finally, entry is the Go entry-function address read from the ELF header. Jump to it.",[16,156,157],{},"The Go entry function is rt0, written in assembly. Go uses Plan 9 assembly, originating in the ancient Plan 9 operating system. It supports multiple instruction-set architectures, yet bizarrely I could find no official documentation listing the supported instructions for each. Some x86 material exists because most Plan 9 examples target x86, but RV64 documentation was nowhere to be found. Pure guesswork.",[16,159,160],{},"After much experimentation, I finally wrote the entry routine:",[132,162,165],{"className":163,"code":164,"language":137,"meta":138},[135],"#include \"textflag.h\"\n\nTEXT ·rt0(SB),NOSPLIT|NOFRAME,$0\n    CALL ·kernelStackTop(SB)\n    MOV  0(SP), A1\n    MOV  A1, SP\n    CALL ·kmain(SB)\n    UNDEF\n    RET\n",[83,166,164],{"__ignoreMap":138},[16,168,169],{},"This syntax is rather cursed too. It does roughly the same thing: call kernelStackTop to obtain the preallocated stack-top address, point SP there, then call the Go entry, kmain. The only Go file is simple:",[132,171,176],{"className":172,"code":174,"language":175,"meta":138},[173],"language-go","type stack [16 * 4096]byte\n\ntype virtualAddress uintptr\n\nvar (\n    kstack stack\n)\n\n\u002F\u002Fgo:nosplit\nfunc (s *stack) top() virtualAddress {\n    stackTop := uintptr(unsafe.Pointer(&s[0])) + unsafe.Sizeof(*s)\n    \u002F\u002F Align to 16 bytes.\n    stackTop = stackTop &^ 0xf\n    return virtualAddress(stackTop)\n}\n\n\u002F\u002Fgo:nosplit\nfunc kernelStackTop() uint64 {\n    return uint64(kstack.top())\n}\n\n\u002F\u002Fgo:nosplit\nfunc rt0()\n\n\u002F\u002Fgo:nosplit\nfunc kmain() {\n    for {\n    }\n}\n","go",[83,177,174],{"__ignoreMap":138},[16,179,180,181,184],{},"The stack array is preallocated as the kernel stack, while kmain does nothing but loop forever. Notice the compiler directive ",[83,182,183],{"code":183},"\u002F\u002Fgo:nosplit"," on every function. It prevents insertion of stack-overflow checking code and also implicitly prevents GC checkpoints. If GC were triggered, this bare-metal environment with nothing implemented could not support it. Of course, GC should not run in the kernel anyway; it is more concerned with user-space heaps.",[16,186,187],{},"The Makefile can then look like this:",[132,189,194],{"className":190,"code":192,"language":193,"meta":138},[191],"language-make","Image: kernel.elf\n    $(CC) $(CFLAGS) -fno-pic -O -nostdinc -I. -c boot\u002Fboot.c\n    $(CC) $(CFLAGS) -fno-pic -nostdinc -I. -c boot\u002Fboot_header.S\n    $(LD) $(LDFLAGS) -T image.ld -o Image boot.o boot_header.o\n\nkernel.elf:\n    GOOS=linux GOARCH=riscv64 go build -o kernel.elf -ldflags '-E goose\u002Fkernel.rt0 -T 0x80200000' -gcflags \"-N -l\" .\u002Fkmain\n","make",[83,195,192],{"__ignoreMap":138},[16,197,198],{},"kernel.elf builds the Go ELF with goose\u002Fkernel.rt0 as its entry and 0x80200000 as the TEXT start. Image compiles the kernel-loading entry code above. image.ld puts the entry function first in TEXT and places TEXT at 0x80000000.",[132,200,205],{"className":201,"code":203,"language":204,"meta":138},[202],"language-plain","\u002F* 执行入口 *\u002F\nENTRY(_start)\n\n\u002F* 数据存放起始地址 *\u002F\nBASE_ADDRESS = 0x80000000;\n\nSECTIONS\n{\n    \u002F* . 表示当前地址（location counter） *\u002F\n    . = BASE_ADDRESS;\n\n    \u002F* start 符号表示全部的开始位置 *\u002F\n    kernel_start = .;\n\n    text_start = .;\n\n    \u002F* .text 字段 *\u002F\n    .text : {\n        \u002F* 把 entry 函数放在最前面 *\u002F\n        *(.text.entry)\n        \u002F* 要链接的文件的 .text 字段集中放在这里 *\u002F\n        *(.text .text.*)\n    }\n    ...\n}\n","plain",[83,206,203],{"__ignoreMap":138},[16,208,209],{},"All set!",[16,211,212],{},"I was so absorbed that I barely managed proper family visits over Chinese New Year. I spent all day shut in my room collecting information, and even outside I just stared into space thinking about approaches. I was obsessed.",[11,214,216],{"id":215},"a-grand-failure","A grand failure",[16,218,219],{},"Dun dun dunnn!",[16,221,222],{},"After loading the kernel into QEMU, debugging showed it freezing while loading program segments into memory. I examined the ELF from go build with readelf and found this bizarre thing:",[132,224,229],{"className":225,"code":227,"language":228,"meta":138},[226],"language-bash","Type           Offset             VirtAddr           PhysAddr\n                 FileSiz            MemSiz              Flags  Align\n  PHDR           0x0000000000000040 0x00000000801ff040 0x00000000801ff040\n                 0x0000000000000188 0x0000000000000188  R      0x10000\n  NOTE           0x0000000000000f9c 0x00000000801fff9c 0x00000000801fff9c\n                 0x0000000000000064 0x0000000000000064  R      0x4\n  LOAD           0xffffffffffff1000 0x00000000801f0000 0x00000000801f0000\n                 0x0000000000063300 0x0000000000063300  R E    0x10000\n  LOAD           0x0000000000060000 0x0000000080260000 0x0000000080260000\n                 0x000000000006adb8 0x000000000006adb8  R      0x10000\n  ...\n","bash",[83,230,227],{"__ignoreMap":138},[16,232,233],{},"Look at the third segment's Offset: the enormous 0xffffffffffff1000. Offset is the position of a segment's contents relative to the start of the file. This ELF was only tens of kilobytes—where could such an offset come from? Even in memory, virt has only 128 MB of physical RAM by default. Instant disaster.",[16,235,236,237,239,240,245],{},"Baffled, I experimented until I found that adding the linker flag ",[83,238,95],{"code":95}," always caused this. But I could not omit it: these segments cannot be loaded at low addresses occupied by MMIO. I filed a Go GitHub issue, ",[20,241,244],{"href":242,"rel":243},"https:\u002F\u002Fgithub.com\u002Fgolang\u002Fgo\u002Fissues\u002F57983",[24],"cmd\u002Flink: wrong program header offset when cross-compile to riscv64 when setting -T text alignment",". After describing the problem, I received this reply:",[16,247,248],{},[72,249],{"alt":250,"src":251},"ISSUE","https:\u002F\u002Fblog-img.774352199.xyz\u002F2025\u002F42c633b821d4323697e542b47a8fce31.png",[16,253,254,255,257],{},"Apparently RV64's support for ",[83,256,95],{"code":95}," was incomplete...",[16,259,260],{},"The project has remained shelved ever since. Such a waste of that wonderful name \u002F(ㄒo ㄒ)\u002F All I can do is hope Go fixes it, though RV64 does not seem to be a major priority. Native cross-compilation to RV64 only landed in mainline in the last few years...",[16,262,263],{},"I'm mad. Off to Rust!",{"title":138,"searchDepth":265,"depth":265,"links":266},4,[267,269,270],{"id":13,"depth":268,"text":14},3,{"id":61,"depth":268,"text":62},{"id":215,"depth":268,"text":216},[272],"fiddling","2023-02-02 23:24:55","Inspiration struck during Chinese New Year: an article read on the train about running Go on bare metal sparked an interest in low-level system interfaces. Its successful implementation suggested exciting possibilities for combining a high-level language with an OS. Further research revealed earlier work on the idea, and that growing enthusiasm became a project full of anticipation that ultimately did not work out.",false,"md","https:\u002F\u002Fblog-img.774352199.xyz\u002FxB1Ni5.webp",{"slots":279},{},true,"\u002Ffiddling\u002Fgo-os",null,{"text":284,"minutes":285,"time":286,"words":287},"8 min read",7.29,437400,1458,{"title":5,"description":274},"I tried building a RISC-V kernel in Go with a C ELF loader and assembly entry point, then traced a blocking ELF offset error to the linker’s -T option.","Bare-metal Go on RISC-V: debugging a kernel linker failure",{"loc":281,"images":292},[293,294],{"loc":75},{"loc":251},"posts\u002Ffiddling\u002Fgo-os",[297,298,299,300,301],"Go","RISC-V","Operating systems","Bare-metal programming","Runtime","tech","PMFdfLthlIRSCizLnOS9IUD9KzfoJa2tzZo6ArMOtXk",[305,323,340,357,374,392,409,427,445,461,477,492,496,512,529,547,562,579,593,609,626,643,659,676,692,711,727,744,762,776,794,811,827,843,857,874,888,903,918,932,946,960,975,989,1000],{"categories":306,"date":308,"description":309,"image":310,"path":311,"readingTime":312,"recommend":282,"tags":317,"title":322,"type":302},[307],"daily","2024-09-01 22:03:10","Chronic gastritis has been a long, uneven journey: stomach trouble throughout childhood, a surprising reprieve at university, then a return of symptoms after years of late nights and drinking. Frequent nausea and reflux eventually became too much to live with. After repeated examinations and some reflection, I finally began taking the recovery process seriously.","https:\u002F\u002Fblog-img.774352199.xyz\u002F0Hr9l5.webp","\u002Fdaily\u002Fanti-chronic-gastritis",{"text":313,"minutes":314,"time":315,"words":316},"4 min read",3.08,184800,616,[318,319,320,321],"Chronic gastritis","Medical care experiences","Gastroscopy","Health journal","My Journey with Chronic Gastritis",{"categories":324,"date":325,"description":326,"image":327,"path":328,"readingTime":329,"recommend":282,"tags":334,"title":339,"type":302},[307],"2022-04-11 00:13:13","In The Three-Body Problem, Liu Cixin uses an immense historical canvas to explore the relationship between individuals and the collective. His doubts about Western democracy and the majority’s ability to determine its own fate run through the trilogy. Heroes struggle and sacrifice, only to see their work swept aside by history. Beginning with the Cultural Revolution, the story sets up a conflict between exceptional individuals and the ordinary masses, raising uncomfortable questions about humanity and society.","https:\u002F\u002Fblog-img.774352199.xyz\u002FLTzbFP.webp","\u002Fdaily\u002Fpeople-in-three-body",{"text":330,"minutes":331,"time":332,"words":333},"9 min read",8.635,518100,1727,[335,336,337,338],"The Three-Body Problem","Liu Cixin","Science fiction","Reading notes","The “Majority” in The Three-Body Problem",{"categories":341,"date":342,"description":343,"image":344,"path":345,"readingTime":346,"recommend":282,"tags":351,"title":356,"type":302},[307],"2024-01-04 02:06:51","My learning goals for 2024: reach N2 in Japanese, finish SICP and TAPL, build a kernel with full POSIX support, and update the blog theme. A challenging list, but a clear direction for the year.","https:\u002F\u002Fblog-img.774352199.xyz\u002FV3rSQC.webp","\u002Fdaily\u002Fplan2024",{"text":347,"minutes":348,"time":349,"words":350},"1 min read",0.15,9000,30,[352,353,354,355,299],"Annual planning","Learning Japanese","SICP","TAPL","My Learning Plan for 2024",{"categories":358,"date":359,"description":360,"image":361,"path":362,"readingTime":363,"recommend":282,"tags":368,"title":373,"type":302},[307],"2024-09-28 16:26:00","Three years at ByteDance have made time feel strangely accelerated. Amid the changes, I have still managed to hold on to some mental balance. Looking back at the new graduate gazing at distant mountains from the balcony of our Hangzhou office, I can trace how curiosity, workplace challenges, and shifting expectations taught me to find a rhythm of my own.","https:\u002F\u002Fblog-img.774352199.xyz\u002FhnCaht.webp","\u002Fdaily\u002Fwork-for-3-years",{"text":364,"minutes":365,"time":366,"words":367},"10 min read",9.74,584400,1948,[369,370,371,372],"ByteDance","Software engineering careers","Career retrospective","Mental health","Working at ByteDance for Three Years and Staying Somewhat Sane Is Not Entirely Impossible",{"categories":375,"date":376,"description":377,"image":378,"path":379,"readingTime":380,"recommend":282,"tags":385,"title":391,"type":302},[272],"2025-05-28 22:09:00","After moving my blog to Astro, the usual Google Analytics integration no longer fit its performance goals. Adding event-reporting JavaScript directly to the head works, but hurts page performance. I used partytown to move the scripts off the main thread so they would not interfere with loading. With a few adjustments to the example code, Google Analytics finally worked, balancing performance with analytics.","https:\u002F\u002Fblog-img.774352199.xyz\u002FQ0w4RN.webp","\u002Ffiddling\u002Fastro-google-tag-manager",{"text":381,"minutes":382,"time":383,"words":384},"2 min read",1.785,107100,357,[386,387,388,389,390],"Astro","Google Analytics","Google Tag Manager","Partytown","Web analytics","Adding Google Analytics to Astro with Tag Manager",{"categories":393,"date":394,"description":395,"image":396,"path":397,"readingTime":398,"recommend":403,"tags":404,"title":408,"type":302},[272],"2023-04-08 13:16:36","Designing a new programming language is challenging and fun. Setting aside complicated compiler theory and implementation details to focus on where code runs helps clarify how languages are built. Starting from the RISC-VI instruction set, this discussion explores the underlying architecture, layered computer systems, and virtual-machine model, reflecting on the nature of programming languages as well as their implementation.","https:\u002F\u002Fblog-img.774352199.xyz\u002FuO420B.webp","\u002Ffiddling\u002Fchitchat-about-programming-language",{"text":399,"minutes":400,"time":401,"words":402},"15 min read",14.275,856500,2855,2,[405,406,407,298],"Programming language design","Type systems","Compiler design","Some Thoughts on Programming Languages",{"categories":410,"date":411,"description":412,"image":413,"path":414,"readingTime":415,"recommend":265,"tags":420,"title":426,"type":302},[272],"2025-04-18 16:43:12","My girlfriend moved from Beijing to Shanghai for work, and I helped arrange broadband too. Shanghai Telecom’s 500M connection costs more than a 1000M line in Hangzhou, frustratingly. I set out to connect the two cities’ networks: transparent proxying in Shanghai, selected traffic exiting through Hangzhou, and access between both LANs. Hangzhou already had a simple setup with a software router and an AP, configured to route my everyday traffic home and ready for the next networking adventure.","https:\u002F\u002Fblog-img.774352199.xyz\u002FO6cAGh.webp","\u002Ffiddling\u002Fcross-city-network-setup",{"text":416,"minutes":417,"time":418,"words":419},"5 min read",4.865,291900,973,[421,422,423,424,425],"Tailscale","mihomo","Site-to-site networking","Transparent proxy","Home networking","Connecting My Shanghai and Hangzhou Networks",{"categories":428,"date":429,"description":430,"image":431,"path":432,"readingTime":433,"recommend":282,"tags":438,"title":444,"type":302},[272],"2021-12-27 00:09:00","The labs are an essential part of learning CSAPP, but setting up Linux can be discouraging. Virtual machines bring installation errors, compatibility problems, and broken networking. WSL (Windows Subsystem for Linux), especially on Windows 10 version 2004 and later, provides a simpler, more direct Linux environment without the complexity and performance bottlenecks of a traditional VM.","https:\u002F\u002Fblog-img.774352199.xyz\u002FvqOC7N.webp","\u002Ffiddling\u002Fcsapplab0",{"text":434,"minutes":435,"time":436,"words":437},"6 min read",5.295,317700,1059,[439,440,441,442,443],"CSAPP","WSL2","Linux","GDB","Lab environment","Setting Up the CSAPP Lab Environment",{"categories":446,"date":447,"description":448,"image":449,"path":450,"readingTime":451,"recommend":282,"tags":456,"title":460,"type":302},[272],"2024-07-13 17:49:00","Using Debian as a side router offers a more stable and flexible alternative without depending on OpenWrt and LuCI. Configuring Debian directly gives you greater control over the system and avoids the limitations and instability of a GUI. Compared with common side-router setups, this approach makes transparent proxying more reliable and offers another option for those who value performance and efficiency.","https:\u002F\u002Fblog-img.774352199.xyz\u002FpPRU5x.webp","\u002Ffiddling\u002Fdebian-as-bypass-router",{"text":452,"minutes":453,"time":454,"words":455},"12 min read",11.79,707400,2358,[457,458,422,459,424],"Debian","Side router","AdGuard Home","Using Debian as a Side Router",{"categories":462,"date":463,"description":464,"image":465,"path":466,"readingTime":467,"recommend":282,"tags":471,"title":476,"type":302},[272],"2024-08-16 23:53:00","This FakeIP-based transparent proxy design addresses the single point of failure, poor performance, and awkward port forwarding of a traditional side router. Switching to the sing-box proxy core improves forwarding performance and simplifies configuration, with broader protocol support and better optimization than the previous Clash setup. Clash can implement the same design, but sing-box provides a flexible alternative.","https:\u002F\u002Fblog-img.774352199.xyz\u002FS2HHD5.webp","\u002Ffiddling\u002Ffake-ip-based-transparent-proxy",{"text":364,"minutes":468,"time":469,"words":470},9.395,563700,1879,[472,473,424,474,475],"FakeIP","sing-box","Policy-based routing","Traffic routing","Routing Transparent Proxy Traffic with FakeIP",{"categories":478,"date":479,"description":480,"image":481,"path":482,"readingTime":483,"recommend":282,"tags":487,"title":491,"type":302},[272],"2024-08-15 23:50:00","Port forwarding on the main router often stops working when a side router is introduced. Setting the side router as the gateway changes the forwarding path, breaking mappings that previously relied on the main router. A gateway translates addresses and forwards traffic from the internal network to the outside, and each internal device needs one to communicate externally. Understanding this mechanism helps explain how to fix the forwarding problem.","https:\u002F\u002Fblog-img.774352199.xyz\u002FmRqws9.webp","\u002Ffiddling\u002Ffix-port-forward-in-bypass-router",{"text":313,"minutes":484,"time":485,"words":486},3.03,181800,606,[458,488,489,490],"Port forwarding","NAT","Network troubleshooting","Fixing Port Forwarding with a Side Router",{"categories":493,"date":273,"description":274,"image":277,"path":281,"readingTime":494,"recommend":282,"tags":495,"title":5,"type":302},[272],{"text":284,"minutes":285,"time":286,"words":287},[297,298,299,300,301],{"categories":497,"date":498,"description":499,"image":500,"path":501,"readingTime":502,"recommend":282,"tags":507,"title":511,"type":302},[272],"2022-08-15 01:05:01","While refactoring a system, converting entities between layers made deep copying surprisingly awkward. A product VO in the view layer, an entity in the domain layer, and a PO in the persistence layer can look nearly identical, yet small type differences complicate direct conversion. I used reflection to build a general conversion method, reducing repetitive assembler methods and making the code more maintainable and flexible.","https:\u002F\u002Fblog-img.774352199.xyz\u002FBlhm0I.webp","\u002Ffiddling\u002Fgolang-deepcopy-between-different-type",{"text":503,"minutes":504,"time":505,"words":506},"3 min read",2.855,171300,571,[297,508,509,510],"Reflection","Deep copy","Struct conversion","Deep Copying Between Different Struct Types in Go",{"categories":513,"date":514,"description":515,"image":516,"path":517,"readingTime":518,"recommend":282,"tags":522,"title":528,"type":302},[272],"2025-03-31 23:51:00","Periodically syncing heart-rate data from Apple Health to a server and visualizing it in Grafana provides an intuitive way to monitor it. Health Auto Export sends the data to an HTTP endpoint through its REST API automation, the server stores it in InfluxDB, and Grafana presents a clear dashboard for tracking and analyzing personal heart-rate changes.","https:\u002F\u002Fblog-img.774352199.xyz\u002FF4qD2T.webp","\u002Ffiddling\u002Fheart-rate-to-grafana",{"text":503,"minutes":519,"time":520,"words":521},2.45,147000,490,[523,524,525,526,527],"Apple Watch","Health Auto Export","InfluxDB","Grafana","Heart rate monitoring","My Heart Beats for U: Visualizing Heart Rate in Grafana",{"categories":530,"date":531,"description":532,"image":533,"path":534,"readingTime":535,"recommend":539,"tags":540,"title":546,"type":302},[272],"2025-06-10 20:18:00","macOS and iPadOS 26 introduce the Liquid Glass design language, refreshing icons and windows with a more modern look. Windowed apps on iPad are a step toward making it a productivity device. The transparent Control Center and the integration of Launchpad have been controversial, however, and the experience still needs work. Despite its shortcomings, this update lays groundwork for a promising future.","https:\u002F\u002Fblog-img.774352199.xyz\u002FTPSaLE.webp","\u002Ffiddling\u002Fmacos-26-trial",{"text":313,"minutes":536,"time":537,"words":538},3.305,198300,661,5,[541,542,543,544,545],"macOS 26","iPadOS 26","Liquid Glass","Apple Intelligence","Operating system impressions","Trying Out macOS 26 and iPadOS 26",{"categories":548,"date":549,"description":550,"image":551,"path":552,"readingTime":553,"recommend":282,"tags":557,"title":561,"type":302},[272],"2026-06-11 10:00:00","Another WWDC brings new Apple Intelligence features in macOS 27. The workarounds from macOS 26 no longer get through, so the battle of wits with Apple continues.","https:\u002F\u002Fblog-img.774352199.xyz\u002FfOFucm.webp","\u002Ffiddling\u002Fmacos-27-apple-intelligence-chatgpt",{"text":434,"minutes":554,"time":555,"words":556},5.1,306000,1020,[558,544,559,560],"macOS 27","ChatGPT","Mainland China Mac","Getting Apple Intelligence Working on a China-Market Mac: Region Changes and Extracting ChatGPT",{"categories":563,"date":564,"description":565,"image":566,"path":567,"readingTime":568,"recommend":282,"tags":572,"title":578,"type":302},[272],"2025-07-20 23:32:00","MoonTV is a new video aggregation platform built with Next.js and React to make following shows convenient. It began as an attempt to improve LibreTV and has attracted substantial attention and usage over several months of development. Cursor made development efficient, although multi-platform support and complex data dependencies posed challenges. As its user base grows, MoonTV continues improving in response to feedback.","https:\u002F\u002Fblog-img.774352199.xyz\u002FnIeONi.webp","\u002Ffiddling\u002Fmoontv-vibe-coding",{"text":434,"minutes":569,"time":570,"words":571},5.76,345600,1152,[573,574,575,576,577],"MoonTV","LunaTV","Vibe Coding","Cursor","AI-assisted development","MoonTV: An Experiment in Vibe Coding",{"categories":580,"date":581,"description":582,"image":583,"path":584,"readingTime":585,"recommend":282,"tags":589,"title":592,"type":302},[272],"2024-10-07 16:51:00","BGP-based routing for Chinese and overseas IPs makes transparent proxying more efficient and accurate. Marking overseas destinations with FakeIP lets the main router route traffic more intelligently for smoother connectivity. The sing-box DNS configuration is also refined to handle queries more flexibly and efficiently, improving the overall network experience.","https:\u002F\u002Fblog-img.774352199.xyz\u002FMOmM1s.webp","\u002Ffiddling\u002Fmore-accurate-chnroute",{"text":313,"minutes":586,"time":587,"words":588},3.805,228300,761,[590,591,474,475],"BGP","IP address database","More Accurate Routing for Chinese and Overseas IPs with BGP",{"categories":594,"date":595,"description":596,"image":597,"path":598,"readingTime":599,"recommend":282,"tags":603,"title":608,"type":302},[272],"2025-12-14 14:31:00","A friend’s comment got me interested in simulation games. After buying Microsoft Flight Simulator, I discovered streamed maps and models, another account login, oddly hidden tutorials, and awkward keyboard controls. A flight stick and some tinkering with Pico VR finally rounded out the experience.","https:\u002F\u002Fblog-img.774352199.xyz\u002FlfhEuE.webp","\u002Ffiddling\u002Fmsfs2024-joystick-and-pico",{"text":416,"minutes":600,"time":601,"words":602},4.68,280800,936,[604,605,606,607],"Microsoft Flight Simulator 2024","Thrustmaster TCA","PICO VR","Flight simulation","Adventures with Microsoft Flight Simulator 2024",{"categories":610,"date":611,"description":612,"image":613,"path":614,"readingTime":615,"recommend":282,"tags":619,"title":625,"type":302},[272],"2025-06-05 23:26:00","My frequent phone changes took me from OnePlus to iPhone, and from enjoying tinkering to relying on an ecosystem. At my girlfriend’s suggestion, I recently bought an OPPO Find X8 Ultra to improve my photos. Migrating apps out of Apple’s ecosystem reminded me how uneven Android’s app selection remains and how difficult finding replacements can be. A month of migration has been an exercise in friction and adaptation between platforms.","https:\u002F\u002Fblog-img.774352199.xyz\u002F19NIhZ.webp","\u002Ffiddling\u002Fone-month-using-android",{"text":284,"minutes":616,"time":617,"words":618},7.61,456600,1522,[620,621,622,623,624],"Android","OPPO","iOS","Smartphone impressions","Ecosystem migration","One Month After Switching to Android",{"categories":627,"date":628,"description":629,"image":630,"path":631,"readingTime":632,"recommend":282,"tags":636,"title":642,"type":302},[272],"2026-05-11 22:43:00","I found a trip-planning tool on GitHub Trending and wanted to host my own instance. Since I was getting a new VPS anyway, I might as well install a little extra. Well, quite a lot extra.","https:\u002F\u002Fblog-img.774352199.xyz\u002FBBdDWW.webp","\u002Ffiddling\u002Fone-trek-twenty-stacks",{"text":434,"minutes":633,"time":634,"words":635},5.735,344100,1147,[637,638,639,640,641],"TREK","Docker Compose","Dockge","VPS","Self-hosting","One TREK, Twenty Stacks",{"categories":644,"date":645,"description":646,"image":647,"path":648,"readingTime":649,"recommend":282,"tags":654,"title":658,"type":302},[272],"2025-01-16 23:09:00","OPNsense is an open-source firewall and router with an attractive interface and a comprehensive feature set. After trying several routing setups, I came to appreciate its potential for transparent proxying and traffic routing. Combining it with BGP-based routing offers better security and stability, while its automatically updated IP lists make network management more convenient.","https:\u002F\u002Fblog-img.774352199.xyz\u002FxA8C1E.webp","\u002Ffiddling\u002Fopnsense-transparent-proxy",{"text":650,"minutes":651,"time":652,"words":653},"7 min read",6.47,388200,1294,[655,656,422,657,424,475],"OPNsense","FreeBSD","tun2socks","Transparent Proxying and Traffic Routing with OPNsense",{"categories":660,"date":661,"description":662,"image":663,"path":664,"readingTime":665,"recommend":268,"tags":669,"title":675,"type":302},[272],"2025-03-15 20:35:00","Distinguishing user-defined type names from ordinary variables is a challenge during parsing. A statement such as `a*b;` can be either an arithmetic expression or a declaration. Grammar rules, especially those involving type specifiers, can misidentify variables as types, affecting correctness and readability. The prevalence of declarations without initializers makes this ambiguity especially common.","https:\u002F\u002Fblog-img.774352199.xyz\u002F2VKHK9.webp","\u002Ffiddling\u002Fparser-type-variable-ambiguity",{"text":284,"minutes":666,"time":667,"words":668},7.475,448500,1495,[670,671,672,673,674],"Parsing","GLR","Symbol table","Scope","Disambiguation","Resolving Type Name and Variable Name Ambiguity in Parsing",{"categories":677,"date":678,"description":679,"image":680,"path":681,"readingTime":682,"recommend":282,"tags":686,"title":691,"type":302},[272],"2023-05-24 17:51:09","To install the RISC-V toolchain, first obtain the riscv-gnu-toolchain source. Using `--depth=1` when cloning reduces the download size. Check the README’s Prerequisites section and install the required dependencies. On Debian, a simple package installation command prepares the environment for building the toolchain.","https:\u002F\u002Fblog-img.774352199.xyz\u002FrWNOKx.webp","\u002Ffiddling\u002Fspike-install",{"text":381,"minutes":683,"time":684,"words":685},1.92,115200,384,[298,687,688,689,690],"Spike","riscv-pk","Cross-compilation","Toolchain","Installing the RISC-V Toolchain and Emulator",{"categories":693,"date":694,"description":695,"image":696,"path":697,"readingTime":698,"recommend":702,"tags":703,"title":710,"type":302},[272],"2026-09-09 23:59:00","This counts as NTR too, surely.","https:\u002F\u002Fblog-img.774352199.xyz\u002FNDPUwc.webp","\u002Ffiddling\u002Fsteamdeck-switch-60fps",{"text":284,"minutes":699,"time":700,"words":701},7.345,440700,1469,7,[704,705,706,707,708,709],"Steam Deck","Nintendo Switch","EmuDeck","Eden","Lossless Scaling","Frame generation","A Second Life for the Steam Deck: Switch Emulation and Frame Generation at 60 FPS",{"categories":712,"date":713,"description":714,"image":715,"path":716,"readingTime":717,"recommend":282,"tags":721,"title":726,"type":302},[272],"2024-06-23 15:31:32","The GFW does more than monitor an exit gateway: it inspects international traffic through passive taps, copying inbound and outbound IP packets to a cluster for analysis and filtering. Understanding where and how this happens matters when studying censorship circumvention. Examining the GFW’s network topology helps explain its blocking mechanisms and how to work around them.","https:\u002F\u002Fblog-img.774352199.xyz\u002FsOpJuL.webp","\u002Ffiddling\u002Ftech-about-gfw",{"text":452,"minutes":718,"time":719,"words":720},11.885,713100,2377,[722,723,724,725],"GFW","DNS poisoning","TCP","Internet censorship","How the Great Firewall Works",{"categories":728,"date":729,"description":730,"image":731,"path":732,"readingTime":733,"recommend":282,"tags":737,"title":743,"type":302},[272],"2022-04-16 00:01:28","In Java, using `this` can prevent the compiler from optimizing constants. Although `ab1` and `ab2` in this example appear to refer to the same static final variable `s`, comparing them produces different results. `ab1` concatenates a direct reference to the static variable, while `ab2` accesses it through `this`, preventing the same constant propagation optimization. This illustrates how a small syntactic difference can change compilation behavior.","https:\u002F\u002Fblog-img.774352199.xyz\u002FgKtkYe.webp","\u002Ffiddling\u002Fthis-in-javac-string-concat",{"text":503,"minutes":734,"time":735,"words":736},2.305,138300,461,[738,739,740,741,742],"Java","javac","String concatenation","Constant propagation","Bytecode","How Java’s this Keyword Can Prevent Compile-Time Constant Propagation",{"categories":745,"date":746,"description":747,"image":748,"path":749,"readingTime":750,"recommend":282,"tags":755,"title":761,"type":302},[272],"2025-01-29 21:58:00","A microblog lets you share short thoughts whenever they occur, without the overhead of publishing a full static-blog post. This implementation uses Cloudflare Workers for the backend and KV for storage and management. A Vue component embedded in VitePress displays the updates, adding a lively, interactive element to the blog.","https:\u002F\u002Fblog-img.774352199.xyz\u002FhZX6hr.webp","\u002Ffiddling\u002Fvitepress-memos-component",{"text":751,"minutes":752,"time":753,"words":754},"19 min read",18.96,1137600,3792,[756,757,758,759,760],"VitePress","Vue","Cloudflare Workers","Cloudflare KV","Microblogging","Adding a Microblog to VitePress",{"categories":763,"date":764,"description":765,"image":766,"path":767,"readingTime":768,"recommend":282,"tags":772,"title":775,"type":302},[272],"2025-03-15 16:24:00","A Telegram notification on an ordinary afternoon introduced a tempting VPS deal: a direct China Telecom CN2 route and 2.5G bandwidth. The plan includes IPv6, useful for unlocking streaming services, but not every connection needs to go through WARP. My previous script was convenient, yet its effects on speed and traffic routing called for a more flexible solution.","https:\u002F\u002Fblog-img.774352199.xyz\u002FMcjrrF.webp","\u002Ffiddling\u002Fvps-warp-ipv6",{"text":503,"minutes":769,"time":770,"words":771},2.34,140400,468,[773,774,640,474,475],"Cloudflare WARP","IPv6","Routing Selected VPS Traffic Through WARP over IPv6",{"categories":777,"date":778,"description":779,"image":780,"path":781,"readingTime":782,"recommend":786,"tags":787,"title":793,"type":302},[272],"2026-08-17 23:59:21","The more I tinker, the more I want to tinker. Still going strong in my old age, still going strong!","https:\u002F\u002Fblog-img.774352199.xyz\u002FqfxB0h.webp","\u002Ffiddling\u002Fxiaomi17-root-and-hide-root",{"text":416,"minutes":783,"time":784,"words":785},4.545,272700,909,6,[788,789,790,791,792],"Xiaomi 17","Bootloader","Android Root","Firmware flashing","Root hiding","Making the Xiaomi 17 My Daily Driver: Unlocking, Flashing, Rooting, and Hiding Root",{"categories":795,"date":797,"description":798,"image":799,"path":800,"readingTime":801,"recommend":282,"tags":805,"title":810,"type":302},[796],"notes","2022-01-20 22:29:00","Lab 1 asks us to implement a MapReduce system with two core components: a master and workers. This requires a good command of Go RPC and concurrent programming, along with a thorough understanding of the MapReduce workflow. I built two versions, starting with mutex locks and then moving to a more elegant channel-based implementation without explicit locks, whose design is simpler and clearer. The key to understanding the lab is to read the relevant documentation carefully, especially the flowcharts and explanations.","https:\u002F\u002Fblog-img.774352199.xyz\u002FibVwPJ.webp","\u002Fnotes\u002F65840\u002Fmapreducelab",{"text":284,"minutes":802,"time":803,"words":804},7.21,432600,1442,[806,807,297,808,809],"MIT 6.5840","MapReduce","RPC","Concurrent programming","6.5840 Lab 1: MapReduce",{"categories":812,"date":813,"description":814,"image":815,"path":816,"readingTime":817,"recommend":282,"tags":821,"title":826,"type":302},[796],"2022-01-16 17:32:00","MapReduce is an efficient parallel computing model designed to simplify processing large datasets. By defining the two key functions, Map and Reduce, users can break complex tasks into simple operations. The framework automatically handles data distribution and task scheduling, allowing developers to focus on the algorithm rather than low-level details. Its widespread use in distributed systems demonstrates its flexibility and practical value.","https:\u002F\u002Fblog-img.774352199.xyz\u002FApIDdC.webp","\u002Fnotes\u002F65840\u002Fmapreducepaper",{"text":416,"minutes":818,"time":819,"words":820},4.12,247200,824,[807,822,823,824,825],"Distributed systems","Paper notes","Parallel computing","Fault tolerance","Reading the MapReduce Paper",{"categories":828,"date":829,"description":830,"image":831,"path":832,"readingTime":833,"recommend":282,"tags":838,"title":842,"type":302},[796],"2022-12-16 02:06:10","Lab 2A focuses on implementing Raft leader election and heartbeats so that elections and term changes work correctly even under extreme conditions. The lab has four stages and lays the foundation for the distributed key-value store that follows. A design without explicit locks simplifies the Raft struct. The lab instructions provide the necessary background, but compared with the previous lab, this one relies on almost no reference material and places greater emphasis on implementing the system independently.","https:\u002F\u002Fblog-img.774352199.xyz\u002Fc11Uk4.webp","\u002Fnotes\u002F65840\u002Fraftlab2a",{"text":834,"minutes":835,"time":836,"words":837},"13 min read",12.235,734100,2447,[806,839,297,840,841],"Raft","Leader election","Distributed consensus","6.5840 Lab 2A: Leader Election",{"categories":844,"date":845,"description":846,"image":847,"path":848,"readingTime":849,"recommend":282,"tags":854,"title":856,"type":302},[796],"2022-12-03 21:40:09","Raft is a consensus algorithm designed to improve the efficiency of log replication. It is particularly suited to clusters of machines, allowing them to keep providing service even when some machines fail. It uses the replicated state machine model: logs record the order of commands so that every machine in the cluster can reach the same state. In Search of an Understandable Consensus Algorithm explores Raft’s design and compares it with Paxos, highlighting its understandability and providing a foundation for building reliable large-scale software systems. These reading notes aim to help explain the paper’s core concepts and their applications.","https:\u002F\u002Fblog-img.774352199.xyz\u002F7mmvIZ.webp","\u002Fnotes\u002F65840\u002Freftextendedpaper",{"text":850,"minutes":851,"time":852,"words":853},"16 min read",15.98,958800,3196,[839,841,855,823],"Log replication","Reading the Raft Paper",{"categories":858,"date":860,"description":861,"image":862,"path":863,"readingTime":864,"recommend":868,"tags":869,"title":873,"type":302},[859],"projects","2021-11-27 14:43:00","MYDB is a personal project exploring and implementing the fundamentals of databases, built in my spare time over a little more than half a month. I picked up some basic knowledge in my university database systems course, though during my internship I mostly used the classes as an excuse to slack off. My candid answers in an interview did not cause too much trouble, but they did make me reconsider what I knew about databases and decide to learn through hands-on practice. That was how this project began.","https:\u002F\u002Fblog-img.774352199.xyz\u002Fxfci2J.webp","\u002Fprojects\u002Fmydb\u002Fmydb0",{"text":416,"minutes":865,"time":866,"words":867},4.15,249000,830,1,[870,738,871,872],"MYDB","Database implementation","Database architecture","MYDB 0. Project Structure and a Few Things I Had to Say",{"categories":875,"date":876,"description":877,"image":878,"path":879,"readingTime":880,"recommend":282,"tags":884,"title":887,"type":302},[859],"2021-11-28 16:10:00","MYDB manages transactions through an XID file. Each transaction has a unique XID, incrementing from 1; XID 0 denotes a super transaction whose state is always committed. TransactionManager maintains this file and records three states: active, committed, and aborted. This mechanism supports accurate transaction state queries and management, providing a foundation for system stability and reliability.","https:\u002F\u002Fblog-img.774352199.xyz\u002FH4zZAK.webp","\u002Fprojects\u002Fmydb\u002Fmydb1",{"text":416,"minutes":881,"time":882,"words":883},4.755,285300,951,[870,738,885,886],"Transaction management","XID","MYDB 1. Starting with the Transaction Manager",{"categories":889,"date":890,"description":891,"image":892,"path":893,"readingTime":894,"recommend":282,"tags":898,"title":902,"type":302},[859],"2021-12-25 18:26:00","MYDB uses a client\u002Fserver architecture similar to MySQL, allowing multiple clients to connect to a server over sockets, execute SQL queries, and receive results. Communication uses a special binary format, though plain text would also be an option for a simpler implementation. The basic transport structure supports effective communication and processing between client and server.","https:\u002F\u002Fblog-img.774352199.xyz\u002FPAHrUZ.webp","\u002Fprojects\u002Fmydb\u002Fmydb10",{"text":416,"minutes":895,"time":896,"words":897},4.305,258300,861,[870,738,899,900,901],"Socket","Client-server architecture","Communication protocol","MYDB 10. Implementing the Server, Client, and Wire Protocol",{"categories":904,"date":905,"description":906,"image":907,"path":908,"readingTime":909,"recommend":282,"tags":913,"title":917,"type":302},[859],"2021-11-30 23:18:00","The Data Manager (DM) bridges higher-level modules and the filesystem, handling paging and caching while ensuring data safety and recovery. Its cache uses reference counting rather than traditional LRU, aiming for a reusable, efficient foundation for subsequent data operations.","https:\u002F\u002Fblog-img.774352199.xyz\u002FWdIGoG.webp","\u002Fprojects\u002Fmydb\u002Fmydb2",{"text":434,"minutes":910,"time":911,"words":912},5.725,343500,1145,[870,738,914,915,916],"Reference counting","Cache design","Shared memory","MYDB 2. A Reference-Counted Cache Framework and Shared Byte Arrays",{"categories":919,"date":920,"description":921,"image":922,"path":923,"readingTime":924,"recommend":282,"tags":928,"title":931,"type":302},[859],"2021-12-05 15:28:00","DM abstracts the filesystem into pages and uses them as the unit of reading, writing, and caching. The default page size is 8K, with larger pages available to improve write performance under heavy loads. With the general-purpose cache framework already in place, we now define the page structure and implement efficient page caching.","https:\u002F\u002Fblog-img.774352199.xyz\u002FjlFC4E.webp","\u002Fprojects\u002Fmydb\u002Fmydb3",{"text":416,"minutes":925,"time":926,"words":927},4.7,282000,940,[870,738,929,930],"Data pages","Cache management","MYDB 3. Caching and Managing Data Pages",{"categories":933,"date":934,"description":935,"image":936,"path":937,"readingTime":938,"recommend":282,"tags":942,"title":945,"type":302},[859],"2021-12-08 22:55:00","Log files are essential to MYDB’s design, allowing data to be recovered after a crash. DM logs every operation on underlying data, forming a continuous sequence of records. Stored in a specific binary format with checksums and individual operation records, these logs let the database accurately reconstruct its data on restart and maintain consistency and integrity.","https:\u002F\u002Fblog-img.774352199.xyz\u002FTRcbsj.webp","\u002Fprojects\u002Fmydb\u002Fmydb4",{"text":284,"minutes":939,"time":940,"words":941},7.885,473100,1577,[870,738,943,944],"Database logging","Crash recovery","MYDB 4. Log Files and Recovery Strategies",{"categories":947,"date":948,"description":949,"image":950,"path":951,"readingTime":952,"recommend":282,"tags":956,"title":959,"type":302},[859],"2021-12-11 15:16:00","The page index is an important part of DM, optimizing insertions by caching the free space available on each page. It lets higher-level modules quickly locate a suitable page without a lengthy search, making data operations more efficient. Its implementation works closely with the DataItem abstraction to support efficient database operation.","https:\u002F\u002Fblog-img.774352199.xyz\u002F22PSG1.webp","\u002Fprojects\u002Fmydb\u002Fmydb5",{"text":650,"minutes":953,"time":954,"words":955},6.37,382200,1274,[870,738,957,958],"Page index","Data management","MYDB 5. The Page Index and the Data Manager",{"categories":961,"date":962,"description":963,"image":964,"path":965,"readingTime":966,"recommend":282,"tags":970,"title":974,"type":302},[859],"2021-12-18 14:58:00","VM uses two-phase locking to ensure serializable schedules and introduces multiversion concurrency control (MVCC) to eliminate blocking between reads and writes. This chapter also defines conflicts between database operations, focusing on the interaction between updates and reads as a foundation for understanding transaction isolation levels.","https:\u002F\u002Fblog-img.774352199.xyz\u002F8YzotA.webp","\u002Fprojects\u002Fmydb\u002Fmydb6",{"text":330,"minutes":967,"time":968,"words":969},8.64,518400,1728,[870,738,971,972,973],"MVCC","Transaction isolation","Two-phase locking","MYDB 6. Record Versions and Transaction Isolation",{"categories":976,"date":977,"description":978,"image":979,"path":980,"readingTime":981,"recommend":282,"tags":985,"title":988,"type":302},[859],"2021-12-23 21:20:00","VM must handle version skipping introduced by MVCC as well as deadlocks. By simply marking a transaction, MYDB can cancel or roll it back and keep data from aborted transactions from affecting others. This design makes concurrent transaction handling more efficient and reliable, avoids the deadlock risks common with traditional 2PL, and improves overall stability and performance.","https:\u002F\u002Fblog-img.774352199.xyz\u002FBF3yDW.webp","\u002Fprojects\u002Fmydb\u002Fmydb7",{"text":284,"minutes":982,"time":983,"words":984},7.265,435900,1453,[870,738,986,987],"Deadlock detection","Version management","MYDB 7. Deadlock Detection and the Version Manager",{"categories":990,"date":991,"description":992,"image":993,"path":994,"readingTime":995,"recommend":282,"tags":996,"title":999,"type":302},[859],"2021-12-24 21:01:00","MYDB implements a clustered index using a B+ tree. IM interacts directly with the Data Manager (DM), bypassing the Version Manager (VM), so index data is written directly to the database file. This chapter details the binary-tree index structure and its basic node fields, including the leaf flag, key count, and sibling identifier, establishing the framework for indexed lookups.","https:\u002F\u002Fblog-img.774352199.xyz\u002Ff92X4o.webp","\u002Fprojects\u002Fmydb\u002Fmydb8",{"text":416,"minutes":865,"time":866,"words":867},[870,738,997,998],"B+ tree","Database indexing","MYDB 8. Index Management",{"categories":1001,"date":1002,"description":1003,"image":1004,"path":1005,"readingTime":1006,"recommend":282,"tags":1010,"title":1013,"type":302},[859],"2021-12-25 15:44:00","The Table Manager (TBM) manages field and table structures. Parser turns SQL-like statements into structured representations, wrapping their information in the corresponding classes to simplify subsequent operations. This chapter also covers MYDB’s SQL syntax as a foundation for understanding the management process.","https:\u002F\u002Fblog-img.774352199.xyz\u002FzOMyv5.webp","\u002Fprojects\u002Fmydb\u002Fmydb9",{"text":434,"minutes":1007,"time":1008,"words":1009},5.035,302100,1007,[870,738,1011,1012],"SQL parsing","Table management","MYDB 9. Field and Table Management",1789914050203]