Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
## 2026-07-12 - Optimize renderTaskRow DOM allocations
**Learning:** Caching unattached template nodes and instantiating them via `.cloneNode(false)` reduces DOM instantiation overhead in O(N) render loops significantly.
**Action:** Apply this optimization to other hot-path rendering elements such as rows, cells, and stack containers.
## 2026-08-31 - [High-performance metric aggregation]
**Learning:** For high-performance O(N) loops in JavaScript, replacing `Array.prototype.reduce`/`forEach` and `Map` caching with standard `for` loops and typed arrays (`Float64Array`) eliminates JS engine callback allocation, garbage collection, and hash-lookup overhead. This allows for faster metric computations, specifically when iterating over large datasets in hot code paths.
**Action:** Use typed arrays over Maps for O(N) primitive storage caches when iteration indices map directly to indices, and use `for` loops instead of functional iteration methods for critical hot paths.
22 changes: 13 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1370,21 +1370,25 @@ function validateDateRange(startLabel, startValue, endLabel, endValue, errors) {
}

function computeTaskMetrics() {
// ⚡ Bolt: Cache durationDays during total calculation to avoid recalculating for every task
const durationCache = new Map();
const totalDays = state.tasks.reduce((sum, task) => {
// ⚡ Bolt: Replace Map and array methods with Float64Array and for-loops to reduce GC overhead
const durationCache = new Float64Array(state.tasks.length);
let totalDays = 0;

for (let i = 0; i < state.tasks.length; i++) {
const task = state.tasks[i];
const duration = calculateDurationDays(task.plannedStartDate, task.plannedEndDate);
durationCache.set(task.id, duration);
return sum + duration;
}, 0);
durationCache[i] = duration;
totalDays += duration;
}

const baseDate = state.baseDate;
const byTask = new Map();
let totalWeightedPlannedRatio = 0;
let totalWeightedActualRatio = 0;

state.tasks.forEach((task) => {
const durationDays = durationCache.get(task.id);
for (let i = 0; i < state.tasks.length; i++) {
const task = state.tasks[i];
const durationDays = durationCache[i];
Comment on lines +1374 to +1391

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Index cache remains aligned

Both loops synchronously traverse unchanged state.tasks order. calculateDurationDays cannot mutate it, so each cached duration remains paired with its task.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

const weightRatio = totalDays > 0 ? durationDays / totalDays : 0;
const plannedProgressRatio = calculatePlannedProgressRatio(baseDate, task.plannedStartDate, task.plannedEndDate, durationDays);
const actualProgressRatio = (ACTUAL_PROGRESS_MAP[task.actualProgressStatus] || 0) / 100;
Expand All @@ -1408,7 +1412,7 @@ function computeTaskMetrics() {
plannedDateWarning,
actualDateWarning
});
});
}

return {
totalDays,
Expand Down
Loading