Ethan Tsui's Technical Blog

website·Indexed 30 days ago

https://ethan-tsui.github.io

A technical knowledge base covering Java development, JVM internals (class loaders, heap structure, and garbage collection), MySQL database optimization (indexing, transactions, and execution workflows), and testing tools including TestNG, Selenium, and JMH. Also includes guides on Linux system administration, Redis Bloom filters, and MyBatis caching.

Tokens
44.8K
Snippets
125
Records
290
Agent score
72%

What's inside Ethan Tsui's Blog

  1. Overview of Spring Framework Core Features

    Spring is a lightweight Java development framework designed to improve developer efficiency and system maintainability. Its core strengths include:

    • IoC and DI: Uses a central container to manage object creation and dependencies, achieving high cohesion and low coupling.
    • AOP (Aspect-Oriented Programming): Allows implementation of cross-cutting concerns like permission interception and monitoring.
    • Declarative Transaction Management: Manages transactions via configuration rather than hard-coded JDBC logic.
    • Integration: Provides direct support for frameworks like Struts, Hibernate, MyBatis, and Quartz.
    • API Template Encapsulation: Simplifies complex JavaEE APIs (JDBC, JavaMail, etc.) through template classes.
  2. Overview of the MySQL SQL execution flow

    Executing a SQL query in MySQL involves the following sequence of components and stages:

    1. Connector: Establishes the connection, manages it, and authenticates the user.
    2. Query Cache: (Removed in MySQL 8.0) Checks if the query result is cached and returns it immediately if found.
    3. SQL Parser: Performs lexical and syntactic analysis to build a syntax tree for identifying tables, fields, and statement types.
    4. SQL Executor: Consists of three phases:
      • Preprocessing: Validates the existence of tables/fields and expands SELECT * into all specific columns.
      • Optimization: Selects the execution plan with the lowest estimated cost.
      • Execution: Executes the chosen plan by retrieving records from the storage engine and returning them to the client.
  3. Overview of JVM Runtime Data Area architecture

    The JVM consists of three primary subsystems: the Class Loading Subsystem, the Runtime Data Area (memory structure), and the Bytecode Execution Engine. The Class Loading Subsystem loads .class files into the Runtime Data Area. The Execution Engine handles program logic and includes the Garbage Collector (GC), which monitors and cleans memory in the background.
  4. Introduction to JMH for Java Microbenchmarking

    JMH (Java Microbenchmark Harness) is a tool developed by the JVM team to solve common performance testing inaccuracies such as timestamp precision errors, JVM code warmup (JIT compilation), JVM optimizations, and unpredictable garbage collection. It allows developers to perform strict, repeatable benchmarks using a simple annotation-based approach.
  5. Understand MySQL Server and Storage Engine layers

    MySQL architecture is divided into two primary layers:

    1. Server Layer: Responsible for establishing connections, analyzing, and executing SQL. It contains core modules including the Connector, Query Cache, Parser, Preprocessor, Optimizer, and Executor. All built-in functions (date, time, math, encryption) and cross-engine features (stored procedures, triggers, views) are implemented here.
    2. Storage Engine Layer: Responsible for data storage and retrieval. It supports multiple engines like InnoDB, MyISAM, and Memory. Index data structures are implemented at this layer (e.g., InnoDB uses B+ trees by default for primary and secondary indexes).
  6. Understand the JVM Heap Structure

    The Java Heap (or GC Heap) is the primary area managed by garbage collectors. It is divided into three main regions to allow for different collection algorithms based on the characteristics of the objects stored there:

    1. Young Generation: Further subdivided into the Eden space and two Survivor spaces (S0 and S1).
    2. Old Generation: Stores long-lived objects that have survived multiple Minor GC cycles.
    3. Metaspace: Stores class metadata (replacing the Permanent Generation in Java 8+).
  7. MySQL SQL Execution Workflow Overview

    Executing a SQL query in MySQL involves the following sequential stages:

    1. Connector (连接器): Establishes the connection, manages it, and authenticates the user.
    2. Query Cache (查询缓存): Returns results immediately if the exact query is cached. Note: This module was removed in MySQL 8.0.
    3. SQL Parser (解析器): Performs lexical and syntactic analysis to build a syntax tree, identifying table names, fields, and statement types.
    4. Execution (执行 SQL), which consists of three phases:
      • Preprocessing (预处理): Validates the existence of tables and fields, and expands SELECT * into all specific columns.
      • Optimization (优化): Selects the execution plan with the lowest estimated cost.
      • Execution (执行): Executes the chosen plan, retrieves records from the storage engine, and returns them to the client.
  8. Understand the JVM object creation process

    When the JVM encounters a new instruction, it follows these five sequential steps to create a fully initialized object:

    1. Class Loading Check: The JVM checks the constant pool to locate the symbolic reference of the class. If the class has not been loaded, resolved, and initialized, the JVM triggers the class loading process.
    2. Memory Allocation: The JVM allocates memory for the new object from the Java Heap. The allocation method (Pointer Bump or Free List) depends on whether the heap is contiguous (fragmented or not).
    3. Zero Initialization: The allocated memory (excluding the object header) is initialized to zero values. This ensures that instance fields can be accessed without explicit initialization in Java code.
    4. Object Header Setup: The JVM populates the object header with essential metadata, including the class instance type, reference to class metadata, hash code, and GC generation age.
    5. Execution of <init> Method: Finally, the JVM executes the <init> method to initialize the object's fields according to the programmer's specifications.
  9. Core features of the Spring Framework

    Spring is a lightweight Java framework designed to improve development efficiency and maintainability. Its core capabilities include:

    • Inversion of Control (IoC) and Dependency Injection (DI): Manages object creation and lifecycles via a container to achieve low coupling.
    • Aspect-Oriented Programming (AOP): Enables cross-cutting concerns like permission interception and monitoring.
    • Declarative Transaction Management: Manages transactions via configuration rather than manual JDBC commit/rollback code.
  10. JVM Runtime Data Areas Overview

    The JVM architecture consists of the Class Loading Subsystem, the Runtime Data Area (Memory Structure), and the Bytecode Execution Engine.

    Runtime Data Area Components:

    • Method Area (Metaspace): Contains the runtime constant pool, type information, field/method data, and references to ClassLoaders and Class instances.
    • Heap: The primary area for object allocation and garbage collection.
    • Stack: Stores local variables and method call frames.
    • Native Method Stack: Used for native method execution.
    • Program Counter (PC) Register: Tracks the current instruction being executed.
  11. Understand the relationship between Spring, SpringMVC, and SpringBoot

    These three entities represent different levels of the ecosystem:

    1. Spring: The base lightweight framework providing core IoC and AOP support.
    2. SpringMVC: A specific module of the Spring framework based on the Model-View-Controller design pattern, used for building Web applications and RESTful services.
    3. SpringBoot: A framework built on top of Spring that enables rapid creation of production-ready applications through 'auto-configuration' and 'convention over configuration', integrating common third-party libraries (e.g., Spring Data, Spring Security).
  12. Understand Index Condition Pushdown (ICP) in MySQL

    Introduced in MySQL 5.6, Index Condition Pushdown (ICP) is an optimization that allows the storage engine to evaluate filtering conditions on non-clustered index columns during the index traversal. This filters out records before they are retrieved from the table (reducing '回表' or table lookups), thereby improving performance.