zlob Challenges glibc's Outdated Globbing With Modern Speed and Features
#Regulation

zlob Challenges glibc's Outdated Globbing With Modern Speed and Features

Startups Reporter
1 min read

A new open-source globbing library called zlob offers POSIX-compatible file pattern matching with modern features like recursive patterns and gitignore support, boasting up to 10x speed improvements over glibc.

Featured image

The humble glob() function—a workhorse for file pattern matching in Unix-like systems—has remained largely unchanged in glibc for decades. Dmitry Kovalenko's new zlob library challenges this status quo with a modern implementation that delivers significant performance gains while adding contemporary features developers expect.

zlob rethinks globbing from first principles. Unlike glibc's implementation, which suffers from mandatory sorting bottlenecks and lacks modern syntax, zlob supports recursive ** patterns, brace expansion (*.{c,h}), bash-style extended globs (@(a|b).c), and native .gitignore handling. Crucially, it achieves this while maintaining 100% POSIX and glibc compatibility, passing over 450 tests from glibc, Rust's glob crate, and Node.js.

Performance comes from architectural optimizations:

  • SIMD acceleration for pattern matching, leveraging Zig's portable SIMD support
  • Direct getdents64 system calls for faster directory traversal
  • Pre-analysis of patterns to skip irrelevant directories (e.g., treating ./drivers/**/*.c as two separate operations)
  • Optimized handling of common cases like multi-extension patterns (*.{c,rs,zig}) using bitmask matching

Benchmarks show 1.2–1.7× speedups for typical workflows and up to 10× improvements for recursive patterns against large directories. The library also includes quality-of-life enhancements like path length metadata in results and a MatchPaths mode for batch-processing existing file lists without filesystem access.

Available as a C library, Zig package, and Rust crate, zlob uses Zig's toolchain for compilation. Its MIT license removes adoption barriers, though building requires Zig 0.15.2. The API mirrors POSIX glob with extensions like ZLOB_GITIGNORE for automatic .gitignore handling and ZLOB_RECOMMENDED flags enabling modern defaults.

For developers wrestling with globbing performance in resource-intensive tools (think build systems or file scanners), zlob represents a practical upgrade path. Its avoidance of hype—focusing instead on measurable optimizations and backward compatibility—signals a maturation point for foundational Unix utilities long overdue for renovation.

Comments

Loading comments...