Practical Engineering
open-menu closeme
Engineering
github linkedin rss
  • Mind ordering cycles in systemd: how systemd breaks them can brick the server start up

    calendar Oct 16, 2024 · 3 min read · Linux  ·
    Share on: twitter copy

    I've been building a service for a month and the day finally arrived when I had the artifact - an EC2 AMI. The AMI passed my "rigourous" manual tests, and I felt confident on a Ruby Tuesday, so I launched 100 EC2 instances using the AMI. Surprise! around 28 instances failed to launch. What is going on? All …


    Read More
  • Monotonicity: Find 1-3-2 Pattern

    calendar Oct 14, 2024 · 3 min read · Algorithms Interview  ·
    Share on: twitter copy

    Given an array of numbers A, find out whether it contains a 1-3-2 pattern. An 1-3-2 pattern is a subsequence of three numbers, A[i], A[j] and A[k] such that i<j<k and A[i] < A[k] < A[j]. For clarity, let's call the 1-3-2 pattern the Bronze-Gold-Silver pattern. If A[j] is Gold, then we should consider the …


    Read More
  • Hoare Partition, one of the simplest and most beautiful algorithms

    calendar Jun 17, 2024 · 4 min read · Algorithms  ·
    Share on: twitter copy

    Tony Hoare invented QuickSort in 1961. At the time of its publication, the best comparison-based sorting algorithm was merge sort. Merge sort divides an unordered array into two equally sized subarrays, sorts each subarray, and then merge the two subarrays to produce a sorted array. Merge sort is simple to understand. …


    Read More
  • No More Confusion of Upstream and Downstream

    calendar Mar 7, 2024 · 3 min read · Guide  ·
    Share on: twitter copy

    I often find myself confused by "upstream" and "downstream", in the context of software development. They bother me so much that I avoid using them in my own writing and I have to pause whenever I see them. In this post, I'll show a simple rule that helps you remember the difference: downstream adds …


    Read More
  • False data independency: a look at cache line and write combining

    calendar Feb 23, 2024 · 7 min read · Go Computer Architecture  ·
    Share on: twitter copy

    Modern CPUs operate significantly faster than memories. A 4.5 GHz x64 CPU operates 30 times faster than a 6000 MHz DDR5 memory of CAS Latency 36. Adding latencies incurred by the bus and memory coherency protocols, memory could be 100 times slower than registers. To mitigate the speed gap, CPU uses layers of caches, …


    Read More
  • Binary Search in Go standard library

    calendar Feb 11, 2024 · 4 min read · Go  ·
    Share on: twitter copy

    Given a non-decreasing array and a target value, we can find the target in logarithmic time using binary search. My first programming language is C++ and the C++ Standard Template Library (STL) provides two functions for this task. iterator lower_bound(first, last, value) returns the smallest index with a value larger …


    Read More
  • Monotonic Stack: Steps to Make Array Non-decreasing

    calendar Jan 28, 2024 · 3 min read · Interview Algorithms  ·
    Share on: twitter copy

    Problem Given an integer array A, in one step, remove all elements A[i] where A[i-1] > A[i]. Return the number of steps performed until A becomes a non-decreasing array. See examples at LeetCode 2289. Solution The naive approach executes steps one by one. Store integers in a Linked List. At each step, find all …


    Read More
  • Calculate number of nodes in a linear network using message passing

    calendar Jan 20, 2024 · 4 min read · Interview  ·
    Share on: twitter copy

    Problem In a connected network consisting of N nodes, each node is connected to either one or two neighbors, forming a line topology. The task is to develop a program that runs on each node, calculating the total number of nodes in the network. Each node is aware of its neighboring nodes and can exchange messages with …


    Read More
  • Nested Map: Breakdown analysis of events and return result as nested JSON

    calendar Jan 19, 2024 · 3 min read · Interview Go  ·
    Share on: twitter copy

    Problem An event consists of multiple properties, each defined as a key-value pair, where the key is a string and the value is of a primitive type such as numbers or strings. Importantly, each event must include a mandatory 'Name' property. Given a list of events, the task is to count the number of events based on …


    Read More
  • Factorial Growth of Subqueries When Using Nested WITH Clauses in ClickHouse

    calendar Jan 12, 2024 · 5 min read · Databases  ·
    Share on: twitter copy

    ClickHouse is a popular OLAP database. It speaks SQL and earns the reputation of "fast and resource efficient". But the support of SQL comes with surprises if not careful. In this blog, I show that a simple query of nested WITH clauses in ClickHouse generates factorial number of subqueries. The simple query …


    Read More
    • ««
    • «
    • 1
    • 2
    • 3
    • 4
    • »
    • »»

Peng Zhang

Software Engineer

Recent Posts

  • A Few Shell Surprises
  • x509: certificate signed by unknown authority? Maybe the cert pool is empty
  • Lessons from an errgroup and Context mishap
  • Avoid panic on expected errors: lessons from operating journald-to-cwl
  • GPG is still in use to verify downloads
  • Why does GOMEMLIMIT take up significant physical memory for unused virtual memory?
  • Logs default to stderr in Go and other languages: avoid using stderr to determine program success.
  • AL2023 vs. AL2: less disk space with ext4?

Tags

GO 15 ALGORITHMS 8 INTERVIEW 7 LINUX 7 GUIDE 3 CONTAINER 2 DISTRIBUTED-SYSTEM 2 WEB 2 BOTTLEROCKET 1 COMPUTER-ARCHITECTURE 1 CONCURRENCY 1 CRYPTOGRAPHY 1 DATABASES 1 SELINUX 1
All Tags
ALGORITHMS8 BOTTLEROCKET1 COMPUTER-ARCHITECTURE1 CONCURRENCY1 CONTAINER2 CRYPTOGRAPHY1 DATABASES1 DISTRIBUTED-SYSTEM2 GO15 GUIDE3 INTERVIEW7 LINUX7 SELINUX1 SHELL1 TESTING1 WEB2
[A~Z][0~9]
Peng Zhang

Copyright 2022-  PENG ZHANG. All Rights Reserved

to-top