惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recent Announcements
Recent Announcements
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News | PayPal Newsroom
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
S
Security @ Cisco Blogs
K
Kaspersky official blog
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Last Watchdog
The Last Watchdog
T
The Exploit Database - CXSecurity.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Security Archives - TechRepublic
Security Archives - TechRepublic
V
V2EX
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
F
Full Disclosure
I
Intezer
Schneier on Security
Schneier on Security
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 聂微东
M
MIT News - Artificial intelligence
P
Privacy & Cybersecurity Law Blog
Attack and Defense Labs
Attack and Defense Labs
量子位
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
C
Check Point Blog
N
Netflix TechBlog - Medium
博客园 - Franky
SecWiki News
SecWiki News
Know Your Adversary
Know Your Adversary
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
S
Securelist

Stonecharioteer on Tech

I Traced My Traffic Through a Home Tailscale Exit Node What Was I Reading Last? In Three Not-So-Easy Pieces Dogfooding Is Hard Code blocks in your books, finally GoForGo v0.9.0 Merrilin - We built an app to read books I use a Macbook now Data Structures & Algorithms - Preparing for Interviews Using a local DNS namespace for local service discovery Direction KOllector - Publishing KOReader Highlights gbt: branches touched in the last 24 hours A Soiree into Symbols in Ruby Some Smalltalk about Ruby Loops Ruby Blocks Returning from Ruby Blocks, Procs and Lambdas My Linux Laptop Finally Works: How Claude Helped Me Fix Years of Annoyances TIL: Watchexec - Modern File Watching for Development Workflows A Less Busy Mind GoForGo - Learn Go through live examples Migrating My Old Blog to Hugo with Claude The Qtile Window Manager: A Python-Powered Tiling Experience Read the RFCs that Built the Internet Py-x-Protobuf - Or How I Learned to Stop Worrying and Love Protocol Buffers Python Reverse a List New Beginnings Leaving ChainSafe Systems Screen Lock for Cinnamon Desktop using Zenity and Terminal Commands Crews Not Teams A System for Getting Better at LeetCode So Far So Rust Retrying HTTP Requests with Rust A Primer on Control Charts Learning Rust Explicit is Better than Implicit: Rust for Pythonistas Using Custom Delimiters in Jinja Templates TIL: Creating Fixed Length Iterables in Python Documentation Without Assumption Vagrant Python - A Reflection in 2022 Learning Golang No, A Virtual Machine Is Not Enough: Why Developers Need Native Linux Empathy in Tech For Those Who Came in Late A Weekend With PostgreSQL TIL: Gooey and Python Fire for Quick GUIs and CLIs TIL: 2ality - Dr. Axel Rauschmayer's JavaScript Blog TIL: MassDNS - High-Performance Bulk DNS Lookups TIL: Matomo Analytics, Google Tech Writing, Memory Programming, and NES TV Signals TIL: MontyDB - MongoDB Implemented in Python Returning to the Craft of Programming TIL: CPUFetch, OneFetch, and Learn CSS TIL: DNS Performance Testing and Pi-hole with Unbound TIL: Eli Bendersky's Blog, Awesome By Example, NoCoDB, and Martin Kleppmann TIL: CRDTs, Extreme HTTP Performance, and BYTEPATH Game TIL: AutoInvent, ASGI, Python Packaging, RAPIDS GPU Computing, and FlaskCon TIL: MangaDesk - Terminal Client for MangaDex TIL: McFly - Smart Shell History Search TIL: Siege Load Testing and Awesome FastAPI Resources TIL: Ventoy Bootable USB and Justniffer Network Analysis TIL: CLI Code Review, Git Split Diffs, and Internal Combustion Engine TIL: Benford's Law, Web Security Headers, Event Sourcing, and Mozilla Security Guidelines How to Write Documentation - The README.md File The Importance of Documentation TIL: NNgroup UX Research, SponsorBlock, and Labella Python Library TIL: The Little Book of Rust Macros and Rust Performance Book TIL: Git-Bug Distributed Issue Tracker and Omni Kubernetes Monitoring TIL: Zellij - Modern Terminal Multiplexer TIL: How Discord Handles 2.5 Million Concurrent Voice Users TIL: Volumio - The Audiophile Music Player TIL: Areopagitica - Milton's Defense of Free Speech TIL: Fast Node Manager, Zoxide Smart CD, Technical Writing, PyO3, and Qubes OS TIL: Slurm Workload Manager for HPC Clusters TIL: Data Visualization Guide and Oso Authorization Academy TIL: CORS Deep Dive, Piku Tiny PaaS, Rust Strings, and Deno Standard Library TIL: Raspberry Pi OS Development, Vim Beginner Guide, Password Management, and QueryBook TIL: uBlock Origin Performance Optimization on Firefox TIL: Breaking PostgreSQL at Scale and LeetCode Problem Patterns TIL: Awesome Tmux Resources for Terminal Multiplexing TIL: Grit - A Multitree-Based Personal Task Manager TIL: Lens 4.2 Kubernetes IDE, Shell Scripting Guide, and Dark HTTP Server Do The Job You Hate So You Won't Hate The Job You Love TIL: Innernet VPN Solution and NoteCalc Calculator App TIL: Argo CD for GitOps and Lens Kubernetes IDE TIL: Modern Rust CLI Tools - System Monitoring, HTTP Requests, and DNS TIL: tz - A Time Zone Helper Tool TIL: Distributed Systems Education, Fallacies, and Self-Hosted Internet Archiving TIL: Real-Time Voice Cloning Technology TIL: ChartMuseum for Helm, AMD's Corporate Journey, and Kubernetes Pod Scaling TIL: Docker and Kubernetes Tools - Whaler, Descheduler, and Dive TIL: Post-Mortem Collection, Terminal Plotting, and Technical Twitter TIL: Dark Mode Toggle Web Component by Google Chrome Labs TIL: Python eval(), exec(), and compile() Functions TIL: Camelot PDF Tables, PostgreSQL Row Level Security, Zerodha Varsity, and Write Yourself a Git TIL: fuser Command for Process and File Investigation TIL: i Hate Regex - The Ultimate Regex Cheat Sheet TIL: Dolt - Git for Data and Database Version Control TIL: x86 Assembly Programming and SafeEyes Break Reminder TIL: Comprehensive Distributed Systems Reading List TIL: Cosmopolitan C Library, Distributed Systems Book, High Performance Browser Networking, and Rust Roguelike Tutorial
TIL: Guile Scheme Compiler, Category Theory for Programmers, SICP, and Linux Process Tracking
2020-08-11 · via Stonecharioteer on Tech

