LiYixian's Digital Garden and Technical Notes

website·Indexed 30 days ago

https://liyixian06.github.io/

A personal knowledge base and digital garden featuring technical study notes on Computer Architecture, Compiler Principles, Operating Systems, Computer Networking, and Databases. The site also includes personal reflections, media reviews, and guides on tools like FFmpeg.

Tokens
73.5K
Snippets
136
Records
436
Agent score
75%

What's inside LiYixian's Blog

  1. Overview of Model Context Protocol (MCP)

    The Model Context Protocol (MCP) is an open standard designed to standardize how AI models interact with external tools and data sources. Instead of the agent implementing every tool's schema and function locally, an MCP server encapsulates the functionality and exposes it via a standardized interface. The agent (MCP Client) connects to the MCP Server to discover and execute tools without needing to know the underlying implementation details.
  2. Overview of Transaction Implementation Mechanisms

    Databases implement ACID properties using a combination of log systems, locking mechanisms, and MVCC (Multi-Version Concurrency Control). MVCC allows read operations to proceed without locking by reading older versions of the data.

    Implementation varies by isolation level:

    • Read Uncommitted: Reads the most recent data directly.
    • Read Committed: Generates a new 'Read View' for every single read operation.
    • Repeatable Read: Generates one 'Read View' at the start of the transaction and uses it for the entire duration.
    • Serializable: Uses read/write locks to prevent concurrent access to the same data.
  3. Overview of Data Prefetching Concepts

    Data prefetching fetches data in cache block units before the program explicitly requests it to reduce compulsory cache misses and memory latency. Key design considerations include:

    • What to fetch: Based on past access patterns or compiler/programmer knowledge.
    • When to fetch: Timeliness is critical; fetching too early or too late reduces effectiveness.
    • Where to place data: Decisions include which cache level to target and the position in the LRU (Least Recently Used) chain.
    • How to fetch: Implemented via software instructions, hardware monitors, or execution-based mechanisms.

    Performance Metrics:

    • Accuracy: Ratio of used prefetches to sent prefetches.
    • Coverage: Ratio of prefetched misses to all misses.
    • Timeliness: Whether the data arrives just before it is needed.
    • Bandwidth Consumption: Additional memory bandwidth used by the prefetcher.
    • Cache Pollution: When prefetched blocks replace useful data, causing additional misses.
  4. Understand Virtual Memory and Address Translation

    Virtual Memory allows multiple processes and the OS to share physical memory while providing each application the illusion that it has access to the entire address space. This is achieved by treating memory as a cache and moving overflowed blocks to a swap space on the hard disk. A layer of indirection (address translation) is used to map virtual addresses (VA) to physical addresses (PA) before every instruction fetch, load, or store operation. Inter-process communication can be implemented by mapping the same physical pages to multiple virtual address spaces. Attempting to execute data, write to read-only data, or read unmapped data results in a segmentation fault.
  5. Understand Kubernetes Pod architecture and networking

    In Kubernetes, the Pod is the smallest deployable unit and the primary abstraction for managing containers. Kubernetes does not manage containers directly, but manages Pods which can contain one or more containers.

    Key characteristics:

    • Isolation: Pods are partitioned into different namespaces using Linux namespace mechanisms.
    • Networking: All containers within a single Pod share the same IP address. Communication between containers in the same Pod occurs via localhost (using specific ports), shared memory, or shared storage volumes.
    • Multi-container Pods: Designed for tightly coupled containers with the same lifecycle (e.g., a main application container and a sidecar utility container for logging or monitoring). Because they share an IP, port conflicts must be avoided.
  6. Understand Superscalar Architecture and ILP

    Superscalar architecture enables multiple instructions to be issued per cycle to achieve Instruction Level Parallelism (ILP), overcoming the performance limit of scalar pipelines where CPI (Cycles Per Instruction) = IPC (Instructions Per Cycle) = 1. Modern implementations typically achieve around 4 instructions per cycle. This requires hardware to check for dependencies between instructions and perform register scheduling.
  7. Review of the novel 'Sacrifice' (牺牲) by Fumie Kondo

    A youth-oriented inspirational novel written as a mystery, focusing on road bicycle racing. The story explores the concept of 'sacrifice' from two perspectives: teammates sacrificing their own results for the team's ace, and the ace bearing the burden of those sacrifices. It is noted for its precise depiction of the charm of sports and the pain of competition, featuring multiple plot twists in the final pages.
  8. Understand Fuzz Testing and Oracles

    Fuzz testing involves randomly generating inputs to discover program crashes or logic bugs. Because fuzzers generate millions of inputs, an 'oracle' is required to determine if the program's behavior is correct. Common oracles include:

    • Example-Based Assertions: Hardcoded expected outputs for specific inputs.
    • Snapshot Tests: Comparing output against a previously approved 'golden' version (can be brittle to harmless changes).
    • Crash Detection: A weak but generic oracle that simply checks if the program crashes.
    • Source Code Assertions: Executable specifications (preconditions, postconditions, invariants) that document intended behavior and can catch logic bugs during fuzzing.
  9. Implement a self-describing Tool definition

    In a professional agent system, tools should be self-describing objects rather than simple functions. This allows the runtime to make decisions about scheduling, permissions, and presentation based on the tool's declared properties without hardcoding logic into a central coordinator. Key properties include concurrency safety, read-only status, and destructive nature.
    export type Tool<
      Input extends AnyObject = AnyObject,
      Output = unknown,
      P extends ToolProgressData = ToolProgressData,
    > = {
      // Identity
      aliases?: string[]       // Backward compatible aliases
      searchHint?: string      // Keywords for lazy discovery
      
      // Core methods
      call(args, context, canUseTool, parentMessage, onProgress?)
        : Promise<ToolResult<Output>>
      description(input, options): Promise<string> // Dynamic description based on environment
      
      // Schema
      readonly inputSchema: Input           // Zod schema
      readonly inputJSONSchema?: ToolInputJSONSchema  // JSON Schema (for MCP tools)
      
      // Behavioral declarations
      isConcurrencySafe(input): boolean     // Can it run in parallel with other tools?
      isEnabled(): boolean                  // Is it available in the current environment?
      isReadOnly(input): boolean            // Is it a read-only operation?
      isDestructive?(input): boolean        // Does it perform irreversible operations?
      interruptBehavior?(): 'cancel' | 'block'  // Behavior when user interrupts
      
      // Permissions
      checkPermissions(input, context): Promise<PermissionResult>
      validateInput?(input, context): Promise<ValidationResult>
      preparePermissionMatcher?(input): Promise<(pattern: string) => boolean>
      
      // Output control
      maxResultSizeChars: number            // Maximum allowed output length to manage context budget
      readonly name: string
    }
  10. Understand Memory Array Organization

    Memory is organized as a 2^N row by M column array. Each row corresponds to a 'word-line' and each column to a 'bit-line'. To read data, a specific word-line is activated, and the storage for that entire row is output. To reduce access latency and allow parallel access, memory is divided into smaller arrays called 'banks'. The hierarchical structure typically follows: channel -> DIMM -> rank -> chip -> bank -> row/column.
  11. Understand the Agent Runtime and MCP

    The Agent Runtime manages the loop between the LLM and tool execution: it detects a tool call request, executes the corresponding program (similar to a syscall), and feeds the result back into the context as an 'Observation' for the LLM's next reasoning step.

    MCP (Model Context Protocol), introduced by Anthropic, is a standardized Tool Calling Interface that acts as a protocol layer between the Runtime and Tools. An MCP server exposes tools, describes schemas, executes calls, and returns results, ensuring consistency across different Agent platforms.

  12. Navigate the TCP/IP Protocol Stack

    The Internet uses a layered architecture where each layer provides services to the layer above it. Data undergoes encapsulation, adding headers at each level:

    1. Application Layer: Network applications and their protocols (Unit: Message).
    2. Transport Layer: Process-to-process data transfer. Key protocols: TCP (connection-oriented, flow/congestion control) and UDP (Unit: Segment).
    3. Network Layer (IP Layer): Routing datagrams from source to destination hosts using IP addresses and routing protocols (Unit: Datagram).
    4. Link Layer: Moving packets from one node to the next over a specific physical link (Unit: Frame).
    5. Physical Layer: Moving individual bits across the physical medium.

    Note: In the TCP/IP model, the Link and Physical layers are often combined into the Interface layer.