# 2024

## 2024

### December

* 31: [MarkItDown is a utility for converting various files to Markdown](https://github.com/microsoft/markitdown)
* 20: [Open Addressing vs Closed Addressing in HashMap](https://programming.guide/hash-tables-open-vs-closed-addressing.html#google_vignette)

  > * Open Addressing, aka., Closed Hashing
  > * Closed Addressing, aka., Open Hashing
* 19: [Java 9 引入的 Memory Order](https://www.lenshood.dev/2021/01/27/java-varhandle/)

  > * [Java 9 VarHandles Best practices, and why? youtube](https://m.youtube.com/watch?v=w2zaqhFczjY)
  > * [What are memory fences used for in Java?](https://stackoverflow.com/questions/60119169/what-are-memory-fences-used-for-in-java?t\&utm_source=perplexity)
* 18: [A friendly introduction to assembly for high-level programmers](https://shikaan.github.io/assembly/x86/guide/2024/09/08/x86-64-introduction-hello.html)
* 17: [What is the reason for performing a double fork when creating a daemon?](https://stackoverflow.com/questions/881388/what-is-the-reason-for-performing-a-double-fork-when-creating-a-daemon)

  > * The first process in the process group becomes the process group leader and the first process in the session becomes the session leader. Every session can have one TTY associated with it. Only a session leader can take control of a TTY. For a process to be truly daemonized (ran in the background) we should ensure that the session leader is killed so that there is no possibility of the session ever taking control of the TTY.
  > * [Use and meaning of session and process group in Unix?](https://stackoverflow.com/questions/6548823/use-and-meaning-of-session-and-process-group-in-unix?t\&utm_source=perplexity)
* 6: Some Python knowledge reviewed
  * [Async IO in Python: A Complete Walkthrough](https://realpython.com/async-io-python/?utm_source=perplexity)
  * [Understanding Object Instantiation and Metaclasses in Python](https://www.honeybadger.io/blog/python-instantiation-metaclass/)
  * [Implementing Interfaces in Python](https://medium.com/@arnab194/implementing-interfaces-in-python-da74b0d499c8)
* 3: [On system memory... specifically the difference between `tmpfs,` `shm,` and `hugepages...`](https://unix.stackexchange.com/questions/120525/on-system-memory-specifically-the-difference-between-tmpfs-shm-and-hug)

  > * There's no difference between shm and tmpfs (actually, tmpfs is only the new name of former shmfs). hugetlbfs is a tmpfs-based filesystem that allocates its space from kernel huge pages and needs some additional configuration afford.
  > * [JVM Anatomy Quark #2: Transparent Huge Pages](https://shipilev.net/jvm/anatomy-quarks/2-transparent-huge-pages/)
  > * [hugetlbfs support comes to Java Chronicle Queue](https://chronicle.software/chronicle-25-whats-new-and-improved/)
  > * [Huge Pages and Transparent Huge Pages](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/performance_tuning_guide/s-memory-transhuge#s-memory-transhuge)
  > * [Understanding Huge Pages](https://www.netdata.cloud/blog/understanding-huge-pages/)
  > * [Logical Volume Manager: A Beginner's Guide](https://dev.to/thecodersden/logical-volume-manager-a-beginners-guide-49l3)
  > * Block devices use SCSI (Small Computer System Interface) to talk to processes on one side and hardware on the other side. Hence, block devices have device names (since everything on Linux is a file, so device files) starting with sd\*, where s = SCSI and d = device. During boot time, the kernel detects block devices one by one and name them in the form sd\[a-z]. So in my case, my vmware disk got detected first and hence, it was named sda. Next, after boot, I attached my USB stick and the kernel named it sdb. As I mentioned earlier, all disks have one or more partitions. In the above output, sdb1, sda1, etc. are names of partitions.
  > * Remember that file systems are the managers of every partition? When we created a partition on mylv1, it's size was 1 GB. Just increasing the volume size doesn't mean that the filesystem would also be synchronized.
* 1: [A Deep Dive Into Python's functools.wraps Decorator](https://jacobpadilla.com/articles/functools-deep-dive)

  > functools.wraps, an easy-to-use interface for functools.update\_wrapper, is a decorator that automatically transfers the key metadata from a callable (generally a function or class) to its wrapper. Typically, this wrapper is another function, but it can be any callable object such as a class.

### November

* 27: [Does a lambda expression create an object on the heap every time it's executed?](https://stackoverflow.com/questions/27524445/does-a-lambda-expression-create-an-object-on-the-heap-every-time-its-executed)

  > It is equivalent but not identical. Simply said, if a lambda expression does not capture values, it will be a singleton that is re-used on every invocation.
* 26: [A Guide to BitSet in Java](https://www.baeldung.com/java-bitset)

  > check the [Affinity.java](https://github.com/OpenHFT/Java-Thread-Affinity/blob/ea/affinity/src/main/java/net/openhft/affinity/Affinity.java)[Using Pausers in Event Loops](https://chronicle.software/pauser-modes/)
* 25: [Python Decorators II: Decorator Arguments by Bruce Eckel](https://www.artima.com/weblogs/viewpost.jsp?thread=240845#decorator-functions-with-decorator-arguments)

  > Decorator Functions with Decorator Arguments
* 20: [Adding Git-Bash to Windows Terminal](https://www.timschaeps.be/post/adding-git-bash-to-windows-terminal/)

  > I hope I know it earlier... Note there is a `bash.exe` and use it instead of `git-bash.ext`. Use `.bashrc` instead of `.profile` or `.bash_profile` to setup env var because by default the `git-bash` won't login like `bash -l` automatically.
* 19: [Detailed Explanation of Guava RateLimiter's Throttling Mechanism](https://www.alibabacloud.com/blog/detailed-explanation-of-guava-ratelimiters-throttling-mechanism_594820)

  > The token bucket limits the average inflow rate and allows sudden increase in traffic. The leaky bucket limits the constant outflow rate, which is set to a fixed value.
  >
  > Some other implementations,
  >
  > * ring buffer based solution
  > * queue based solution
* 13: [Java Timer](https://concurrencydeepdives.com/java-timer/?t\&utm_source=perplexity#TLDR)

  > * [Concurrency Deep Dives](https://concurrencydeepdives.com/) worth a reading.
  > * Implementing a Java Timer uses native Java API.
  > * Comparing it with a Hashed Timer Wheel Solution.
  > * [DelayedQueue used by ScheduledThreadPoolExecutor](https://www.baeldung.com/java-delay-queue)
  > * [HashedWheelTimer vs ScheduledThreadPoolExecutor for higher performance](https://stackoverflow.com/questions/17276393/hashedwheeltimer-vs-scheduledthreadpoolexecutor-for-higher-performance)
* 7: [How the glibc strlen() implementation works ](https://stackoverflow.com/questions/20021066/how-the-glibc-strlen-implementation-works)/ [strlen performance implementation](https://stackoverflow.com/questions/11787810/strlen-performance-implementation)

  > * The algorithm behind the check is based on Determine if a word has a zero byte: [Bit Twiddling Hacks](https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord)
* 6: [Scalable IO in Java](https://gee.cs.oswego.edu/dl/cpjslides/nio.pdf)

  > * from Doug Lea, the famous Java Concurrency Module author.
  > * [《Scalable IO in Java》译文](https://www.cnblogs.com/dafanjoy/p/11217708.html)
* 5: [Introduction to Java ProcessHandle](https://dev.to/harithay/introduction-to-java-processhandle-5950)

  > * "Container types, including collections, maps, streams, arrays, and optionals should not be wrapped in optionals."
  > * "The ProcessHandle class does have the arguments method, which returns Optional\<String\[]>, but this method should be regarded as an anomaly that is not to be emulated."
* 4: [Why String is popular HashMap key in Java?](https://youtu.be/xhTAzmaW_7M)

  > * Using String as a key in a Java HashMap is generally preferred over CharSequence. This is because String is immutable, ensuring that its hash code remains constant throughout its lifetime, which is crucial for maintaining the integrity of the HashMap. In contrast, CharSequence is an interface that includes both mutable (like StringBuilder) and immutable implementations, leading to potential inconsistencies in equality and hash code behavior across different implementations. Thus, to avoid unexpected behavior, it’s advisable to use String as the key.
  > * The hashCode() implementation for StringBuilder in Java is not explicitly defined in the same way it is for String. Instead, StringBuilder inherits the hashCode() method from the Object class, which returns a hash code based on the object's memory address. This means that each instance of StringBuilder will have a unique hash code that does not take into account the contents of the builder.
* 3: [String length](https://rosettacode.org/wiki/String_length#Grapheme_Length_7)

  > String length method for Java and other languages.
* 2: [Hashed Wheel Timers](https://dev.to/frosnerd/hashed-wheel-timers-5bo9)

  > * due to the nature of threaded execution and system timing, this test could potentially fail if the system is under heavy load or experiencing other issues that cause significant delays.
  > * Alternatives to Hashed Wheel Timers:
  > * Heap-based timers
  > * List-based timers
  > * [DeadlineTimerWheel.java](https://github.com/real-logic/agrona/blob/master/agrona/src/main/java/org/agrona/DeadlineTimerWheel.java)
* 1: [Java Enums Are Inherently Serializable](https://www.infoworld.com/article/2164951/java-enums-are-inherently-serializable.html)

  > The default implementation has better performance.

### October

* 31: [Replace your switch statement and multiple "if and else", using Object Literals](https://dev.to/tauantcamargo/replace-your-switch-statement-and-multiple-if-and-else-using-object-literals-en-us-1dec)

  > Lesson: treat the switch statement as if they were the data.
* 30: [Java Convert Bytes to Unsigned Bytes](https://www.javatpoint.com/java-convert-bytes-to-unsigned-bytes)

  > * When we need to represent signed numbers in Java, we find [**2's complement**](https://builtin.com/articles/twos-complement#:~:text=Two's%20complement%20is%20a%20mathematical,Written%20by%20David%20Klempfner).In 2's complements the left most bit represent the sign (+ ive or - ive). The bit 0 denotes positive and 1 denotes negative. The rest of the bits denotes the value from -128 to 127. Therefore, it is called 8-bit byte only have 7 bits to store the values. other extra values range from 128 to 255 are unable to fit into a single byte. So, we can cast it to 32-bit unsigned integer for more spaces (bits).
  > * Note that Java does not provide unsigned byte. If we need to represent a number as unsigned byte (1 byte -> 4 bytes), we must cast byte to int and mask (&) the new int with a &0xff (get the last 8 bits). It gives the last 8-bits or prevents sign extension.
  > * Java 8 provides the built-in method toUnsignedInt() that is defined in the Byte class. It supports unsigned operations. The method converts a signed byte into an unsigned integer.
  > * Many external systems (e.g., databases, network protocols) utilize unsigned types. The lack of native support for unsigned bytes in Java complicates integration with these systems, requiring additional conversion logic or the use of larger data types (like int or long) to represent values that should fit in an unsigned byte24. This can lead to performance overhead and potential bugs if developers do not handle these conversions carefully.
  > * Frequent conversions between signed and unsigned representations can impact performance, especially in applications that require high throughput or low latency, such as video processing or real-time data analysis.
  > * the lack of an unsigned byte type in Java complicates data handling and interoperability while increasing the risk of errors in code. Developers must implement additional logic to work around these limitations, which can lead to more complex and error-prone applications.
* 29: [Debugging Till Dawn: How Git Bisect Saved My Demo](https://www.mikebuss.com/posts/debugging-till-dawn)

  > `git bisect run ./test_for_bug.sh`
* 28: [Nginx Logging: A Comprehensive Guide](https://betterstack.com/community/guides/logging/how-to-view-and-configure-nginx-access-and-error-logs/)
* 27: [A virtual DOM in 200 lines of JavaScript](https://lazamar.github.io/virtual-dom/)
* 26: [Using files for shared memory IPC](https://stackoverflow.com/questions/61962399/using-files-for-for-shared-memory-ipc)

  > * If another process attempts to load the same file (while it is still resident in the cache) the kernel detects this and doesn't need to reload the file. If the page cache gets full, pages will get evicted - dirty ones being written back out to the disk.
  > * By contrast, with IPC implemented using shared memory, there are no read and write syscalls, and no extra copy step. Each "channel" can simply use a separate area of the mapped buffer. A thread in one process writes data into the shared memory and it is almost immediately visible to the second process.
  > * if shared memory IPC can be implemented without memory mapped files?
  > * A practical way would be to create a memory-mapped file for a file that lives in a memory-only file system; e.g. a "tmpfs" in Linux.
  > * You could in theory implement a shared segment between two processes
  > * [What is the purpose of MAP\_ANONYMOUS flag in mmap system call?](https://stackoverflow.com/questions/34042915/what-is-the-purpose-of-map-anonymous-flag-in-mmap-system-call)
  > * Note that both Aeron IPC and CQ support tmpfs to further improve the performance
  > * When setting up Aeron for IPC, the media driver can be configured to operate with a term buffer located on a tmpfs mount point. This setup minimizes disk I/O latency since all operations occur in memory. The configuration involves specifying the directory for the Aeron media driver to point to a tmpfs mount, ensuring that all IPC messages are handled in-memory
  > * For even lower latencies, Chronicle Queue can be backed by tmpfs, a temporary filesystem that resides in RAM. This configuration significantly reduces delays caused by disk operations, provided that the queue size is managed appropriately.
* 25: [Aeron: Open-source high-performance messaging](https://www.youtube.com/watch?v=tM4YskS94b0)

  > The video discusses Aeron, a messaging system focused on high performance and reliability, particularly in scenarios where traditional protocols like TCP and UDP may fall short. The speaker, Martin Thompson, emphasizes the need for consistent latency and the challenges of reliable message delivery over UDP.![](/files/bFtOJSF2V2pd3zWIjEsz)
  >
  > * Transportation Media: multicast, IPC, InfiniBand, RDMA, PCI-e 3.0
  > * OSI Layer 4 (Transport) Services
  > * Connection Oriented Communication
  > * Reliability
  > * Flow Control: counters are the key to flow control and monitoring; pluggable in Aeron
  > * Congestion Avoidance/Control: TCP is not suitable for HFT partially because of it; pluggable in Aeron
  > * Multiplexing: HOL Blocking
  > * Design Principles
  >
  > from
  >
  > 1. clear segregation of control
  > 2. garbage free in steady state running
  > 3. lock-free, wait-free and copy-free in data structure in the messaging path
  > 4. respect the Single Writer Principle
  > 5. major data structures are not shared
  > 6. don't burden the main paths with exceptional cases
  > 7. non-blocking in the message path
  > 8. ...
  >
  > into 3 basic things
  >
  > * system architecture
  > * data structure
  > * protocol of interactions
  > * Data Structure
  > * Maps: dealing with primitives
  > * IPC Ring/Broadcast Buffer: between Conductors
  > * ITC Queues: between Sender/Receiver and Conductors
  > * Dynamic Arrays
  > * Log Buffer: IPC for messaging, creates a replicated persistent log of messages
  >   * mmap
  >   * tail is being moved atomically
  >   * No big file: page fault; page cache churn; VM pressure; clean/dirty/active
  >   * receiver side: High Water Mark + Completed; point chasing is really bad (In the context of messaging systems, point chasing refers to a method where a sender strategically prioritizes and sends messages to maximize engagement or response rates.)
  > * Monitoring and Debugging should be designed on day 1
  > * Loss, throughput and buffer size are strongly related
  > * Java
  > * Bad:
  >   * No Unsigned Type
  >   * NIO - Locks, off-heap, PAUSE, Signals, etc
  >   * String Encoding - 3 buffer copy
  >   * External Resources
  >   * Selectors - GC
  >   * converting bytes into int
  > * Good:
  >   * Tooling: IDEs, Gradle, HdrHistogram
  >   * Lambda & [Method Handlers](https://www.baeldung.com/java-method-handles)
  >   * Bytecode Instrumentation: good to debugging
  >   * Unsafe
  >   * The Optimizer
  >   * Garbage Collectors
  > * Kernel Module and FPGAs possible
  > * [Aeron: Do we really need another messaging system?](https://highscalability.com/aeron-do-we-really-need-another-messaging-system/)
* 24: [Evolution of Financial Exchange Architectures](https://www.youtube.com/watch?v=qDhTjE0XmkE)

  > The video features Martin Thompson discussing the evolution of financial exchanges, focusing on advancements in design, resilience, performance and deployment over the past decade.
  >
  > * Design
  > * State Machine -> Replicated State Machine: ordered input + deterministic execution
  > * Distributed Event Log: event sourcing
  > * Rich Domain Model (DDD) and specific data structure designed from scratch
  > * Time & Timers: atomic clock + gps synchronizer; how a timer cancels an order
  > * Resilience
  > * Fairness: multiple gateways -> 1
  > * Gateway: classification of customers
  > * Matching Engine: sharding by symbol/fungible...
  > * Primary Secondary vs Consensus: Raft
  > * Code Quality and Model Fidelity: Model fidelity refers to the degree to which a model accurately represents the real-world system or phenomenon it is intended to simulate or predict. High fidelity means that the model closely matches the actual behavior or characteristics of the system, capturing important details and dynamics. Low fidelity indicates a more simplified or abstract representation that may overlook critical factors.
  > * Performance: Transaction throughput has increased significantly, with some exchanges reaching millions of transactions per second and achieving latencies below 100 microseconds.
  > * Latency: average latency is misleading, we need percentile
  > * Throughput: burst scenario
  > * JVM:
  >   * CMS full GC
  >   * G1
  >   * Azul C4: Continuously Concurrent Compacting Collector, high allocation rate without nasty gc pauses with Amdahl's law
  >   * ZGC: not generational (but we can turn it on now?)
  >   * Shanadoah: better at smaller heaps
  > * Memory Access Patterns: Java is still catching up with that, c can get the close to the machine about the memory layout so that's why the fastest matching engine is written is c
  > * Data Structure: check all kinds of libs or even implement your own one; prevent cache misses;
  > * Binary Codecs: SBE; the FIX protocol is encoded in ASCII
  > * Preventing Costs: system calls; disk calls; page fault is going to interrupt the kernel - A page fault is an exception raised by the memory management unit (MMU) when a program attempts to access a memory page that is not currently mapped to its virtual address space. This situation typically arises when the required page is not loaded into physical memory (RAM), which make the mmap file horrendously more expensive all of a sudden. Setup huge pages to fix it; context switching
  > * Hardware
  >   * Disks: from milliseconds to tens/hundreds of microseconds
  >   * Network: financial organization is good at that
  >   * CPU: not too much improvement, throughput is abundant, but the latency is not getting better
  >   * IO: socket is not good; new API for IO and please use asynchronous API; DPDK
  > * Language: polyglot
  > * Deployment
  > * CI/CD
  > * Flexible Scaling: dev env in your local machine; using IPC if the machine has 100 cores
* 23: [An oral history of Bank Python](https://calpaterson.com/bank-python.html)

  > Dagger, a directed, acyclic graph of financial instruments. Also refer to [tradebook](https://github.com/damonYuan/tradebook) for this concept.
* 22: [Datetimes versus timestamps in MySQL](https://planetscale.com/blog/datetimes-vs-timestamps-in-mysql)

  > * The Epochalypse problem.
  > * [Using Unix Timestamps in MySQL Mini-Course](https://www.epochconverter.com/programming/mysql)
* 21: [HTTP/3 From A To Z: Core Concepts](https://www.smashingmagazine.com/2021/08/http3-core-concepts-part1/)

  > QUIC’s faster connection set-up with 0-RTT is really more of a micro-optimization than a revolutionary new feature. Compared to a state-of-the art TCP + TLS 1.3 set-up, it would save a maximum of one round trip. The amount of data that can actually be sent in the first round trip is additionally limited by a number of security considerations.
* 20: [The Gamma Of Levered ETFs](https://moontowermeta.com/the-gamma-of-levered-etfs/)

  > Levered ETFs are trading tools that are not suitable for investing. They do a good job of matching the levered return of an underlying index intraday. The sum of all the negative gamma trading is expensive as the mechanical re-balancing gets front-run and “arbed” by traders. This creates significant drag on the levered ETF’s assets. In fact, if the borrowing costs to short levered ETFs were not punitive, a popular strategy would be to short both the long and short versions of the same ETF, allowing the neutral arbitrageur to harvest both the expense ratios and negative gamma costs from tracking the index!
* 19: [How the Guinness Brewery Invented the Most Important Statistical Method in Science](https://www.scientificamerican.com/article/how-the-guinness-brewery-invented-the-most-important-statistical-method-in/)
* 18: [Server Setup Basics](https://becomesovran.com/blog/server-setup-basics.html)

  > and his \[Y[README.md](https://github.com/damonYuan/gitbook/blob/main/gems/README.md)et another full-node guide]\(<https://becomesovran.com/blog/yet-another-full-node-guide.html>) is quite good too. And here is another blog about the mentioned [btop](https://mp.weixin.qq.com/s/Qr-z0-zL44UjnItmDlsMzg).
* 15: [What is an Equivalent Martingale Measure, and why should a bookie care?](https://web.ma.utexas.edu/users/smmg/archive/2010/Brunick/slides-Brunick-2010-03-27.pdf)

  > * If there is an arbitrage possibility, then there is no EMM.
  > * If there are no arbitrage possibilities, then there is at least one EMM.
  > * If every payoff is replicable, then there is exactly one EMM.
  > * [Changing Probability Measures](https://benjaminwhiteside.com/2022/02/05/changing-probability-measures/)
  > * [Girsanov’s Theorem](https://benjaminwhiteside.com/2022/09/04/girsanovs-theorem/)
* 13: [Introduction to Spliterator in Java](https://www.baeldung.com/java-spliterator)
  * [Writing a custom spliterator in Java 8](https://hedleyproctor.com/2017/06/writing-a-custom-spliterator-in-java-8/)
* 12: [NIO Buffer](http://www.tianshouzhi.com/api/tutorials/netty/315)
* 11: [Guide to Java groupingBy Collector](https://www.baeldung.com/java-groupingby-collector)
* 7: [你管这破玩意儿叫 TCP](https://mp.weixin.qq.com/s/RsuuaC61b97-IM78kYRlIw)

  > 窗口大小 = min(cwnd, rwnd)
* 2: [String Length vs Character Length in Different Languages](https://rosettacode.org/wiki/String_length#Java)

  > In Java, the length method of String objects is not the length of that String in characters. Instead, it only gives the number of 16-bit code units used to encode a string. This is not (always) the number of Unicode characters (code points) in the string.

### September

* 30: [TCP Fast Open](https://dbwu.tech/posts/network/what-is-tcp-fast-open/)

  > TCP Fast Open (TFO) 是在传统的三次握手基础上进行优化，允许在握手过程中发送数据，从而减少首次发送数据的延迟，提升网络应用性能。
* 29: [Essence of linear algebra](https://youtu.be/kjBOesZCoqc?si=QDHT460ilkJ14VLx)

  > TODO
* 28: [High-availability matching engine of a stock exchange](https://github.com/pgellert/matching-engine)

  > This repo using RAFT to ensure the Availability, and based on CAP Theory,
  >
  > * Consistency: no, only eventual consistency
  > * Availability: yes
  > * Partition Tolerance: yes
* 27: [Linear Algebra 101 for AI/ML](https://www.trybackprop.com/blog/linalg101/part_1_vectors_matrices_operations)

  > TODO
* 26: [Trading at light speed: designing low latency systems in C++ - David Gross - Meeting C++ 2022](https://youtu.be/8uAW5FQtcvE?si=RCyeHNIX4s3k0i_n)

  > * ![concurrent data](/files/7A6wGGBo9XkbNbyikQfE)
  > * I wish I can understand more when I watch it again later.
* 25: [如果让你来设计网络](https://mp.weixin.qq.com/s?__biz=MzkxMDc1MDg1Nw==\&mid=2247508504\&idx=1\&sn=b21196cfd1c3cbde80119240c9d2cd81\&source=41\&poc_token=HBXj82ajD_l0qeqwYszOJbprRYAhjRFa0zg-_YF4)
* 24: [Java Objects.hash() vs Objects.hashCode()](https://www.baeldung.com/java-objects-hash-vs-objects-hashcode)

  > * back to the basics.
* 23: [Java Variable Handles Demystified](https://www.baeldung.com/java-variable-handles)

  > * The goal of VarHandle is to define a standard for invoking equivalents of java.util.concurrent.atomic and sun.misc.Unsafe operations on fields and array elements.
* 13: [Java G1GC - Card Table (CT) vs Remembered Set (RS)](https://stackoverflow.com/questions/65475533/java-g1gc-card-table-ct-vs-remembered-set-rs)

  > * ![rset](/files/Bj2OcRI7lPbDQ0We8Rlw)
  > * [Understanding JVM Garbage Collection – Part 9 Garbage First (G1) Garbage Collector (GC)](https://abiasforaction.net/understanding-jvm-garbage-collection-part-9-garbage-first-g1-garbage-collector-gc/)
  > * [垃圾回收之CardTable和Remembered Set](https://www.cnblogs.com/binyue/p/17281785.html)
* 12: [Bending pause times to your will with Generational ZGC](https://netflixtechblog.com/bending-pause-times-to-your-will-with-generational-zgc-256629c9386b)

  > * In the worst case we evaluated, non-generational ZGC caused 36% more CPU utilization than G1 for the same workload. That became a nearly 10% improvement with generational ZGC.
  > * [Introducing Generational ZGC](https://inside.java/2023/11/28/gen-zgc-explainer/)
* 11: [Demystifying ZGC: Concurrent Garbage Collection and Colored Pointers](https://sumofbytes.com/blog/demystifying-zgc-concurrent-garbage-collection-and-colored-pointers)

  > * ![colored pointer](/files/Xg803osAhj18F2tzQTxd)
* 10: [Memory Address of Objects in Java](https://www.baeldung.com/java-object-memory-address)

  > When we don’t declare a hashCode() method for a class, Java will use the identity hash code for it.
* 9: [Java Variable Handles Demystified](https://www.baeldung.com/java-variable-handles)

  > * [Correct way to use VarHandle in Java 9?](https://stackoverflow.com/questions/43558270/correct-way-to-use-varhandle-in-java-9)
* 7: [Java 17 migration: bias locks performance regression](https://dev.to/vbochenin/java-17-migration-bias-locks-regression-2c5m)

  > * JVM raises a flag in the monitor object that some thread acquires the lock, so reacquiring and releasing the lock by the same thread is lightweight. But the lock must be revoked when another thread tries to acquire the bias lock. And the revocation is a costly operation.
  > * [Loop unrolling](https://en.m.wikipedia.org/wiki/Loop_unrolling): Loop unrolling, also known as loop unwinding, is a loop transformation technique that attempts to optimize a program's execution speed at the expense of its binary size, which is an approach known as space–time tradeoff.
  > * [Loop unswitching](https://en.m.wikipedia.org/wiki/Loop_unswitching): Loop unswitching is a compiler optimization. It moves a conditional inside a loop outside of it by duplicating the loop's body, and placing a version of it inside each of the if and else clauses of the conditional.\[1] This can improve the parallelization of the loop. Since modern processors can operate quickly on vectors, this improvement increases the speed of the program.
* 6: [Remote C++ Development with Docker and CLion (with X11)](https://austinmorlan.com/posts/docker_clion_development/) -> [linux ARM is not supported yet](https://intellij-support.jetbrains.com/hc/en-us/community/posts/6899798064658-Remote-Development-SSH-No-Linux-Installation-Found-on-the-Selected-Machine), which means Apple chips are not supported yet.

  > * [Debugging C++ in a Docker Container with CLion](https://github.com/shuhaoliu/docker-clion-dev)
  > * [Use containers for C++ development](https://docs.docker.com/guides/language/cpp/develop/)
  > * [Docker toolchain](https://www.jetbrains.com/help/clion/clion-toolchains-in-docker.html)
  > * [Using Docker with CLion](https://blog.jetbrains.com/clion/2020/01/using-docker-with-clion/#major-updates)

### August

* 29: [Why should I use the keyword "final" on a method parameter in Java?](https://stackoverflow.com/questions/500508/why-should-i-use-the-keyword-final-on-a-method-parameter-in-java#:~:text=Never%20Reassign%20Arguments\&text=Since%20humans%20make%20mistakes%2C%20and,flag%20any%20such%20re%2Dassignments.)

  > * Use the keyword final when you want the compiler to prevent a variable from being re-assigned to a different object.
  > * [8 Kinds of Variables](https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.12.3)
* 28: [Types of References in Java](https://medium.com/@ali.gelenler/types-of-references-in-java-d8fe0da6d656)

  > * The default type of reference in Java is a strong reference.
  > * If JVM sees an object that has only a weak reference during GC, it will be collected.
  > * A soft reference is garbage-collected only if there is not enough memory left in the heap.
  > * Unlike weak and soft references whereby we can control how objects garbage-collected, a phantom reference is used for pre-mortem clean-up actions before the GC removes the object.
* 27: [Where are generic types stored in java class files?](https://stackoverflow.com/questions/937933/where-are-generic-types-stored-in-java-class-files)

  > * [详解Gson的TypeToken原理](https://cloud.tencent.com/developer/article/1672483)
* 26: [Move Your Mac's Home Folder to a New Location](https://www.lifewire.com/move-macs-home-folder-new-location-2260157)

  > Simple but useful.
* 24: [The Synchronizes-With Relation](https://preshing.com/20130823/the-synchronizes-with-relation/)

  > <img src="/files/x0SAc7Frrd52Q0DGmh9k" alt="Happens-Before" data-size="original">
* 23: [Java Objects Inside Out](https://shipilev.net/jvm/objects-inside-out/)
* 22: [Java Memory Layour](https://www.baeldung.com/java-memory-layout)

  > * [JOL](https://openjdk.org/projects/code-tools/jol/) to inspect the memory layout of objects in the JVM.
  > * Put simply, the Contended annotation adds some paddings around each annotated field to isolate each field on its own cache line. Consequently, this will impact the memory layout. Please note that the Contended annotation is JDK internal, therefore we should avoid using it. Also, we should run our code with the -XX:-RestrictContended tuning flag; otherwise, the annotation wouldn’t take effect.
  > * [Compressed OOPs in the JVM](https://www.baeldung.com/jvm-compressed-oops#2beyond-32-gb)
  > * the JVM adds padding to the objects so that their size is a multiple of 8 bytes. With these paddings, the last three bits in oops are always zero. This is because numbers that are a multiple of 8 always end in 000 in binary.
  > * Since ZGC needs to use 64-bit colored pointers, it does not support compressed references. So, using an ultra-low latency GC like ZGC has to be weighed against using more memory.
  > * [jvm-堆内存不要超过32G](https://tf2jaguar.github.io/jvm-heap-size.html)
  > * [ZGC: A Scalable Low-Latency Garbage Collector](https://www.youtube.com/watch?v=kF_r3GE3zOo\&t=643s)
  > * [An Introduction to ZGC](https://www.baeldung.com/jvm-zgc-garbage-collector)
  > * [Shenandoah: A Low-Pause-Time Garbage Collector](https://openjdk.org/jeps/379)
* 21: [JC Tools](https://github.com/JCTools/JCTools)

  > * [MpmcArrayQueue](https://github.com/JCTools/JCTools/blob/a17b56f09cc9ec7d773707578c89f3ca9c11f968/jctools-core/src/main/java/org/jctools/queues/MpmcArrayQueue.java#L168)
  > * [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools)
  > * [False Sharing](https://mechanical-sympathy.blogspot.com/2011/07/false-sharing.html)
  > * On modern x86 CPUs, the typical cache line size is 64 bytes. However, some CPUs may have larger cache lines, such as 128 bytes.
  > * To ensure compatibility with various CPU architectures and avoid false sharing on CPUs with larger cache lines, the `ConcurrentCircularArrayQueueL0Pad` class is padded with 128 bytes.
  > * ![false sharing](/files/o8VDEOpohpr9QVQaI4WS)
* 20: [From the Circle to Epicycles (Part 1) - An animated introduction to Fourier Series](https://www.andreinc.net/2024/04/24/from-the-circle-to-epicycles)
* 19: [JMH: Benchmark Reactive vs Disruptor](https://medium.com/@trunghuynh/jmh-benchmark-reactive-vs-disruptor-2100a293e17f)

  > * [Microbenchmarking with Java](https://www.baeldung.com/java-microbenchmark-harness)
* 18: [JSON is incredibly slow: Here’s What’s Faster!](https://medium.com/data-science-community-srm/json-is-incredibly-slow-heres-what-s-faster-ca35d5aaf9e8)

  > * [Protocol Buffers & Simple Binary Encoding](https://medium.com/@jyjimmylee/protocol-buffers-vs-simple-binary-encoding-24cb496376b6)
  > * [Json,Protobuf, SBE: Benchmark the byte story](https://medium.com/@trunghuynh/json-protobuf-sbe-benchmark-the-byte-story-16840f763543)
  > * We can make “message processors” are faster
  > * We can make deserialize and serialize process faster
  > * We can make the network transfer faster
* 17: [Sort, sweep, and prune: Collision detection algorithms](https://leanrada.com/notes/sweep-and-prune/)

  > * Usually when optimising algorithms, you wanna find redundant or unnecessary work. Then find a way to consolidate that redundancy.
  > * The sweep-and-prune algorithm is also known as sort-and-sweep.
  > * Pairs flagged in all dimensions would be considered intersecting.
  > * Insertion sort has a running time of O(n) at best when the list is already sorted or nearly-sorted, and O(n2) at worst when the list is in reverse.
* 16: [Deribit volatility (DVOL)](https://mp.weixin.qq.com/s/WFdE8We2v7ZZlFIX1sSa0Q)
* 15: [How to Implement a FIX Trading Engine in Python](https://medium.com/@andresberejnoi/how-to-implement-a-fix-trading-engine-in-python-andres-berejnoi-4971270fa2f6)

  > * [Financial Information eXchange](https://en.wikipedia.org/wiki/Financial_Information_eXchange): The body length is the character count starting at tag 35 (included) all the way to tag 10 (excluded), including trailing SOH delimiters.
  > * Simple Binary Encoding (SBE) is a codec format specified by the Financial Information eXchange (FIX) Trading Community for use in high-performance trading systems. ([The Unreasonable Effectiveness of Simple Binary Encoding (SBE)](https://yafetn.github.io/2023/01/12/sbe.html))
  > * FAST: Primarily designed to reduce the amount of data sent over the network and improve the speed of message delivery, particularly for market data. It utilizes compression techniques to minimize the size of messages, which can include both binary and character-based data.
  > * FAST: Focuses on the transmission layer and may be used in conjunction with other encoding methods, including SBE.
* 14: [Bounded MPMC queue](https://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue)
* 13: [Understanding the meaning of lvalues and rvalues in C++](https://www.internalpointers.com/post/understanding-meaning-lvalues-and-rvalues-c)

  > * [C++: lvalue/rvalue for Complete Dummies](https://www.aloneguid.uk/posts/2021/12/lvalue-vs-rvalue/?t\&utm_source=perplexity)
  > * [Understanding lvalues, rvalues and their references](https://www.fluentcpp.com/2018/02/06/understanding-lvalues-rvalues-and-their-references/)
  > * [C++ rvalue references and move semantics for beginners](https://www.internalpointers.com/post/c-rvalue-references-and-move-semantics-beginners)\
  >   more,
  > * [Resource acquisition is initialization](https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization)
  > * Mark you move constructors and move assignment operators with noexcept
  > * Further optimizations and stronger exception safety with copy-and-swap idiom
  > * Perfect forwarding
* 12: [Effective Java! Use Varargs Judiciously](https://dev.to/kylec32/effective-java-use-varargs-judiously-58g7)

  > * A possible mitigation strategy to this is, if for example 95% of the callers of the function will include 3 or less parameters you can create three functions that take 1, 2, and 3 parameters of the argument type to handle the 95% and a fourth that takes three parameters and a vararg parameter to handle the rest of the 5%.
  > * [var args constructors/methods vs lists](https://softwareengineering.stackexchange.com/questions/186598/var-args-constructors-methods-vs-lists)
* 11: [Thread-Local Allocation Buffers in JVM](https://alidg.me/blog/2019/6/21/tlab-jvm)

  > * <https://www.baeldung.com/java-jvm-tlab>
  > * [Introduction to Thread Local Allocation Buffers (TLAB)](https://dzone.com/articles/thread-local-allocation-buffers)
* 10: [org.apache.logging.log4j.util.Unbox.java](https://github.com/apache/logging-log4j2/blob/2.x/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java)

  > * Utility for preventing primitive parameter values from being auto-boxed. Auto-boxing creates temporary objects which contribute to pressure on the garbage collector. With this utility users can convert primitive values directly into text without allocating temporary objects.
  > * [Java Performance Notes: Autoboxing / Unboxing](https://dzone.com/articles/java-performance-notes-autoboxing-unboxing)
  > * `private final ThreadLocal<int[]> current = new ThreadLocal<>();`: By using ThreadLocal\<int\[]>, you can store multiple integer values in a single thread-local variable without the overhead of boxing.
* 9: [An exploration of vector search](https://blog.shalvah.me/posts/an-exploration-of-vector-search)

  > TODO
* 8: [Calling a @Bean annotated method in Spring java configuration](https://stackoverflow.com/questions/27990060/calling-a-bean-annotated-method-in-spring-java-configuration)

  > You will always get the same bean from the context if calling a @Bean annotated method in Spring java configuration. Same for @Component.
* 7: [Exact difference between CharSequence and String in java](https://stackoverflow.com/questions/11323962/exact-difference-between-charsequence-and-string-in-java/26498954#26498954)

  > <img src="/files/mA51QIcqXbxpCOmW7yvX" alt="String Types in Java 8" data-size="original">
* 6: [Maps in Java](https://stackoverflow.com/questions/1811782/when-should-i-use-concurrentskiplistmap)

  > <img src="/files/Jx6tu14e1JFkG7R4ol3R" alt="Maps in Java" data-size="original">
* 5: [Embeddings: What they are and why they matter](https://simonwillison.net/2023/Oct/23/embeddings/)

  > * [How does cosine similarity work?](https://tomhazledine.com/cosine-similarity/)\
  >   TODO
* 4: [Fiber in C++: Understanding the Basics](https://agraphicsguynotes.com/posts/fiber_in_cpp_understanding_the_basics/)

  > TODO
* 3: [Kernel bypass](https://blog.cloudflare.com/kernel-bypass/)
* 2: [How to implement a hash table (in C)](https://benhoyt.com/writings/hash-table-in-c/)
* 1: [Linear Algebra Done Right](https://linear.axler.net/)

### July

* 31: [TypeToken in Gson](https://cloud.tencent.com/developer/article/1672483)

  > 1. Anonymous subclass of TypeToken
  > 2. The annotation of the `getGenericSuperClass()` method of the `Class` class is: Returns the Type representing the direct superclass of the entity (class, interface, primitive type or void) represented by thisClass. If the superclass is a parameterized type, the Type object returned must accurately reflect the actual type parameters used in the source code. The parameterized type representing the superclass is created if it had not been created before. See the declaration of ParameterizedType for the semantics of the creation process for parameterized types. If thisClass represents either theObject class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then theClass object representing theObject class is returned.
* 30: [Vim: insert the same characters across multiple lines](https://stackoverflow.com/questions/9549729/vim-insert-the-same-characters-across-multiple-lines)

  > 1. VISUAL BLOCK: I - insert before; A - append after; c - replace
  > 2. macro
  > 3. substitute
* 29: [Java Collections Framework](https://www.logicbig.com/tutorials/core-java-tutorial/java-collections.html)

  > * ![Java Concurrent Collection CheatSheet](/files/1u4CXYUgg2AMDWhOWEjH)
  > * Exchanger vs SynchronousQueue vs LinkedTransferQueue
* 28: [FutureTask](https://www.cnblogs.com/dolphin0520/p/3949310.html)

  > * `public interface RunnableFuture<V> extends Runnable, Future<V>`
  > * `public class FutureTask<V> implements RunnableFuture<V>`
* 27: [Types of References in Java](https://medium.com/@ali.gelenler/types-of-references-in-java-d8fe0da6d656)

  > * There are four types of references in Java: Strong, Weak, Soft, and Phantom.
  > * Unlike weak and soft references whereby we can control how objects garbage-collected, a phantom reference is used for pre-mortem clean-up actions before the GC removes the object.
* 26: [为什么数学不允许除以0，却定义了根号- 1？](https://youtu.be/Ls1kEKmg0UU?si=PiX0rlu3Cs137V2m)

  > It explains the origin of complex number and the geometrical meaning of complex domain.
* 24: [Exploring TLS certificates and their limits](https://0x00.cl/blog/2024/exploring-tls-certs/)

  > * How big can a certificate be? For curl to work is 100kB and for a web browser like Firefox is \~60kB though Firefox TLS library works different so results may vary.
  > * How long can it last? From Jan 1, 1950 to Dec 31, 9999. About 8050 years.
* 25: [GCs of JVM tuning: PS+PO VS CMS VS G1](https://masteranyfield.com/2021/05/13/gcs-of-jvm-tuning-pspo-vs-cms-vs-g1/)

  > * [GC Algos](http://www.tianshouzhi.com/api/tutorials/jvm/96): Mark-Sweep, Copying, Mark-Compact, Generation-Collection
  > * ![GC](/files/zjpNvBbau2PU5dhyywSg)
  > * [JVM and GC](https://www.infoq.cn/article/3wyretkqrhivtw4frmr3)
  > * ![gens](/files/OOxUODnvbdsmkURsllw1)
  > * [JVM Garbage Collectors](https://www.baeldung.com/jvm-garbage-collectors)
* 24: [Simulating a financial exchange in Scala](https://falconair.github.io/2015/01/05/financial-exchange.html)

  > * [Order Matching Engine Design](https://liaoxuefeng.com/books/java/springcloud/engine/match/index.html): TreeMap (Red-Black Tree) vs Priority Queue (Heap)
  > * [matching engine](https://github.com/damonYuan/MatchingEngine)
* 18: [IO Mode](https://rickhw.github.io/2019/02/27/ComputerScience/IO-Models/)

  > * ![IO models](/files/tBOcw7vJU8yXBeLD3zrW)
  > * Blocking I/O model (Blocking / Synchronous): recvfrom
  > * Signal-driven I/O (Blocking / Synchronous): SIGIO
  > * Non-Blocking I/O (Non-Blocking / Synchronous): recvfrom (O\_NONBLOCK)
  > * I/O Multiplexing (Blocking / Asynchronous): select, poll, epoll
  > * Asynchronous I/O (Non-Blocking / Asynchronous): AIO
* 15: [Measure Theory](https://www.youtube.com/playlist?list=PLBh2i93oe2qvMVqAzsX1Kuv6-4fjazZ8j)

  > * Power Set of X is the set of all possible subsets of X.
  > * Definition of sigma algebra
* 12: [covariance of two squared (not zero mean) random variables](https://math.stackexchange.com/questions/1889402/covariance-of-two-squared-not-zero-mean-random-variables)

  > [How to compute expectation for the product of squared jointly normal random variables](https://math.stackexchange.com/questions/3846771/how-to-compute-expectation-for-the-product-of-squared-jointly-normal-random-vari)
* 11: [Risk System Concepts - Trade Booking & Pricing](https://github.com/stehrn/tradebook)

  > * what is a trade and how can it be modelled
  > * what you need before booking a trade
  > * what happens when a trade is booked
* 08: [What Is Bootstrapping Statistics?](https://builtin.com/data-science/bootstrapping-statistics)

  > “Bootstrapping is a statistical procedure that resamples a single data set to create many simulated samples.”
* 04: [String Matching KMP](https://mp.weixin.qq.com/s/6knLuNCRshz9a8FRDATs4w)

  > 30 lines.
* 02: [An Interactive Intro to CRDTs](https://jakelazaroff.com/words/an-interactive-intro-to-crdts/) and [Building a collaborative text editor in Go](https://databases.systems/posts/collaborative-editor)

  > * CRDT stands for “Conflict-free Replicated Data Type”.
  > * It’s a kind of data structure that can be stored on different computers (peers). Each peer can update its own state instantly, without a network request to check with other peers.
  > * Peers may have different states at different points in time, but are guaranteed to eventually converge on a single agreed-upon state. That makes CRDTs great for building rich collaborative apps, like Google Docs and Figma — without requiring a central server to sync changes.

### June

* 28: [Acquire and Release Semantics](https://preshing.com/20120913/acquire-and-release-semantics/)

  > * Acquire semantics -> LoadLoad + LoadStore
  > * Release semantics -> LoadStore + StoreStore
* 27: [Memory Barriers Are Like Source Control Operations](https://preshing.com/20120710/memory-barriers-are-like-source-control-operations/)

  > Types of Memory Barrier/Reordering: LoadLoad, StoreStore, LoadStore, StoreLoad
* 26: [Memory Reordering Caught in the Act](https://preshing.com/20120515/memory-reordering-caught-in-the-act/)
* 24: [mintomic](http://mintomic.github.io/lock-free/memory-fences/)

  > Mintomic (short for “minimal atomic”) is an API for low-level lock-free programming in C and C++.
* 23: [An Introduction to Lock-Free Programming](https://preshing.com/20120612/an-introduction-to-lock-free-programming/)

  > Sequential consistency means that all threads agree on the order in which memory operations occurred, and that order is consistent with the order of operations in the program source code.
* 21: [Kiss Linux](https://kisslinux.github.io/)

  > Kiss Linux™ is a meta-distribution for the x86\_64 architecture with a focus on simplicity, sustainability and user freedom.
* 20: [Story: Redis and its creator antirez](https://blog.brachiosoft.com/en/posts/redis/)

  > "For antirez, programming was a way to express himself, a form of art. Every character and line break had to be meticulously crafted, akin to the art form of writing. Software development was like writing a book — it had to be beautiful, elegant, and easy to comprehend. If that software happened to be useful to others, that was just a side effect."[Why is single threaded Redis so fast](https://m.toutiao.com/article/7204821418587144736/?log_from=d235c7c636293_1677580633904\&upstream_biz=toutiao_pc)
* 19: [User-space RCU: Memory-barrier menagerie](https://lwn.net/Articles/573436/#Quick%20Quiz%202)

  > The truth is that pairs of memory barriers provide conditional ordering guarantees.
* 18: [new\_script](http://linuxcommand.org/lc3_new_script.php)

  > * This is a shell script template generator (i.e. a script that writes scripts).
  > * [Advanced Shell Scripting Techniques: Automating Complex Tasks with Bash](https://omid.dev/2024/06/19/advanced-shell-scripting-techniques-automating-complex-tasks-with-bash/)
* 17: [Arthas for Java Debugging](https://arthas.aliyun.com/doc/quick-start.html)

  > * [How Arthas Works Underneath](https://zhuanlan.zhihu.com/p/115127052)
  > * [How to Get the Size of an Object in Java](https://www.baeldung.com/java-size-of-object)
  > * [Unleashing the Power of Java Instrumentation: A Deep Dive into Runtime Metamorphosis](https://naveen-metta.medium.com/unleashing-the-power-of-java-instrumentation-a-deep-dive-into-runtime-metamorphosis-1bbce9602daf#:~:text=Instrumentation%20in%20Java%20refers%20to,Java%20Virtual%20Machine%20\(JVM\).)
  > * <https://www.baeldung.com/java-instrumentation>
  > * [core-java-jvm](https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-jvm)
* 16: [Java Aeron Framework: A Beginner’s Guide to Unicast Networking with UDP](https://medium.com/@trunghuynh/java-aeron-framework-a-beginners-guide-to-unicast-networking-with-udp-8784eb060bd6)
* 15: [Exploring the Java Aeron Framework: A Comprehensive Introduction to IPC](https://medium.com/@trunghuynh/exploring-the-java-aeron-framework-a-comprehensive-introduction-to-ipc-975578b5acb5)
* 14: [Introduction to Lock-Free Algorithms 101 in Java](https://medium.com/@trunghuynh/introduction-to-lock-free-algorithms-101-in-java-e5673b6e0d77)

  > * [Java Microbenchmark Harness (JMH)](https://github.com/openjdk/jmh)
  > * Maybe the `thread.yield()` should be used instead of the `LockSupport.parkNanos(1);`
* 13: [Java NIO: Using Memory-mapped file to load big data into applications](https://medium.com/@trunghuynh/java-nio-using-memory-mapped-file-to-load-big-data-into-applications-5058b395cc9d)

  > * Java supports to use “memory-mapped file” we can see this feature has been implemented in some popular frameworks and are successful by using this capability of Java
  > * Chronicle queue
  > * QuestDB
  > * KDB
  > * [mmap](https://cpu.wonyes.org/21.-ni-guan-zhe-po-wan-yi-jiao-mmap.html)
  > * kafka -> sendfile
* 12: [Netty核心原理剖析与RPC实践](https://tf2jaguar.github.io/principle-of-netty-rpc-practice.html)

  > TODO
* 11: [Build Your Own Redis with C/C++](https://build-your-own.org/redis/)
* 10: [LMAX Disruptor](https://lmax-exchange.github.io/disruptor/disruptor.html)

  > 1. lock-free using volatile / AtomicLong
  > 2. padding to prevent false sharing
  > 3. batching for disk/network writing (e.g., the size of a block is 4k)
  > 4. enable the ability to zero garbage route using byte array or using the immutable object\
  >    Reference,
  > 5. [Disruptor++](https://github.com/lewissbaker/disruptorplus?tab=readme-ov-file)
  > 6. [disruptor C++ 用法浅析](https://leiyiming.com/2017/11/01/disruptor/)
  > 7. [c++ disruptor 无锁消息队列](https://wudaijun.com/2015/02/cpp-disruptor/)
  > 8. [Low Latency Java with the Disruptor](https://blog.scottlogic.com/2021/12/01/disruptor.html)
* 9: [Scrambling Eggs for Spotify with Knuth's Fibonacci Hashing](https://pncnmnp.github.io/blogs/fibonacci-hashing.html)
* 8: [Capturing a Java Thread Dump](https://www.baeldung.com/java-thread-dump)
* 7: [Manipulation with ASM](https://www.baeldung.com/java-asm)
* 6: [A Simple Explanation of How Shares Move Around the Securities Settlement System](https://gendal.me/2014/01/05/a-simple-explanation-of-how-shares-move-around-the-securities-settlement-system/)
* 5: [A Simple Explanation of Balance Sheets](https://gendal.me/2015/07/05/a-simple-explanation-of-balance-sheets-dont-run-away-its-interesting-really/)
* 4: [A simple explanation of how money moves around the banking system](https://gendal.me/2013/11/24/a-simple-explanation-of-how-money-moves-around-the-banking-system/)
* 3: <https://github.com/donnemartin/system-design-primer>

  > Latency numbers every programmer should know,
  >
  > * L1 cache reference 0.5 ns
  > * Branch mispredict 5 ns
  > * L2 cache reference 7 ns
  > * Mutex lock/unlock 25 ns
  > * Main memory reference 100 ns
  > * ...


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.damonyuan.com/gems/2024-gems.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
