Skip to content

perf(gptodo): 59x faster task loading by avoiding git subprocess per task#300

Merged
TimeToBuildBob merged 1 commit intomasterfrom
fix/gptodo-load-perf
Feb 17, 2026
Merged

perf(gptodo): 59x faster task loading by avoiding git subprocess per task#300
TimeToBuildBob merged 1 commit intomasterfrom
fix/gptodo-load-perf

Conversation

@TimeToBuildBob
Copy link
Copy Markdown
Member

@TimeToBuildBob TimeToBuildBob commented Feb 17, 2026

Summary

  • When tasks lack a modified field in frontmatter (common — all 87 tasks in Bob's workspace), load_tasks() was spawning 2 git log subprocesses per task to get timestamps
  • With 87 tasks that's 174 subprocess calls, taking 20.5 seconds
  • Fix: use file mtime as fast fallback for missing modified field instead of git log

Benchmark

  • Before: 20.5s to load 87 tasks
  • After: 0.35s to load 87 tasks (59x faster)
  • gptodo status --compact: 21.5s → 0.3s (71x faster)

Test plan

  • All 50 gptodo tests pass
  • Verified gptodo status --compact shows correct task listing
  • Modified dates still show reasonable values (file mtime-based)

Important

Optimize task loading in utils.py by using file mtime instead of git log for missing modified fields, improving performance by 59x.

  • Performance Improvement:
    • In load_tasks() in utils.py, replaced git log subprocess calls with file mtime checks for tasks missing modified field.
    • Reduces task loading time from 20.5s to 0.35s for 87 tasks.
  • Benchmark:
    • gptodo status --compact execution time reduced from 21.5s to 0.3s.
  • Testing:
    • All 50 gptodo tests pass.
    • Verified correct task listing and reasonable modified dates using file mtime.

This description was created by Ellipsis for 31e390e. You can customize this summary. It will automatically update as commits are pushed.

When tasks lack a 'modified' field in frontmatter (common — 87/87 tasks
in Bob's workspace), load_tasks() was spawning 2 git-log subprocesses
per task to get timestamps. With 87 tasks that's 174 subprocess calls.

Fix: use file mtime as the fast fallback for missing 'modified' field.
Only fall back to git when 'created' is also missing/unparseable.

Before: 20.5s to load 87 tasks
After:  0.35s to load 87 tasks (59x faster)
Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 31e390e in 13 seconds. Click for details.
  • Reviewed 55 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_ypOB9cHC43fRck4k

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 17, 2026

Greptile Summary

Replaced expensive git log subprocess calls with filesystem mtime for task timestamp loading when modified field is missing from frontmatter, achieving 59x performance improvement (20.5s → 0.35s for 87 tasks).

  • Removed 2 git subprocess calls per task (174 total for 87 tasks)
  • Now uses stats.st_mtime as fast fallback for missing modified field
  • Still uses stats.st_ctime as fallback for missing created field
  • All 50 gptodo tests pass
  • Maintains reasonable timestamp values using file modification time

Confidence Score: 4/5

  • Safe to merge with low risk - effective performance optimization with maintained correctness
  • Code simplifies timestamp handling by removing complex git subprocess logic in favor of filesystem timestamps. All 50 existing tests pass, demonstrating that the behavior change is acceptable. The optimization is well-targeted at the actual bottleneck (missing modified field is common). Minor concern about st_ctime semantics on Linux (metadata change time vs creation time), but this was already present in fallback code.
  • No files require special attention

Important Files Changed

Filename Overview
packages/gptodo/src/gptodo/utils.py Replaced expensive git subprocess calls with fast filesystem mtime fallback for task timestamp loading, achieving 59x speedup

Flowchart

flowchart TD
    A[load_tasks starts] --> B[Read task file]
    B --> C[Parse frontmatter metadata]
    C --> D{created field<br/>in metadata?}
    D -->|Yes| E[Parse created timestamp]
    D -->|No| F[Use st_ctime fallback]
    E --> G{modified field<br/>in metadata?}
    F --> G
    G -->|Yes| H[Parse modified timestamp]
    G -->|No| I[Use st_mtime fallback<br/>NEW: Fast path]
    H --> J[Create TaskInfo object]
    I --> J
    J --> K[Return task]
    
    style I fill:#90EE90
    style G fill:#FFE4B5
    
    L[OLD: Missing modified] -.->|Used to spawn| M[git log subprocess<br/>174 calls for 87 tasks<br/>20.5 seconds]
    M -.->|Removed| N[X]
    
    style M fill:#FFB6C6
    style N fill:#FF6B6B
Loading

Last reviewed commit: 31e390e

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@TimeToBuildBob TimeToBuildBob merged commit f3deabe into master Feb 17, 2026
51 checks passed
@TimeToBuildBob TimeToBuildBob deleted the fix/gptodo-load-perf branch February 17, 2026 12:32
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.

1 participant