Skip to content

📝 Add performance optimization design document - #37

Merged
juftin merged 8 commits into
juftin:mainfrom
jufty-bot:main
Jul 21, 2026
Merged

📝 Add performance optimization design document#37
juftin merged 8 commits into
juftin:mainfrom
jufty-bot:main

Conversation

@jufty-bot

Copy link
Copy Markdown
Contributor

Summary

Adds OPTIMIZATION.md — a detailed performance optimization design document and updated CHECKLIST.md with Phase 6 tracking.

Context

Current benchmark state: 14 faster, 21 slower, 4 at parity vs CPython 3.14 pathlib.

Three-Win Strategy

  1. Shallow parsing — Skip full parse for ops that only need byte-level manipulation (parent, truediv, joinpath, with_*). Currently all trigger full parse + per-part allocations.

  2. _make_child_fast — Direct Rust-native path construction with subclass-override detection. Cuts 3 FFI crossings per result down to 1.

  3. Inline short pathsCompactOsString (30-byte inline), OnceLock replacing Mutex for path_info, inlined ParsedPath (no Box). Drops construction from 7 → 1 heap allocation.

Contents

  • Root-cause analysis for each slow benchmark
  • Allocation profiling (where every byte comes from)
  • Rust code sketches for proposed fixes
  • 6-step implementation plan with verification gates
  • Projected benchmark outcomes per step

Test Plan

  • make fmt-check-rust passes
  • Implementation TBD — doc-only PR

juftin added 8 commits July 20, 2026 20:12
Three-big-wins strategy for closing the 21-benchmark performance
gap vs CPython pathlib:
1. Shallow parsing — skip full parse for ops that don't need it
2. _make_child_fast — direct Rust construction, no Python round-trip
3. Inline short paths — CompactOsString + OnceLock + inline ParsedPath

Detailed root-cause analysis, Rust code sketches, allocation
profiling, implementation plan in 6 steps with verification gates.
BENCHMARKS.md, CHECKLIST.md, DESIGN.md, OPTIMIZATION.md → docs/
Update all cross-references in README.md and AGENTS.md.
Move verbose code examples, benchmark table, feature coverage,
architecture diagram, and marketing prose to the existing docs/
files they duplicate. README now covers: quick tour, pure/concrete
class tables, benchmark summary, dev commands, doc links.
…ectory

The Makefile copies files directly into site-packages/pathlibrs/,
so the intermediate pathlibrs/ subdir was unnecessary. Update
DESIGN.md file tree and reference.
Move .pyi stubs directly into pathlibrs/ at repo root. No
conflict with the Rust crate (source is in src/, Cargo.toml)
and no import collision (_no_ __init__.py in this directory).
…ckage

Python 3.3+ namespace packages pick up pathlibrs/ directory at repo
root when the working dir is on sys.path. This shadows the installed
.so on CI, causing 'module has no attribute Path' for all tests.
Replace step-summary-only output with a PR comment that updates
in-place on each push using a hidden marker for deduplication.
Benchmark json generated in one job, passed via artifact to a
separate comment-posting job that creates or updates the comment.
Fork PRs get read-only GITHUB_TOKEN so the inline comment job
returns 403. Split into two workflows:
1. ci.yml benchmarks job uploads benchmark-comment.md artifact
2. benchmark-comment.yml triggers on workflow_run completion,
   downloads artifact, posts/updates comment using main-branch
   token with full pull-requests:write permission.
@juftin
juftin merged commit 9df1d6c into juftin:main Jul 21, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants