Skip to content

Refactor frs_habitat: unified pipeline + performance fixes#94

Merged
NewGraphEnvironment merged 5 commits intomainfrom
refactor-habitat
Apr 7, 2026
Merged

Refactor frs_habitat: unified pipeline + performance fixes#94
NewGraphEnvironment merged 5 commits intomainfrom
refactor-habitat

Conversation

@NewGraphEnvironment
Copy link
Copy Markdown
Owner

Summary

Performance

Fix Before After
Threshold recycling (#89) 183s ADMS 54s
Breaks index 54s 39s
Growth penalty fix (#91) 30-58s/species at 1M rows 0.1-1.2s/species at 1.3M rows

Province run completed: 229 WSGs, 5.98M segments, 9.1 hours (before #91 fix).
With #91 fix, 6 WSG benchmark shows flat timing at 1.3M rows — estimate ~4 hours.

Test plan

  • devtools::test() — 528 pass
  • Sequential ADMS: species-specific access (CO 3,719 vs BT 6,338)
  • 6 WSG benchmark: timing stays flat as habitat table grows
  • Province-wide: 229 WSGs completed

Fixes #89, #91
Relates to #83
Relates to NewGraphEnvironment/sred-2025-2026#16

🤖 Generated with Claude Code

NewGraphEnvironment and others added 5 commits April 5, 2026 22:48
Rewrites frs_habitat as a thin orchestrator that per WSG:
1. Generates gradient access barriers at species thresholds
2. Segments network via frs_network_segment (one table, shared geometry)
3. Classifies habitat via frs_habitat_classify (long format, per species)
4. Persists to to_streams + to_habitat tables

Replaces to_prefix with to_streams + to_habitat params.
Species-specific accessibility: CO/CH/SK at 15%, BT/RB at 25%.
mirai parallel: each WSG is one task.

Tested: ADMS sequential — 16,606 segments, 5 species, 183s.
BT/RB: 6,338 accessible. CO/CH/SK: 3,719 accessible.

Relates to #83

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bottleneck is frs_habitat_classify — NOT EXISTS per species without
threshold recycling. ADMS 781s, BULK 2,090s. Fix in #89.

Relates to NewGraphEnvironment/sred-2025-2026#16

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-compute accessibility ONCE per unique access threshold into temp
tables, then JOIN when classifying each species. 5 species with 2
thresholds = 2 queries instead of 5.

ADMS: 183s → 54s. Per-species classify: ~40s → 0.1s.
Composite index on (label, blue_line_key) for breaks table.

Fixes #89

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add .frs_index_working on breaks table after enrichment. Cross-BLK
accessibility query drops from 17s to 1.1s with ltree GIST indexes.

ADMS total: 54s → 39s. Province estimate: ~2.7 hours sequential.

Relates to #89

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add watershed_group_code to habitat table. DELETE uses column filter
instead of id_segment IN (subquery) — constant time regardless of
table size.

Benchmark: 6 WSGs (1.3M habitat rows), timing stays flat.
Per-species: 0.1-1.2s at 1.3M rows (was 30-58s in province run).
Province estimate: ~4 hours (was 8+).

Fixes #91

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NewGraphEnvironment NewGraphEnvironment merged commit 1c00261 into main Apr 7, 2026
1 check passed
@NewGraphEnvironment NewGraphEnvironment deleted the refactor-habitat branch April 7, 2026 04:58
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.

frs_habitat_classify: recycle accessibility by threshold group

1 participant