Today’s learning spanned from advanced programming language theory to practical Linux system administration challenges.

Guile Scheme Baseline Compiler

A Baseline Compiler for Guile describes modern compiler development for the GNU Guile Scheme implementation:

Compiler Architecture:

Traditional Guile Compilation Pipeline:

1
2
3
4
5
;; Guile's traditional approach
Source Code  Tree-IL  CPS  Bytecode  VM

;; New baseline compiler approach
Source Code  Tree-IL  Direct Machine Code

Baseline Compiler Benefits:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
;; Traditional interpreted execution
(define (fibonacci n)
  (if (<= n 1)
      n
      (+ (fibonacci (- n 1))
         (fibonacci (- n 2)))))

;; With baseline compiler:
;; - Faster startup (no CPS conversion)
;; - Better debugging (clearer stack traces)
;; - Incremental optimization opportunity
;; - Reduced memory pressure

Implementation Strategy:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
;; Compiler generates direct assembly
(define-compiler-pass (compile-application app)
  (match app
    [($ <application> src proc args)
     (let* ([proc-code (compile-expr proc)]
            [args-code (map compile-expr args)]
            [argc (length args)])
       `(begin
          ,@proc-code
          ,@(append-map (lambda (arg) arg) args-code)
          (call-with-argc ,argc)))]))

;; Register allocation and stack management
(define (allocate-registers exprs)
  (fold (lambda (expr regs)
          (assign-registers expr regs))
        (make-register-set)
        exprs))

Performance Implications:

Startup Time Optimization:

  • Reduced compilation phases: Direct translation without intermediate representations
  • Lazy optimization: Optimize hot paths after profiling
  • Incremental compilation: Compile functions as needed
  • Better caching: Store compiled code for reuse

Runtime Characteristics:

  • Predictable performance: Consistent execution patterns
  • Debugging support: Maintain source location information
  • Memory efficiency: Reduced intermediate data structures
  • Interoperability: Better C foreign function interface

Bartosz Milewski’s Category Theory for Programmers bridges mathematical concepts with practical programming:

Core Category Theory Concepts:

Categories and Morphisms:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
-- Category consists of objects and morphisms (arrows)
-- In programming: types are objects, functions are morphisms

-- Identity morphism
id :: a -> a
id x = x

-- Composition of morphisms
compose :: (b -> c) -> (a -> b) -> (a -> c)
compose g f = \x -> g (f x)

-- Composition is associative
-- compose h (compose g f) = compose (compose h g) f

Functors:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Functor maps between categories
class Functor f where
    fmap :: (a -> b) -> f a -> f b

-- Functor laws:
-- fmap id = id
-- fmap (g . f) = fmap g . fmap f

-- Examples of functors
instance Functor [] where
    fmap = map

instance Functor Maybe where
    fmap _ Nothing = Nothing
    fmap f (Just x) = Just (f x)

-- Using functors
numbers = [1, 2, 3, 4]
squared = fmap (^2) numbers  -- [1, 4, 9, 16]

maybeValue = Just 42
doubled = fmap (*2) maybeValue  -- Just 84

Natural Transformations:

1
2
3
4
5
6
7
8
9
-- Natural transformation between functors
-- Safe head function using Maybe
safeHead :: [a] -> Maybe a
safeHead [] = Nothing
safeHead (x:_) = Just x

-- Length is a natural transformation from [] to Const Int
length :: [a] -> Int
-- Satisfies: length . fmap f = length (naturality condition)

Monads:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Monad as a category theory concept
class Functor m => Monad m where
    return :: a -> m a     -- Unit natural transformation
    (>>=) :: m a -> (a -> m b) -> m b  -- Multiplication

-- Monad laws (category theory requirements):
-- Left identity: return a >>= f = f a
-- Right identity: m >>= return = m
-- Associativity: (m >>= f) >>= g = m >>= (\x -> f x >>= g)

-- IO Monad example
greetUser :: IO ()
greetUser = do
    putStrLn "What's your name?"
    name <- getLine
    putStrLn ("Hello, " ++ name)

-- Desugared version
greetUser' =
    putStrLn "What's your name?" >>= \_ ->
    getLine >>= \name ->
    putStrLn ("Hello, " ++ name)

Kleisli Categories:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
-- Kleisli category for a monad
-- Objects: same as base category
-- Morphisms: a -> m b (where m is a monad)

-- Kleisli composition
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
f >=> g = \x -> f x >>= g

-- Example: composing functions that might fail
safeDivide :: Double -> Double -> Maybe Double
safeDivide _ 0 = Nothing
safeDivide x y = Just (x / y)

safeSquareRoot :: Double -> Maybe Double
safeSquareRoot x
    | x < 0 = Nothing
    | otherwise = Just (sqrt x)

-- Kleisli composition
safeComputation :: Double -> Double -> Maybe Double
safeComputation x y = safeDivide x y >=> safeSquareRoot

Structure and Interpretation of Computer Programs

SICP remains one of the most influential computer science textbooks:

Core SICP Principles:

Abstraction and Modularity:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
;; Building abstractions with procedures
(define (square x) (* x x))

(define (sum-of-squares x y)
  (+ (square x) (square y)))

;; Higher-order procedures
(define (sum term a next b)
  (if (> a b)
      0
      (+ (term a)
         (sum term (next a) next b))))

;; Using higher-order procedures
(define (sum-cubes a b)
  (sum (lambda (x) (* x x x))
       a
       (lambda (x) (+ x 1))
       b))

(define (pi-sum a b)
  (define (pi-term x)
    (/ 1.0 (* x (+ x 2))))
  (define (pi-next x)
    (+ x 4))
  (sum pi-term a pi-next b))

Data Abstraction:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
;; Abstract data types
(define (make-rat n d)
  (let ((g (gcd n d)))
    (cons (/ n g) (/ d g))))

(define (numer x) (car x))
(define (denom x) (cdr x))

(define (add-rat x y)
  (make-rat (+ (* (numer x) (denom y))
               (* (numer y) (denom x)))
            (* (denom x) (denom y))))

;; Using rational numbers
(define one-half (make-rat 1 2))
(define one-third (make-rat 1 3))
(define sum (add-rat one-half one-third))  ; 5/6

Metalinguistic Abstraction:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;; Metacircular evaluator - Scheme interpreter in Scheme
(define (eval exp env)
  (cond ((self-evaluating? exp) exp)
        ((variable? exp) (lookup-variable-value exp env))
        ((quoted? exp) (text-of-quotation exp))
        ((assignment? exp) (eval-assignment exp env))
        ((definition? exp) (eval-definition exp env))
        ((if? exp) (eval-if exp env))
        ((lambda? exp) (make-procedure (lambda-parameters exp)
                                       (lambda-body exp)
                                       env))
        ((begin? exp) (eval-sequence (begin-actions exp) env))
        ((cond? exp) (eval (cond->if exp) env))
        ((application? exp)
         (apply (eval (operator exp) env)
                (list-of-values (operands exp) env)))))

(define (apply procedure arguments)
  (cond ((primitive-procedure? procedure)
         (apply-primitive-procedure procedure arguments))
        ((compound-procedure? procedure)
         (eval-sequence
           (procedure-body procedure)
           (extend-environment
             (procedure-parameters procedure)
             arguments
             (procedure-environment procedure))))))

Linux Process Tracking Challenges

The Difficulties of Tracking Running Processes on Linux explores the complexities of process monitoring:

Process Tracking Methods:

/proc Filesystem Monitoring:

1
2
3
4
5
6
7
8
9
# Basic process information
cat /proc/PID/stat    # Process statistics
cat /proc/PID/status  # Human-readable status
cat /proc/PID/cmdline # Command line that started process
cat /proc/PID/environ # Environment variables

# Process tree relationships
cat /proc/PID/task/   # Thread information
ls /proc/PID/fd/      # Open file descriptors

Race Conditions in Process Monitoring:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import time
from pathlib import Path

def monitor_process_safely(pid):
    """Handle race conditions when monitoring processes"""
    try:
        # Check if process exists
        proc_path = Path(f"/proc/{pid}")
        if not proc_path.exists():
            return None

        # Read multiple files atomically (as much as possible)
        stat_path = proc_path / "stat"
        status_path = proc_path / "status"

        # Race condition: process might disappear between checks
        with stat_path.open() as f:
            stat_data = f.read().strip()

        # Process might have been replaced by another with same PID
        with status_path.open() as f:
            status_data = f.read()

        return {
            'stat': stat_data,
            'status': status_data,
            'timestamp': time.time()
        }

    except (FileNotFoundError, ProcessLookupError, PermissionError):
        # Process disappeared or access denied
        return None

# Handle PID reuse
def track_process_with_start_time(pid):
    """Use start time to identify unique process instances"""
    try:
        with open(f"/proc/{pid}/stat") as f:
            fields = f.read().split()
            start_time = int(fields[21])  # Process start time

        return {
            'pid': pid,
            'start_time': start_time,
            'unique_id': f"{pid}_{start_time}"
        }
    except (FileNotFoundError, IndexError):
        return None

System-Level Process Monitoring:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Process accounting (if enabled)
sudo apt-get install acct
sudo accton /var/log/wtmp

# Monitor process creation/termination
lastcomm | head -10

# Real-time process monitoring
# Using bpftrace (eBPF)
sudo bpftrace -e '
tracepoint:syscalls:sys_enter_execve {
    printf("PID %d exec: %s\n", pid, str(args->filename));
}

tracepoint:syscalls:sys_enter_exit_group {
    printf("PID %d exit\n", pid);
}'

# Using perf events
sudo perf record -e sched:sched_process_exec,sched:sched_process_exit -a sleep 10
sudo perf script

Advanced Monitoring Challenges:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Container process monitoring
def monitor_container_processes(container_id):
    """Monitor processes inside containers"""
    try:
        # Find container's PID namespace
        with open(f"/sys/fs/cgroup/memory/docker/{container_id}/cgroup.procs") as f:
            container_pids = [int(line.strip()) for line in f if line.strip()]

        processes = []
        for pid in container_pids:
            try:
                with open(f"/proc/{pid}/stat") as f:
                    stat_data = f.read().split()
                    processes.append({
                        'pid': pid,
                        'name': stat_data[1].strip('()'),
                        'state': stat_data[2],
                        'ppid': int(stat_data[3])
                    })
            except FileNotFoundError:
                continue  # Process disappeared

        return processes
    except FileNotFoundError:
        return []  # Container not found

Monitoring Tools Comparison:

User-space vs Kernel-space Monitoring:

  • ps/top: Snapshots with race conditions
  • htop: Better real-time display but still snapshots
  • eBPF/BPF: Kernel-level monitoring with lower overhead
  • ftrace: Kernel function tracing
  • perf: Hardware and software event monitoring

These topics demonstrate the depth of computer science knowledge, from theoretical foundations in category theory and language design to practical challenges in system programming and process monitoring.