[{"data":1,"prerenderedAt":1116},["ShallowReactive",2],{"content:\u002Fen\u002Ffiddling\u002Fparser-type-variable-ambiguity":3,"series:content_en":406},{"id":4,"title":5,"authorship":6,"body":7,"categories":377,"date":379,"description":380,"draft":381,"extension":382,"image":383,"meta":384,"navigation":386,"path":387,"permalink":388,"published":388,"readingTime":389,"recommend":373,"references":388,"seo":394,"seoDescription":395,"seoTitle":388,"sitemap":396,"stem":397,"tags":398,"type":404,"__hash__":405},"content_en\u002Fposts\u002Ffiddling\u002Fparser-type-variable-ambiguity.md","Resolving Type Name and Variable Name Ambiguity in Parsing","human-only",{"type":8,"value":9,"toc":369},"minimark",[10,15,28,31,41,56,60,63,66,95,101,109,115,140,152,155,158,161,165,168,176,183,186,192,195,205,215,218,243,246,265,282,297,301,304,310,313,319,331,342,351,354,360,363],[11,12,14],"h3",{"id":13},"introduction","Introduction",[16,17,18,19,23,24,27],"p",{},"Without a symbol table during parsing, user-defined type names (typedef) are hard to distinguish from ordinary variable names. Inside a function, ",[20,21,22],"code",{"code":22},"a*b;"," can mean multiply a by b and discard the result, or declare b with type ",[20,25,26],{"code":26},"a*",".",[16,29,30],{},"There are also these grammar rules:",[32,33,38],"pre",{"className":34,"code":36,"language":37},[35],"language-text","declaration := declaration_specifiers SEMICOLON\ndeclaration_specifiers := type_specifier declaration_specifiers\ntype_specifier := INT\ntype_specifier := typedef_name\ntypedef_name := IDENTIFIER\n","text",[20,39,36],{"__ignoreMap":40},"",[16,42,43,44,47,48,51,52,55],{},"Rule 1 is mostly used for forward declarations of structs that require no identifier. For example, ",[20,45,46],{"code":46},"struct Node;"," forward-declares the type ",[20,49,50],{"code":50},"struct Node",". But this rule also allows something like ",[20,53,54],{"code":54},"int a;"," to be reduced by rule 1, treating a as a user-defined type name instead of a variable name. Declarations without initializers are common, so a source file can produce many ASTs satisfying the grammar. A symbol table in semantic analysis can resolve this, but inexpensive checks during parsing can reduce the number of ASTs semantic analysis must handle.",[11,57,59],{"id":58},"approach","Approach",[16,61,62],{},"To resolve type-name\u002Fvariable-name ambiguity, we can prune incorrect branches during or after GLR execution using a lightweight symbol table. At minimum, it must track variable names and user-defined type names. Since names in inner scopes can shadow those in outer scopes, it must also track scope.",[16,64,65],{},"The tasks are straightforward:",[67,68,69,73,76,87],"ol",{},[70,71,72],"li",{},"Maintain a symbol table collecting type definitions and variable declarations.",[70,74,75],{},"When adding a symbol, check for a variable declaration or type definition with the same name in the same scope.",[70,77,78,79,82,83,86],{},"For every node reduced by ",[20,80,81],{"code":81},"primary_expression := IDENTIFIER",", verify that ",[20,84,85],{"code":85},"IDENTIFIER"," is a declared, unshadowed variable name.",[70,88,78,89,82,92,94],{},[20,90,91],{"code":91},"typedef_name := IDENTIFIER",[20,93,85],{"code":85}," is a declared, unshadowed user-defined type name.",[16,96,97,98,100],{},"Take the classic ",[20,99,22],{"code":22}," example:",[32,102,107],{"className":103,"code":105,"language":106,"meta":40},[104],"language-c","\u002F\u002F 例 1\ntypedef int a;\nfunc test_func()\n{\n\ta*b;\n}\n","c",[20,108,105],{"__ignoreMap":40},[32,110,113],{"className":111,"code":112,"language":106,"meta":40},[104],"\u002F\u002F 例 2\ntypedef int a;\nfunc test_func()\n{\n\tint a;\n\ta*b;\n}\n",[20,114,112],{"__ignoreMap":40},[16,116,117,118,120,121,124,125,127,128,130,131,134,135,127,137,139],{},"Example 1: At ",[20,119,22],{"code":22},", scope 1 (outermost) contains a user-defined type a, while scope 2 (the function) has no symbols. In the AST interpreting the statement as a declaration of variable ",[20,122,123],{"code":123},"b"," with type ",[20,126,26],{"code":26},", a is reduced using ",[20,129,91],{"code":91},". The symbol table confirms that a is a user-defined type declared in scope 1, so we keep this AST. In the AST interpreting it as variable ",[20,132,133],{"code":133},"a"," multiplied by variable ",[20,136,123],{"code":123},[20,138,81],{"code":81},". There is no variable a in the table, so we discard that AST.",[16,141,142,143,145,146,148,149,151],{},"Example 2: At ",[20,144,22],{"code":22},", scope 1 contains a user-defined type a and scope 2 contains a variable a, which shadows the type. In the declaration AST, a is reduced using ",[20,147,91],{"code":91},", but the table shows that a in this scope is a variable, not a user-defined type. We discard this AST. In the multiplication AST, a is reduced using ",[20,150,81],{"code":81},"; the table confirms that a is a variable name, so we keep it.",[16,153,154],{},"Unlike a full symbol table, this lightweight version does not check duplicate declarations of variables of the same kind within a scope, although it can check duplicate user-defined type names. Forward declarations make multiple declarations of the same variable legal, while only one may include initialization. Distinguishing initialized declarations during parsing is relatively expensive, so I recommend leaving that to semantic analysis. Type checking is also deferred for cost reasons.",[16,156,157],{},"Maintaining the lightweight table during GLR execution makes function parameters and for-loop declarations difficult. Their variables actually belong to an inner scope whose boundaries do not perfectly coincide with braces. A function definition can only be reduced after its opening and closing braces have been shifted, so scopes cannot simply be handled when shifting braces: several symbols on the current symbol stack must be considered together. The underlying reason is that GLR constructs an AST bottom-up, building the root step by step from leaves. Lower nodes are handled first, without awareness of their surrounding context.",[16,159,160],{},"Checking and rejecting individual ASTs by traversing the AST forest after GLR finishes is much simpler. It cannot prune during execution and therefore costs more time and memory, but its advantages are simplicity, simplicity, and simplicity. In practice, both approaches can be combined. Pruning during execution is cheap, and every successful pruning reduces the number of ASTs left to check afterward. Since the post-execution checks can always resolve this ambiguity, pruning during execution must follow the rule: better to let a bad branch through than reject a good one.",[11,162,164],{"id":163},"during-ast-construction","During AST construction",[16,166,167],{},"When shifting symbols or performing reductions, we can store information in nodes and propagate it upward so that a later top-down traversal can retrieve it quickly. For this ambiguity, I add two markers:",[32,169,174],{"className":170,"code":172,"language":173,"meta":40},[171],"language-go","type GLRLabel struct {\n\t\u002F\u002F Declaration 使用，规约出 Declaration 后消除\n\tTypeDef      bool     \u002F\u002F 是否是 TypeDef\n\tDeclaratorID []*Token \u002F\u002F 包含的 Identifier\n}\n","go",[20,175,172],{"__ignoreMap":40},[16,177,178,179,182],{},"typedef marks whether the declaration defines a type. If the marker is absent when a declaration is finally reduced, it is an ordinary variable declaration. DeclaratorID contains the symbols defined by the declaration; for a type definition, it contains the user-defined type names. Since function_definition handles the function name with a declarator much like declaration does (",[20,180,181],{"code":181},"function_definition := declaration_specifiers declarator compound_statement","), DeclaratorID also includes function names.",[16,184,185],{},"During AST construction, these markers propagate from child nodes to parent nodes:",[32,187,190],{"className":188,"code":189,"language":173,"meta":40},[171],"gslice.ForEach(children, func(child *AstNode) {\n    if child.TypeDef {\n        parent.TypeDef = true\n    }\n    parent.DeclaratorID = append(parent.DeclaratorID, child.DeclaratorID...)\n})\n",[20,191,189],{"__ignoreMap":40},[16,193,194],{},"When should we set them?",[16,196,197,198,201,202,27],{},"typedef is straightforward: set the current node's ",[20,199,200],{"code":200},"typedef"," to true when reducing ",[20,203,204],{"code":204},"storage_class_specifier := TYPEDEF",[16,206,207,208,211,212,27],{},"DeclaratorID is more involved. The basic case is ",[20,209,210],{"code":210},"direct_declarator := IDENTIFIER",". Enumeration constants also require handling ",[20,213,214],{"code":214},"enumeration_constant := IDENTIFIER",[16,216,217],{},"We cannot let these markers propagate upward indefinitely. When later processing a node top-down, we want information belonging to that level, without information from lower levels mixed in. C's scope rules allow information to flow from outer scopes into inner ones, but not the reverse. We therefore clear the markers at certain reductions to stop upward propagation.",[16,219,220,221,224,225,228,229,232,233,236,237,239,240,27],{},"Besides reductions to ",[20,222,223],{"code":223},"declaration"," and ",[20,226,227],{"code":227},"function_definition",", we need special handling when reducing ",[20,230,231],{"code":231},"direct_declarator",". For a rule such as ",[20,234,235],{"code":235},"direct_declarator := direct_declarator LEFT_PARENTHESES parameter_type_list RIGHT_PARENTHESES",", only propagate DeclaratorID from the right-hand side's ",[20,238,231],{"code":231},", avoiding contamination from parameter declarations in ",[20,241,242],{"code":242},"parameter_type_list",[16,244,245],{},"Two checks can be made safely during AST construction:",[67,247,248,251],{},[70,249,250],{},"When a user-defined type is used, check whether it was declared previously. Variable shadowing cannot be checked yet.",[70,252,253,254,257,258,261,262,264],{},"If ",[20,255,256],{"code":256},"declaration_specifiers"," contains a user-defined-type ",[20,259,260],{"code":260},"type_specifier",", it must be the only ",[20,263,260],{"code":260},": a user-defined type is already complete and should not be combined with other type specifiers.",[16,266,267,268,271,272,275,276,278,279,281],{},"For the first check, maintain a stack of user-defined-type scopes during construction. Push a new scope when shifting ",[20,269,270],{"code":270},"{"," and pop the top scope when shifting ",[20,273,274],{"code":274},"}",". When reducing a Declaration, inspect its typedef marker. If set, add all its DeclaratorID entries to the top scope. At a node reduced by ",[20,277,91],{"code":91},", this ",[20,280,85],{"code":85}," should refer to a previously defined type; search from the top of the stack downward.",[16,283,284,285,287,288,290,291,293,294,27],{},"The second check is simple: inspect ",[20,286,256],{"code":256}," when reducing ",[20,289,223],{"code":223},", ",[20,292,227],{"code":227},", and ",[20,295,296],{"code":296},"parameter_declaration",[11,298,300],{"id":299},"after-ast-construction","After AST construction",[16,302,303],{},"The construction-time checks above only consider user-defined types, not variable names, so some errors and ambiguities remain. For example:",[32,305,308],{"className":306,"code":307,"language":106,"meta":40},[104],"typedef int a;\nint main() {\n\tint a;\n\ta c;\t\u002F\u002F 类型 a 已经被变量 a 遮蔽，此处声明不合法\n}\n",[20,309,307],{"__ignoreMap":40},[16,311,312],{},"After construction, we therefore need a somewhat more complete symbol table that records both type names and variable names in each scope:",[32,314,317],{"className":315,"code":316,"language":173,"meta":40},[171],"type ScopeSymbols struct {\n\tTypeNames map[string]*entity.Token\n\tVarNames  map[string]*entity.Token\n}\n",[20,318,316],{"__ignoreMap":40},[16,320,321,322,324,325,327,328,330],{},"As with the construction-time checks, push a scope on ",[20,323,270],{"code":270}," and pop it on ",[20,326,274],{"code":274},". At a ",[20,329,223],{"code":223}," node, add DeclaratorID to the top scope's type names if the typedef marker is present, or to its variable names otherwise. Before adding a variable name, check whether the top scope already contains a type with that name; if so, return an error. Apply the reverse check when adding a type name.",[16,332,333,334,337,338,341],{},"A function definition's name must also enter the symbol table as a variable symbol. Function definitions have the form ",[20,335,336],{"code":336},"function_definition := declaration_specifiers declarator...",", and DeclaratorID in ",[20,339,340],{"code":340},"declarator"," is the function name.",[16,343,344,345,347,348,350],{},"Next, check uses of type and variable names. User-defined types are used only at ",[20,346,91],{"code":91},". Construction-time checks already verified that the type had been defined. The later check must additionally verify that a variable in an inner scope has not shadowed it; if so, return an error. Variable names appear at ",[20,349,81],{"code":81}," and receive similar checks.",[16,352,353],{},"A simple example of checking a variable name:",[32,355,358],{"className":356,"code":357,"language":173,"meta":40},[171],"func (s *symbolStack) CheckVar(token *entity.Token, depth int) error {\n\tfor i := depth; i >= 0; i-- {\n\t\tif previous, ok := s.stack[i].TypeNames[token.Lexeme]; ok {\n\t\t\treturn InvalidSymbolKind(token.SourceStart, previous.SourceStart, token.Lexeme)\n\t\t}\n\t\tif _, ok := s.stack[i].VarNames[token.Lexeme]; ok {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn UndeclaredIdentifier(token.SourceStart, token.Lexeme)\n}\n",[20,359,357],{"__ignoreMap":40},[16,361,362],{},"Function definitions and for loops need special scope handling. Function parameters and the parenthesized part of a for loop belong to the inner scope of the function or loop body, rather than the scope containing the function or loop. Taking a for loop as an example:",[32,364,367],{"className":365,"code":366,"language":173,"meta":40},[171],"currentSymbolStackDepth := s.symbolStack.currentSymbolStackDepth\ns.symbolStack.SwitchScope(currentSymbolStackDepth + 1)\t\u002F\u002F 切换到深层作用域\nfor i := 0; i \u003C len(node.Children)-1; i++ {\n\tif err := s.Chop(node.Children[i]); err != nil {\n\t\treturn err\n\t}\n}\ns.symbolStack.SwitchScope(currentSymbolStackDepth)\t\t\u002F\u002F 切换回当前作用域\nif err := s.Chop(node.Children[len(node.Children)-1]); err != nil {\n\t\u002F\u002F 如果循环体中包含 {，则会自然进入\n\treturn err\n}\ns.symbolStack.EnterScope(currentSymbolStackDepth)\t\t\u002F\u002F 若不存在循环体，则会导致深层作用域无法弹出，这里强行重置一下\n",[20,368,366],{"__ignoreMap":40},{"title":40,"searchDepth":370,"depth":370,"links":371},4,[372,374,375,376],{"id":13,"depth":373,"text":14},3,{"id":58,"depth":373,"text":59},{"id":163,"depth":373,"text":164},{"id":299,"depth":373,"text":300},[378],"fiddling","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.",false,"md","https:\u002F\u002Fblog-img.774352199.xyz\u002F2VKHK9.webp",{"slots":385},{},true,"\u002Ffiddling\u002Fparser-type-variable-ambiguity",null,{"text":390,"minutes":391,"time":392,"words":393},"8 min read",7.475,448500,1495,{"title":5,"description":380},"Resolve C type-name and variable-name ambiguity in GLR parsing with lightweight symbol tables, AST pruning, and scope checks for shadowing and declarations.",{"loc":387},"posts\u002Ffiddling\u002Fparser-type-variable-ambiguity",[399,400,401,402,403],"Parsing","GLR","Symbol table","Scope","Disambiguation","tech","zBe1IJL0KgBNu5WVyFyTBhERajisMwu9lmNzbD4WSG4",[407,425,442,460,477,495,513,531,549,565,581,596,611,627,644,662,677,694,708,724,741,758,774,778,794,813,829,846,864,878,896,913,929,945,959,976,990,1005,1020,1034,1048,1062,1077,1091,1102],{"categories":408,"date":410,"description":411,"image":412,"path":413,"readingTime":414,"recommend":388,"tags":419,"title":424,"type":404},[409],"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":415,"minutes":416,"time":417,"words":418},"4 min read",3.08,184800,616,[420,421,422,423],"Chronic gastritis","Medical care experiences","Gastroscopy","Health journal","My Journey with Chronic Gastritis",{"categories":426,"date":427,"description":428,"image":429,"path":430,"readingTime":431,"recommend":388,"tags":436,"title":441,"type":404},[409],"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":432,"minutes":433,"time":434,"words":435},"9 min read",8.635,518100,1727,[437,438,439,440],"The Three-Body Problem","Liu Cixin","Science fiction","Reading notes","The “Majority” in The Three-Body Problem",{"categories":443,"date":444,"description":445,"image":446,"path":447,"readingTime":448,"recommend":388,"tags":453,"title":459,"type":404},[409],"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":449,"minutes":450,"time":451,"words":452},"1 min read",0.15,9000,30,[454,455,456,457,458],"Annual planning","Learning Japanese","SICP","TAPL","Operating systems","My Learning Plan for 2024",{"categories":461,"date":462,"description":463,"image":464,"path":465,"readingTime":466,"recommend":388,"tags":471,"title":476,"type":404},[409],"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":467,"minutes":468,"time":469,"words":470},"10 min read",9.74,584400,1948,[472,473,474,475],"ByteDance","Software engineering careers","Career retrospective","Mental health","Working at ByteDance for Three Years and Staying Somewhat Sane Is Not Entirely Impossible",{"categories":478,"date":479,"description":480,"image":481,"path":482,"readingTime":483,"recommend":388,"tags":488,"title":494,"type":404},[378],"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":484,"minutes":485,"time":486,"words":487},"2 min read",1.785,107100,357,[489,490,491,492,493],"Astro","Google Analytics","Google Tag Manager","Partytown","Web analytics","Adding Google Analytics to Astro with Tag Manager",{"categories":496,"date":497,"description":498,"image":499,"path":500,"readingTime":501,"recommend":506,"tags":507,"title":512,"type":404},[378],"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":502,"minutes":503,"time":504,"words":505},"15 min read",14.275,856500,2855,2,[508,509,510,511],"Programming language design","Type systems","Compiler design","RISC-V","Some Thoughts on Programming Languages",{"categories":514,"date":515,"description":516,"image":517,"path":518,"readingTime":519,"recommend":370,"tags":524,"title":530,"type":404},[378],"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":520,"minutes":521,"time":522,"words":523},"5 min read",4.865,291900,973,[525,526,527,528,529],"Tailscale","mihomo","Site-to-site networking","Transparent proxy","Home networking","Connecting My Shanghai and Hangzhou Networks",{"categories":532,"date":533,"description":534,"image":535,"path":536,"readingTime":537,"recommend":388,"tags":542,"title":548,"type":404},[378],"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":538,"minutes":539,"time":540,"words":541},"6 min read",5.295,317700,1059,[543,544,545,546,547],"CSAPP","WSL2","Linux","GDB","Lab environment","Setting Up the CSAPP Lab Environment",{"categories":550,"date":551,"description":552,"image":553,"path":554,"readingTime":555,"recommend":388,"tags":560,"title":564,"type":404},[378],"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":556,"minutes":557,"time":558,"words":559},"12 min read",11.79,707400,2358,[561,562,526,563,528],"Debian","Side router","AdGuard Home","Using Debian as a Side Router",{"categories":566,"date":567,"description":568,"image":569,"path":570,"readingTime":571,"recommend":388,"tags":575,"title":580,"type":404},[378],"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":467,"minutes":572,"time":573,"words":574},9.395,563700,1879,[576,577,528,578,579],"FakeIP","sing-box","Policy-based routing","Traffic routing","Routing Transparent Proxy Traffic with FakeIP",{"categories":582,"date":583,"description":584,"image":585,"path":586,"readingTime":587,"recommend":388,"tags":591,"title":595,"type":404},[378],"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":415,"minutes":588,"time":589,"words":590},3.03,181800,606,[562,592,593,594],"Port forwarding","NAT","Network troubleshooting","Fixing Port Forwarding with a Side Router",{"categories":597,"date":598,"description":599,"image":600,"path":601,"readingTime":602,"recommend":388,"tags":606,"title":610,"type":404},[378],"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":390,"minutes":603,"time":604,"words":605},7.29,437400,1458,[607,511,458,608,609],"Go","Bare-metal programming","Runtime","A Project That Failed: Seven Not-So-Happy Days over Chinese New Year",{"categories":612,"date":613,"description":614,"image":615,"path":616,"readingTime":617,"recommend":388,"tags":622,"title":626,"type":404},[378],"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":618,"minutes":619,"time":620,"words":621},"3 min read",2.855,171300,571,[607,623,624,625],"Reflection","Deep copy","Struct conversion","Deep Copying Between Different Struct Types in Go",{"categories":628,"date":629,"description":630,"image":631,"path":632,"readingTime":633,"recommend":388,"tags":637,"title":643,"type":404},[378],"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":618,"minutes":634,"time":635,"words":636},2.45,147000,490,[638,639,640,641,642],"Apple Watch","Health Auto Export","InfluxDB","Grafana","Heart rate monitoring","My Heart Beats for U: Visualizing Heart Rate in Grafana",{"categories":645,"date":646,"description":647,"image":648,"path":649,"readingTime":650,"recommend":654,"tags":655,"title":661,"type":404},[378],"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":415,"minutes":651,"time":652,"words":653},3.305,198300,661,5,[656,657,658,659,660],"macOS 26","iPadOS 26","Liquid Glass","Apple Intelligence","Operating system impressions","Trying Out macOS 26 and iPadOS 26",{"categories":663,"date":664,"description":665,"image":666,"path":667,"readingTime":668,"recommend":388,"tags":672,"title":676,"type":404},[378],"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":538,"minutes":669,"time":670,"words":671},5.1,306000,1020,[673,659,674,675],"macOS 27","ChatGPT","Mainland China Mac","Getting Apple Intelligence Working on a China-Market Mac: Region Changes and Extracting ChatGPT",{"categories":678,"date":679,"description":680,"image":681,"path":682,"readingTime":683,"recommend":388,"tags":687,"title":693,"type":404},[378],"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":538,"minutes":684,"time":685,"words":686},5.76,345600,1152,[688,689,690,691,692],"MoonTV","LunaTV","Vibe Coding","Cursor","AI-assisted development","MoonTV: An Experiment in Vibe Coding",{"categories":695,"date":696,"description":697,"image":698,"path":699,"readingTime":700,"recommend":388,"tags":704,"title":707,"type":404},[378],"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":415,"minutes":701,"time":702,"words":703},3.805,228300,761,[705,706,578,579],"BGP","IP address database","More Accurate Routing for Chinese and Overseas IPs with BGP",{"categories":709,"date":710,"description":711,"image":712,"path":713,"readingTime":714,"recommend":388,"tags":718,"title":723,"type":404},[378],"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":520,"minutes":715,"time":716,"words":717},4.68,280800,936,[719,720,721,722],"Microsoft Flight Simulator 2024","Thrustmaster TCA","PICO VR","Flight simulation","Adventures with Microsoft Flight Simulator 2024",{"categories":725,"date":726,"description":727,"image":728,"path":729,"readingTime":730,"recommend":388,"tags":734,"title":740,"type":404},[378],"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":390,"minutes":731,"time":732,"words":733},7.61,456600,1522,[735,736,737,738,739],"Android","OPPO","iOS","Smartphone impressions","Ecosystem migration","One Month After Switching to Android",{"categories":742,"date":743,"description":744,"image":745,"path":746,"readingTime":747,"recommend":388,"tags":751,"title":757,"type":404},[378],"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":538,"minutes":748,"time":749,"words":750},5.735,344100,1147,[752,753,754,755,756],"TREK","Docker Compose","Dockge","VPS","Self-hosting","One TREK, Twenty Stacks",{"categories":759,"date":760,"description":761,"image":762,"path":763,"readingTime":764,"recommend":388,"tags":769,"title":773,"type":404},[378],"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":765,"minutes":766,"time":767,"words":768},"7 min read",6.47,388200,1294,[770,771,526,772,528,579],"OPNsense","FreeBSD","tun2socks","Transparent Proxying and Traffic Routing with OPNsense",{"categories":775,"date":379,"description":380,"image":383,"path":387,"readingTime":776,"recommend":373,"tags":777,"title":5,"type":404},[378],{"text":390,"minutes":391,"time":392,"words":393},[399,400,401,402,403],{"categories":779,"date":780,"description":781,"image":782,"path":783,"readingTime":784,"recommend":388,"tags":788,"title":793,"type":404},[378],"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":484,"minutes":785,"time":786,"words":787},1.92,115200,384,[511,789,790,791,792],"Spike","riscv-pk","Cross-compilation","Toolchain","Installing the RISC-V Toolchain and Emulator",{"categories":795,"date":796,"description":797,"image":798,"path":799,"readingTime":800,"recommend":804,"tags":805,"title":812,"type":404},[378],"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":390,"minutes":801,"time":802,"words":803},7.345,440700,1469,7,[806,807,808,809,810,811],"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":814,"date":815,"description":816,"image":817,"path":818,"readingTime":819,"recommend":388,"tags":823,"title":828,"type":404},[378],"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":556,"minutes":820,"time":821,"words":822},11.885,713100,2377,[824,825,826,827],"GFW","DNS poisoning","TCP","Internet censorship","How the Great Firewall Works",{"categories":830,"date":831,"description":832,"image":833,"path":834,"readingTime":835,"recommend":388,"tags":839,"title":845,"type":404},[378],"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":618,"minutes":836,"time":837,"words":838},2.305,138300,461,[840,841,842,843,844],"Java","javac","String concatenation","Constant propagation","Bytecode","How Java’s this Keyword Can Prevent Compile-Time Constant Propagation",{"categories":847,"date":848,"description":849,"image":850,"path":851,"readingTime":852,"recommend":388,"tags":857,"title":863,"type":404},[378],"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":853,"minutes":854,"time":855,"words":856},"19 min read",18.96,1137600,3792,[858,859,860,861,862],"VitePress","Vue","Cloudflare Workers","Cloudflare KV","Microblogging","Adding a Microblog to VitePress",{"categories":865,"date":866,"description":867,"image":868,"path":869,"readingTime":870,"recommend":388,"tags":874,"title":877,"type":404},[378],"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":618,"minutes":871,"time":872,"words":873},2.34,140400,468,[875,876,755,578,579],"Cloudflare WARP","IPv6","Routing Selected VPS Traffic Through WARP over IPv6",{"categories":879,"date":880,"description":881,"image":882,"path":883,"readingTime":884,"recommend":888,"tags":889,"title":895,"type":404},[378],"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":520,"minutes":885,"time":886,"words":887},4.545,272700,909,6,[890,891,892,893,894],"Xiaomi 17","Bootloader","Android Root","Firmware flashing","Root hiding","Making the Xiaomi 17 My Daily Driver: Unlocking, Flashing, Rooting, and Hiding Root",{"categories":897,"date":899,"description":900,"image":901,"path":902,"readingTime":903,"recommend":388,"tags":907,"title":912,"type":404},[898],"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":390,"minutes":904,"time":905,"words":906},7.21,432600,1442,[908,909,607,910,911],"MIT 6.5840","MapReduce","RPC","Concurrent programming","6.5840 Lab 1: MapReduce",{"categories":914,"date":915,"description":916,"image":917,"path":918,"readingTime":919,"recommend":388,"tags":923,"title":928,"type":404},[898],"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":520,"minutes":920,"time":921,"words":922},4.12,247200,824,[909,924,925,926,927],"Distributed systems","Paper notes","Parallel computing","Fault tolerance","Reading the MapReduce Paper",{"categories":930,"date":931,"description":932,"image":933,"path":934,"readingTime":935,"recommend":388,"tags":940,"title":944,"type":404},[898],"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":936,"minutes":937,"time":938,"words":939},"13 min read",12.235,734100,2447,[908,941,607,942,943],"Raft","Leader election","Distributed consensus","6.5840 Lab 2A: Leader Election",{"categories":946,"date":947,"description":948,"image":949,"path":950,"readingTime":951,"recommend":388,"tags":956,"title":958,"type":404},[898],"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":952,"minutes":953,"time":954,"words":955},"16 min read",15.98,958800,3196,[941,943,957,925],"Log replication","Reading the Raft Paper",{"categories":960,"date":962,"description":963,"image":964,"path":965,"readingTime":966,"recommend":970,"tags":971,"title":975,"type":404},[961],"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":520,"minutes":967,"time":968,"words":969},4.15,249000,830,1,[972,840,973,974],"MYDB","Database implementation","Database architecture","MYDB 0. Project Structure and a Few Things I Had to Say",{"categories":977,"date":978,"description":979,"image":980,"path":981,"readingTime":982,"recommend":388,"tags":986,"title":989,"type":404},[961],"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":520,"minutes":983,"time":984,"words":985},4.755,285300,951,[972,840,987,988],"Transaction management","XID","MYDB 1. Starting with the Transaction Manager",{"categories":991,"date":992,"description":993,"image":994,"path":995,"readingTime":996,"recommend":388,"tags":1000,"title":1004,"type":404},[961],"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":520,"minutes":997,"time":998,"words":999},4.305,258300,861,[972,840,1001,1002,1003],"Socket","Client-server architecture","Communication protocol","MYDB 10. Implementing the Server, Client, and Wire Protocol",{"categories":1006,"date":1007,"description":1008,"image":1009,"path":1010,"readingTime":1011,"recommend":388,"tags":1015,"title":1019,"type":404},[961],"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":538,"minutes":1012,"time":1013,"words":1014},5.725,343500,1145,[972,840,1016,1017,1018],"Reference counting","Cache design","Shared memory","MYDB 2. A Reference-Counted Cache Framework and Shared Byte Arrays",{"categories":1021,"date":1022,"description":1023,"image":1024,"path":1025,"readingTime":1026,"recommend":388,"tags":1030,"title":1033,"type":404},[961],"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":520,"minutes":1027,"time":1028,"words":1029},4.7,282000,940,[972,840,1031,1032],"Data pages","Cache management","MYDB 3. Caching and Managing Data Pages",{"categories":1035,"date":1036,"description":1037,"image":1038,"path":1039,"readingTime":1040,"recommend":388,"tags":1044,"title":1047,"type":404},[961],"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":390,"minutes":1041,"time":1042,"words":1043},7.885,473100,1577,[972,840,1045,1046],"Database logging","Crash recovery","MYDB 4. Log Files and Recovery Strategies",{"categories":1049,"date":1050,"description":1051,"image":1052,"path":1053,"readingTime":1054,"recommend":388,"tags":1058,"title":1061,"type":404},[961],"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":765,"minutes":1055,"time":1056,"words":1057},6.37,382200,1274,[972,840,1059,1060],"Page index","Data management","MYDB 5. The Page Index and the Data Manager",{"categories":1063,"date":1064,"description":1065,"image":1066,"path":1067,"readingTime":1068,"recommend":388,"tags":1072,"title":1076,"type":404},[961],"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":432,"minutes":1069,"time":1070,"words":1071},8.64,518400,1728,[972,840,1073,1074,1075],"MVCC","Transaction isolation","Two-phase locking","MYDB 6. Record Versions and Transaction Isolation",{"categories":1078,"date":1079,"description":1080,"image":1081,"path":1082,"readingTime":1083,"recommend":388,"tags":1087,"title":1090,"type":404},[961],"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":390,"minutes":1084,"time":1085,"words":1086},7.265,435900,1453,[972,840,1088,1089],"Deadlock detection","Version management","MYDB 7. Deadlock Detection and the Version Manager",{"categories":1092,"date":1093,"description":1094,"image":1095,"path":1096,"readingTime":1097,"recommend":388,"tags":1098,"title":1101,"type":404},[961],"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":520,"minutes":967,"time":968,"words":969},[972,840,1099,1100],"B+ tree","Database indexing","MYDB 8. Index Management",{"categories":1103,"date":1104,"description":1105,"image":1106,"path":1107,"readingTime":1108,"recommend":388,"tags":1112,"title":1115,"type":404},[961],"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":538,"minutes":1109,"time":1110,"words":1111},5.035,302100,1007,[972,840,1113,1114],"SQL parsing","Table management","MYDB 9. Field and Table Management",1789914051832]