[{"data":1,"prerenderedAt":1000},["ShallowReactive",2],{"content:\u002Fen\u002Fnotes\u002F65840\u002Fmapreducelab":3,"series:content_en":291},{"id":4,"title":5,"authorship":6,"body":7,"categories":260,"date":262,"description":263,"draft":264,"extension":265,"image":266,"meta":267,"navigation":269,"path":270,"permalink":271,"published":271,"readingTime":272,"recommend":271,"references":271,"seo":277,"seoDescription":278,"seoTitle":271,"sitemap":279,"stem":282,"tags":283,"type":289,"__hash__":290},"content_en\u002Fposts\u002Fnotes\u002F65840\u002Fmapreducelab.md","6.5840 Lab 1: MapReduce","human-only",{"type":8,"value":9,"toc":244},"minimark",[10,15,19,26,29,33,43,51,74,84,90,105,108,112,117,120,124,129,132,142,145,151,154,158,161,167,170,173,176,182,185,189,192,195,201,204,207,213,216,219,225,228,232,235,241],[11,12,14],"h3",{"id":13},"introduction","Introduction",[16,17,18],"p",{},"Lab 1 is about implementing a MapReduce system. There are essentially two parts: the master program and the worker program. This lab is quite the early hurdle. You need to be comfortable with RPC and concurrency in Go, and you need a good grasp of the entire MapReduce workflow. My little trick is to stare at this diagram from the paper, then reread the explanation of the flow beneath it, over and over:",[16,20,21],{},[22,23],"img",{"alt":24,"src":25},"MapReduce execution flow","https:\u002F\u002Fblog-img.774352199.xyz\u002F2025\u002F6f7e7839e6f09e0d8193d530920a6f7e.jpg",[16,27,28],{},"I implemented two versions of this lab, differing mainly in how they handle concurrency. The first used mutexes; I later refactored it into a channel-based version without explicit locks. The latter is more elegant, so that's the version I'll focus on here.",[11,30,32],{"id":31},"understanding-the-lab","Understanding the Lab",[16,34,35,36,42],{},"Before starting, make sure you understand the assignment. The instructions are at ",[37,38,39],"a",{"href":39,"rel":40},"https:\u002F\u002Fpdos.csail.mit.edu\u002F6.824\u002Flabs\u002Flab-mr.html",[41],"nofollow",". The lab is mainly intended for Linux, since processes communicate over Unix sockets. macOS should work in principle, though I've heard it can have a few issues.",[16,44,45,46,50],{},"The starter code includes a single-threaded, sequential MapReduce implementation at ",[47,48,49],"code",{"code":49},"src\u002Fmain\u002Fmrsequential.go",". It's worth reading first to understand the overall flow. You can also copy some of its data-processing logic directly.",[16,52,53,54,57,58,61,62,65,66,69,70,73],{},"The parallel master's entry point is ",[47,55,56],{"code":56},"main\u002Fmrcoordinator.go",", and the worker's is ",[47,59,60],{"code":60},"main\u002Fmrworker.go",". You need to implement three files: ",[47,63,64],{"code":64},"mr\u002Fcoordinator.go",", ",[47,67,68],{"code":68},"mr\u002Fworker.go",", and ",[47,71,72],{"code":72},"mr\u002Frpc.go",". They contain the master's logic, the worker's logic, and the RPC structures used for communication, respectively.",[16,75,76,77,79,80],{},"mrcoordinator calls MakeCoordinator in ",[47,78,64],{"code":64}," to construct the master and start listening on a socket. Once that returns, the main goroutine repeatedly calls Coordinator.Done to check whether the entire MapReduce job has finished, and exits only when it has. MakeCoordinator therefore must not block indefinitely, or the subsequent checks will never run. ",[81,82,83],"strong",{},"Start listeners and similar background work in new goroutines.",[16,85,86,87,89],{},"mrworker is simpler. Its single main goroutine calls Worker in ",[47,88,68],{"code":68},", so you can put the processing there. A single goroutine is generally enough for the worker.",[16,91,92,93,96,97,100,101,104],{},"The test script, ",[47,94,95],{"code":95},"src\u002Fmain\u002Ftest-mr.sh",", runs two existing MapReduce programs, wc and indexer, on your framework and compares their results with the sequential implementation. It also checks that the results remain correct when the same Map or Reduce task runs concurrently, or when a worker crashes during execution. It usually starts one master process and three worker processes. If something goes wrong and a run won't exit, use ",[47,98,99],{"code":99},"ps -A"," to find the mrcoordinator PID and kill it. A simple ",[47,102,103],{"code":103},"ctrl + c"," may leave processes behind and interfere with later tests.",[16,106,107],{},"Finally, read the lab instructions a few more times.",[11,109,111],{"id":110},"implementation-approach","Implementation Approach",[113,114,116],"h4",{"id":115},"overall-flow","Overall Flow",[16,118,119],{},"The workers first finish all map tasks, producing intermediate files named “mr-X-Y,” where X is the map task ID and Y is the corresponding reduce task ID. Each reduce task then gathers all files whose Y matches its ID, reads them, performs the reduction, and writes its result to “mr-out-Y.”",[113,121,123],{"id":122},"implementing-the-master","Implementing the Master",[125,126,128],"h5",{"id":127},"working-without-explicit-locks","Working Without Explicit Locks",[16,130,131],{},"To avoid data races without explicit locks, all operations on the main data structures need to happen in a single goroutine. I'll call it the scheduler goroutine. When a worker makes an RPC request to the master, perhaps to ask for a task or report completion, the master handles the request in an automatically created goroutine. Since access to the main data structures is centralized, that RPC goroutine must ask the scheduler goroutine to perform the operation through a channel. There are several kinds of messages between workers and the master, so the scheduler needs to handle several channels at once. Go's select statement is useful here:",[133,134,140],"pre",{"className":135,"code":137,"language":138,"meta":139},[136],"language-go","\u002F\u002F 只在这个 goroutine 中操作结构\nfunc (c *Coordinator) schedule() {\n    for {\n        select {\n        case msg := \u003C-c.getTaskChan:\n            c.getTaskHandler(msg)\n        case msg := \u003C-c.doneTaskChan:\n            c.doneTaskHandler(msg)\n        case msg := \u003C-c.timeoutChan:\n            c.timeoutHandler(msg)\n        case msg := \u003C-c.doneCheckChan:\n            c.doneCheckHandler(msg)\n        }\n    }\n}\n","go","",[47,141,137],{"__ignoreMap":139},[16,143,144],{},"Suppose a worker needs a task and calls the master's GetTask. The handler looks like this:",[133,146,149],{"className":147,"code":148,"language":138,"meta":139},[136],"func (c *Coordinator) GetTask(_ *GetTaskReq, resp *GetTaskResp) error {\n    msg := GetTaskMsg{\n        resp: resp,\n        ok:   make(chan struct{}),\n    }\n    c.getTaskChan \u003C- msg\n    \u003C-msg.ok\n    return nil\n}\n",[47,150,148],{"__ignoreMap":139},[16,152,153],{},"The message sent to getTaskChan contains resp and a chan struct{}; getTask needs no request parameters. The scheduler uses that channel to tell the RPC goroutine that processing is complete. Once it sends a struct{} to msg.ok, the RPC goroutine can return.",[125,155,157],{"id":156},"coordinator","Coordinator",[16,159,160],{},"Here is the full Coordinator structure:",[133,162,165],{"className":163,"code":164,"language":138,"meta":139},[136],"type Coordinator struct {\n    nMap    int\n    nReduce int\n    phase   TaskPhase\n    allDone bool\n \n    taskTimeOut map[int]time.Time\n    tasks       []*Task\n \n    getTaskChan   chan GetTaskMsg\n    doneTaskChan  chan DoneTaskMsg\n    doneCheckChan chan DoneCheckMsg\n    timeoutChan   chan TimeoutMsg\n}\n",[47,166,164],{"__ignoreMap":139},[16,168,169],{},"phase records the current execution phase. Because reduce tasks can only begin once all map tasks have finished, TaskPhase has Map and Reduce phases. The tasks slice contains only the tasks for the current phase.",[16,171,172],{},"taskTimeOut records the start times of tasks currently running. A goroutine periodically scans this map for tasks that have run for more than ten seconds, treats them as timed out, and resets them to the unstarted state so they can be scheduled again. The scan must also go through the scheduler goroutine, of course. The timeout map contains only running tasks from the current phase and is cleared when phases change.",[16,174,175],{},"The tasks slice stores every Task in the current phase, along with its state:",[133,177,180],{"className":178,"code":179,"language":138,"meta":139},[136],"type ReduceTask struct {\n    NMap int\n}\n \ntype MapTask struct {\n    FileName string\n    NReduce  int\n}\n \ntype TaskStatus int\n \nvar (\n    TaskStatus_Idle     TaskStatus = 0\n    TaskStatus_Running  TaskStatus = 1\n    TaskStatus_Finished TaskStatus = 2\n)\n \ntype Task struct {\n    TaskId     int\n    MapTask    MapTask\n    ReduceTask ReduceTask\n    TaskStatus TaskStatus\n}\n",[47,181,179],{"__ignoreMap":139},[16,183,184],{},"There are three task states: idle, running, and finished. Both MapTask and ReduceTask are stored in the same structure, even though only one is needed; the current phase determines which one to use.",[125,186,188],{"id":187},"handling-operations","Handling Operations",[16,190,191],{},"The channels in Coordinator correspond to four kinds of operations that need to communicate with the scheduler goroutine.",[16,193,194],{},"When a worker requests a task, it can receive one of four task types:",[133,196,199],{"className":197,"code":198,"language":138,"meta":139},[136],"type TaskType int\n \nvar (\n    TaskType_Map    TaskType = 0\n    TaskType_Reduce TaskType = 1\n    TaskType_Wait   TaskType = 2\n    TaskType_Exit   TaskType = 3\n)\n",[47,200,198],{"__ignoreMap":139},[16,202,203],{},"The master first walks through tasks looking for an unstarted task, then returns a Map or Reduce task according to the current phase. If there are no idle tasks, there are two cases: in the Map phase, return TaskType_Wait and ask the worker to wait, since Reduce work still follows; in the Reduce phase, all tasks are now complete, so return TaskType_Exit and ask the worker to exit.",[16,205,206],{},"When a worker finishes, it notifies the master, including the task type and task ID. The master ignores tasks from a different phase, finds the task by taskId, marks it as finished regardless of its current state, and removes its timeout entry.",[133,208,211],{"className":209,"code":210,"language":138,"meta":139},[136],"func (c *Coordinator) doneTaskHandler(msg DoneTaskMsg) {\n    req := msg.req\n    if req.TaskType == TaskType_Map && c.phase == TaskPhase_Reduce {\n        \u002F\u002F 提交非当前阶段的任务，直接返回\n        msg.ok \u003C- struct{}{}\n        return\n    }\n    for _, task := range c.tasks {\n        if task.TaskId == req.TaskId {\n            \u002F\u002F 无论当前状态，直接改为完成\n            task.TaskStatus = TaskStatus_Finished\n            break\n        }\n    }\n    \u002F\u002F 删除 timeout 结构\n    delete(c.taskTimeOut, req.TaskId)\n    allDone := true\n    for _, task := range c.tasks {\n        if task.TaskStatus != TaskStatus_Finished {\n            allDone = false\n            break\n        }\n    }\n    if allDone {\n        if c.phase == TaskPhase_Map {\n            c.initReducePhase()\n        } else {\n            c.allDone = true\n        }\n    }\n    msg.ok \u003C- struct{}{}\n}\n",[47,212,210],{"__ignoreMap":139},[16,214,215],{},"If all tasks have finished in the Reduce phase, the handler also sets the allDone flag.",[16,217,218],{},"During initialization, Coordinator starts a goroutine that asks the scheduler once a second to check timeoutMap for timed-out tasks. Any such task is reset to the unstarted state so it can be assigned the next time a worker requests work.",[133,220,223],{"className":221,"code":222,"language":138,"meta":139},[136],"func (c *Coordinator) timeoutHandler(msg TimeoutMsg) {\n    now := time.Now()\n    for taskId, start := range c.taskTimeOut {\n        if now.Sub(start).Seconds() > 10 {\n            for _, task := range c.tasks {\n                if taskId == task.TaskId {\n                    if task.TaskStatus != TaskStatus_Finished {\n                        task.TaskStatus = TaskStatus_Idle\n                    }\n                    break\n                }\n            }\n            delete(c.taskTimeOut, taskId)\n            break\n        }\n    }\n    msg.ok \u003C- struct{}{}\n    return\n}\n",[47,224,222],{"__ignoreMap":139},[16,226,227],{},"The last operation is the completion check. The main thread calls Coordinator.Done, which asks the scheduler goroutine to check the allDone flag.",[113,229,231],{"id":230},"worker","Worker",[16,233,234],{},"The worker has just one goroutine, which repeatedly fetches tasks from the master and executes them:",[133,236,239],{"className":237,"code":238,"language":138,"meta":139},[136],"func Worker(mapf func(string, string) []KeyValue,\n    reducef func(string, []string) string) {\n    for {\n        resp := callGetTask()\n        switch resp.TaskType {\n        case TaskType_Map:\n            handleMapTask(resp.Task, mapf)\n        case TaskType_Reduce:\n            handleReduceTask(resp.Task, reducef)\n        case TaskType_Wait:\n            time.Sleep(time.Second)\n        case TaskType_Exit:\n            return\n        }\n    }\n}\n",[47,240,238],{"__ignoreMap":139},[16,242,243],{},"For the map and reduce operations, refer to the sequential single-threaded implementation. One thing to watch out for: multiple processes may run the same task simultaneously, and a process may crash halfway through. Files left behind can cause problems when another worker reruns the task. Write output to a temporary file created with ioutil.TempFile, then rename it to the target filename with os.Rename after the write completes. That ensures the final output file is always complete.",{"title":139,"searchDepth":245,"depth":245,"links":246},4,[247,249,250],{"id":13,"depth":248,"text":14},3,{"id":31,"depth":248,"text":32},{"id":110,"depth":248,"text":111,"children":251},[252,253,259],{"id":115,"depth":245,"text":116},{"id":122,"depth":245,"text":123,"children":254},[255,257,258],{"id":127,"depth":256,"text":128},5,{"id":156,"depth":256,"text":157},{"id":187,"depth":256,"text":188},{"id":230,"depth":245,"text":231},[261],"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.",false,"md","https:\u002F\u002Fblog-img.774352199.xyz\u002FibVwPJ.webp",{"slots":268},{},true,"\u002Fnotes\u002F65840\u002Fmapreducelab",null,{"text":273,"minutes":274,"time":275,"words":276},"8 min read",7.21,432600,1442,{"title":5,"description":263},"Implement MIT’s MapReduce lab in Go with a channel-based coordinator, RPC task assignment, phase transitions, timeout retries, and atomic output renaming.",{"loc":270,"images":280},[281],{"loc":25},"posts\u002Fnotes\u002F65840\u002Fmapreducelab",[284,285,286,287,288],"MIT 6.5840","MapReduce","Go","RPC","Concurrent programming","tech","wTEGcDV45s1tlAKmAZHCEJngvZB_no7mNgtwLPAG-7g",[292,310,327,345,362,381,399,417,435,451,467,482,496,512,529,546,561,578,592,608,625,642,658,675,691,710,726,743,761,775,793,797,813,829,843,860,874,889,904,918,932,946,961,975,986],{"categories":293,"date":295,"description":296,"image":297,"path":298,"readingTime":299,"recommend":271,"tags":304,"title":309,"type":289},[294],"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":300,"minutes":301,"time":302,"words":303},"4 min read",3.08,184800,616,[305,306,307,308],"Chronic gastritis","Medical care experiences","Gastroscopy","Health journal","My Journey with Chronic Gastritis",{"categories":311,"date":312,"description":313,"image":314,"path":315,"readingTime":316,"recommend":271,"tags":321,"title":326,"type":289},[294],"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":317,"minutes":318,"time":319,"words":320},"9 min read",8.635,518100,1727,[322,323,324,325],"The Three-Body Problem","Liu Cixin","Science fiction","Reading notes","The “Majority” in The Three-Body Problem",{"categories":328,"date":329,"description":330,"image":331,"path":332,"readingTime":333,"recommend":271,"tags":338,"title":344,"type":289},[294],"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":334,"minutes":335,"time":336,"words":337},"1 min read",0.15,9000,30,[339,340,341,342,343],"Annual planning","Learning Japanese","SICP","TAPL","Operating systems","My Learning Plan for 2024",{"categories":346,"date":347,"description":348,"image":349,"path":350,"readingTime":351,"recommend":271,"tags":356,"title":361,"type":289},[294],"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":352,"minutes":353,"time":354,"words":355},"10 min read",9.74,584400,1948,[357,358,359,360],"ByteDance","Software engineering careers","Career retrospective","Mental health","Working at ByteDance for Three Years and Staying Somewhat Sane Is Not Entirely Impossible",{"categories":363,"date":365,"description":366,"image":367,"path":368,"readingTime":369,"recommend":271,"tags":374,"title":380,"type":289},[364],"fiddling","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":370,"minutes":371,"time":372,"words":373},"2 min read",1.785,107100,357,[375,376,377,378,379],"Astro","Google Analytics","Google Tag Manager","Partytown","Web analytics","Adding Google Analytics to Astro with Tag Manager",{"categories":382,"date":383,"description":384,"image":385,"path":386,"readingTime":387,"recommend":392,"tags":393,"title":398,"type":289},[364],"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":388,"minutes":389,"time":390,"words":391},"15 min read",14.275,856500,2855,2,[394,395,396,397],"Programming language design","Type systems","Compiler design","RISC-V","Some Thoughts on Programming Languages",{"categories":400,"date":401,"description":402,"image":403,"path":404,"readingTime":405,"recommend":245,"tags":410,"title":416,"type":289},[364],"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":406,"minutes":407,"time":408,"words":409},"5 min read",4.865,291900,973,[411,412,413,414,415],"Tailscale","mihomo","Site-to-site networking","Transparent proxy","Home networking","Connecting My Shanghai and Hangzhou Networks",{"categories":418,"date":419,"description":420,"image":421,"path":422,"readingTime":423,"recommend":271,"tags":428,"title":434,"type":289},[364],"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":424,"minutes":425,"time":426,"words":427},"6 min read",5.295,317700,1059,[429,430,431,432,433],"CSAPP","WSL2","Linux","GDB","Lab environment","Setting Up the CSAPP Lab Environment",{"categories":436,"date":437,"description":438,"image":439,"path":440,"readingTime":441,"recommend":271,"tags":446,"title":450,"type":289},[364],"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":442,"minutes":443,"time":444,"words":445},"12 min read",11.79,707400,2358,[447,448,412,449,414],"Debian","Side router","AdGuard Home","Using Debian as a Side Router",{"categories":452,"date":453,"description":454,"image":455,"path":456,"readingTime":457,"recommend":271,"tags":461,"title":466,"type":289},[364],"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":352,"minutes":458,"time":459,"words":460},9.395,563700,1879,[462,463,414,464,465],"FakeIP","sing-box","Policy-based routing","Traffic routing","Routing Transparent Proxy Traffic with FakeIP",{"categories":468,"date":469,"description":470,"image":471,"path":472,"readingTime":473,"recommend":271,"tags":477,"title":481,"type":289},[364],"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":300,"minutes":474,"time":475,"words":476},3.03,181800,606,[448,478,479,480],"Port forwarding","NAT","Network troubleshooting","Fixing Port Forwarding with a Side Router",{"categories":483,"date":484,"description":485,"image":486,"path":487,"readingTime":488,"recommend":271,"tags":492,"title":495,"type":289},[364],"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.","https:\u002F\u002Fblog-img.774352199.xyz\u002FxB1Ni5.webp","\u002Ffiddling\u002Fgo-os",{"text":273,"minutes":489,"time":490,"words":491},7.29,437400,1458,[286,397,343,493,494],"Bare-metal programming","Runtime","A Project That Failed: Seven Not-So-Happy Days over Chinese New Year",{"categories":497,"date":498,"description":499,"image":500,"path":501,"readingTime":502,"recommend":271,"tags":507,"title":511,"type":289},[364],"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,[286,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":271,"tags":522,"title":528,"type":289},[364],"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":256,"tags":539,"title":545,"type":289},[364],"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":300,"minutes":536,"time":537,"words":538},3.305,198300,661,[540,541,542,543,544],"macOS 26","iPadOS 26","Liquid Glass","Apple Intelligence","Operating system impressions","Trying Out macOS 26 and iPadOS 26",{"categories":547,"date":548,"description":549,"image":550,"path":551,"readingTime":552,"recommend":271,"tags":556,"title":560,"type":289},[364],"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":424,"minutes":553,"time":554,"words":555},5.1,306000,1020,[557,543,558,559],"macOS 27","ChatGPT","Mainland China Mac","Getting Apple Intelligence Working on a China-Market Mac: Region Changes and Extracting ChatGPT",{"categories":562,"date":563,"description":564,"image":565,"path":566,"readingTime":567,"recommend":271,"tags":571,"title":577,"type":289},[364],"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":424,"minutes":568,"time":569,"words":570},5.76,345600,1152,[572,573,574,575,576],"MoonTV","LunaTV","Vibe Coding","Cursor","AI-assisted development","MoonTV: An Experiment in Vibe Coding",{"categories":579,"date":580,"description":581,"image":582,"path":583,"readingTime":584,"recommend":271,"tags":588,"title":591,"type":289},[364],"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":300,"minutes":585,"time":586,"words":587},3.805,228300,761,[589,590,464,465],"BGP","IP address database","More Accurate Routing for Chinese and Overseas IPs with BGP",{"categories":593,"date":594,"description":595,"image":596,"path":597,"readingTime":598,"recommend":271,"tags":602,"title":607,"type":289},[364],"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":406,"minutes":599,"time":600,"words":601},4.68,280800,936,[603,604,605,606],"Microsoft Flight Simulator 2024","Thrustmaster TCA","PICO VR","Flight simulation","Adventures with Microsoft Flight Simulator 2024",{"categories":609,"date":610,"description":611,"image":612,"path":613,"readingTime":614,"recommend":271,"tags":618,"title":624,"type":289},[364],"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":273,"minutes":615,"time":616,"words":617},7.61,456600,1522,[619,620,621,622,623],"Android","OPPO","iOS","Smartphone impressions","Ecosystem migration","One Month After Switching to Android",{"categories":626,"date":627,"description":628,"image":629,"path":630,"readingTime":631,"recommend":271,"tags":635,"title":641,"type":289},[364],"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":424,"minutes":632,"time":633,"words":634},5.735,344100,1147,[636,637,638,639,640],"TREK","Docker Compose","Dockge","VPS","Self-hosting","One TREK, Twenty Stacks",{"categories":643,"date":644,"description":645,"image":646,"path":647,"readingTime":648,"recommend":271,"tags":653,"title":657,"type":289},[364],"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":649,"minutes":650,"time":651,"words":652},"7 min read",6.47,388200,1294,[654,655,412,656,414,465],"OPNsense","FreeBSD","tun2socks","Transparent Proxying and Traffic Routing with OPNsense",{"categories":659,"date":660,"description":661,"image":662,"path":663,"readingTime":664,"recommend":248,"tags":668,"title":674,"type":289},[364],"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":273,"minutes":665,"time":666,"words":667},7.475,448500,1495,[669,670,671,672,673],"Parsing","GLR","Symbol table","Scope","Disambiguation","Resolving Type Name and Variable Name Ambiguity in Parsing",{"categories":676,"date":677,"description":678,"image":679,"path":680,"readingTime":681,"recommend":271,"tags":685,"title":690,"type":289},[364],"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":370,"minutes":682,"time":683,"words":684},1.92,115200,384,[397,686,687,688,689],"Spike","riscv-pk","Cross-compilation","Toolchain","Installing the RISC-V Toolchain and Emulator",{"categories":692,"date":693,"description":694,"image":695,"path":696,"readingTime":697,"recommend":701,"tags":702,"title":709,"type":289},[364],"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":273,"minutes":698,"time":699,"words":700},7.345,440700,1469,7,[703,704,705,706,707,708],"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":711,"date":712,"description":713,"image":714,"path":715,"readingTime":716,"recommend":271,"tags":720,"title":725,"type":289},[364],"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":442,"minutes":717,"time":718,"words":719},11.885,713100,2377,[721,722,723,724],"GFW","DNS poisoning","TCP","Internet censorship","How the Great Firewall Works",{"categories":727,"date":728,"description":729,"image":730,"path":731,"readingTime":732,"recommend":271,"tags":736,"title":742,"type":289},[364],"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":733,"time":734,"words":735},2.305,138300,461,[737,738,739,740,741],"Java","javac","String concatenation","Constant propagation","Bytecode","How Java’s this Keyword Can Prevent Compile-Time Constant Propagation",{"categories":744,"date":745,"description":746,"image":747,"path":748,"readingTime":749,"recommend":271,"tags":754,"title":760,"type":289},[364],"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":750,"minutes":751,"time":752,"words":753},"19 min read",18.96,1137600,3792,[755,756,757,758,759],"VitePress","Vue","Cloudflare Workers","Cloudflare KV","Microblogging","Adding a Microblog to VitePress",{"categories":762,"date":763,"description":764,"image":765,"path":766,"readingTime":767,"recommend":271,"tags":771,"title":774,"type":289},[364],"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":768,"time":769,"words":770},2.34,140400,468,[772,773,639,464,465],"Cloudflare WARP","IPv6","Routing Selected VPS Traffic Through WARP over IPv6",{"categories":776,"date":777,"description":778,"image":779,"path":780,"readingTime":781,"recommend":785,"tags":786,"title":792,"type":289},[364],"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":406,"minutes":782,"time":783,"words":784},4.545,272700,909,6,[787,788,789,790,791],"Xiaomi 17","Bootloader","Android Root","Firmware flashing","Root hiding","Making the Xiaomi 17 My Daily Driver: Unlocking, Flashing, Rooting, and Hiding Root",{"categories":794,"date":262,"description":263,"image":266,"path":270,"readingTime":795,"recommend":271,"tags":796,"title":5,"type":289},[261],{"text":273,"minutes":274,"time":275,"words":276},[284,285,286,287,288],{"categories":798,"date":799,"description":800,"image":801,"path":802,"readingTime":803,"recommend":271,"tags":807,"title":812,"type":289},[261],"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":406,"minutes":804,"time":805,"words":806},4.12,247200,824,[285,808,809,810,811],"Distributed systems","Paper notes","Parallel computing","Fault tolerance","Reading the MapReduce Paper",{"categories":814,"date":815,"description":816,"image":817,"path":818,"readingTime":819,"recommend":271,"tags":824,"title":828,"type":289},[261],"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":820,"minutes":821,"time":822,"words":823},"13 min read",12.235,734100,2447,[284,825,286,826,827],"Raft","Leader election","Distributed consensus","6.5840 Lab 2A: Leader Election",{"categories":830,"date":831,"description":832,"image":833,"path":834,"readingTime":835,"recommend":271,"tags":840,"title":842,"type":289},[261],"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":836,"minutes":837,"time":838,"words":839},"16 min read",15.98,958800,3196,[825,827,841,809],"Log replication","Reading the Raft Paper",{"categories":844,"date":846,"description":847,"image":848,"path":849,"readingTime":850,"recommend":854,"tags":855,"title":859,"type":289},[845],"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":406,"minutes":851,"time":852,"words":853},4.15,249000,830,1,[856,737,857,858],"MYDB","Database implementation","Database architecture","MYDB 0. Project Structure and a Few Things I Had to Say",{"categories":861,"date":862,"description":863,"image":864,"path":865,"readingTime":866,"recommend":271,"tags":870,"title":873,"type":289},[845],"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":406,"minutes":867,"time":868,"words":869},4.755,285300,951,[856,737,871,872],"Transaction management","XID","MYDB 1. Starting with the Transaction Manager",{"categories":875,"date":876,"description":877,"image":878,"path":879,"readingTime":880,"recommend":271,"tags":884,"title":888,"type":289},[845],"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":406,"minutes":881,"time":882,"words":883},4.305,258300,861,[856,737,885,886,887],"Socket","Client-server architecture","Communication protocol","MYDB 10. Implementing the Server, Client, and Wire Protocol",{"categories":890,"date":891,"description":892,"image":893,"path":894,"readingTime":895,"recommend":271,"tags":899,"title":903,"type":289},[845],"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":424,"minutes":896,"time":897,"words":898},5.725,343500,1145,[856,737,900,901,902],"Reference counting","Cache design","Shared memory","MYDB 2. A Reference-Counted Cache Framework and Shared Byte Arrays",{"categories":905,"date":906,"description":907,"image":908,"path":909,"readingTime":910,"recommend":271,"tags":914,"title":917,"type":289},[845],"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":406,"minutes":911,"time":912,"words":913},4.7,282000,940,[856,737,915,916],"Data pages","Cache management","MYDB 3. Caching and Managing Data Pages",{"categories":919,"date":920,"description":921,"image":922,"path":923,"readingTime":924,"recommend":271,"tags":928,"title":931,"type":289},[845],"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":273,"minutes":925,"time":926,"words":927},7.885,473100,1577,[856,737,929,930],"Database logging","Crash recovery","MYDB 4. Log Files and Recovery Strategies",{"categories":933,"date":934,"description":935,"image":936,"path":937,"readingTime":938,"recommend":271,"tags":942,"title":945,"type":289},[845],"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":649,"minutes":939,"time":940,"words":941},6.37,382200,1274,[856,737,943,944],"Page index","Data management","MYDB 5. The Page Index and the Data Manager",{"categories":947,"date":948,"description":949,"image":950,"path":951,"readingTime":952,"recommend":271,"tags":956,"title":960,"type":289},[845],"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":317,"minutes":953,"time":954,"words":955},8.64,518400,1728,[856,737,957,958,959],"MVCC","Transaction isolation","Two-phase locking","MYDB 6. Record Versions and Transaction Isolation",{"categories":962,"date":963,"description":964,"image":965,"path":966,"readingTime":967,"recommend":271,"tags":971,"title":974,"type":289},[845],"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":273,"minutes":968,"time":969,"words":970},7.265,435900,1453,[856,737,972,973],"Deadlock detection","Version management","MYDB 7. Deadlock Detection and the Version Manager",{"categories":976,"date":977,"description":978,"image":979,"path":980,"readingTime":981,"recommend":271,"tags":982,"title":985,"type":289},[845],"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":406,"minutes":851,"time":852,"words":853},[856,737,983,984],"B+ tree","Database indexing","MYDB 8. Index Management",{"categories":987,"date":988,"description":989,"image":990,"path":991,"readingTime":992,"recommend":271,"tags":996,"title":999,"type":289},[845],"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":424,"minutes":993,"time":994,"words":995},5.035,302100,1007,[856,737,997,998],"SQL parsing","Table management","MYDB 9. Field and Table Management",1789914052882]