From 8a15ba370aab26720a277c9e62092a77772193df Mon Sep 17 00:00:00 2001 From: Chris Garrett Date: Tue, 24 Mar 2020 17:53:21 -0700 Subject: [PATCH] [PERF] Removes the Errors created for autotracking transactions These errors are expensive to generate, and have become problematic for development mode in general. The plan is to remove them for now, and try to bring them back some time in the future in a opt-in way that is more conventional and comprehensive (e.g. show all possible consumption locations, not just the first one). --- packages/@glimmer/validator/lib/debug.ts | 18 ++++-------------- packages/@glimmer/validator/lib/tracking.ts | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/@glimmer/validator/lib/debug.ts b/packages/@glimmer/validator/lib/debug.ts index 98f8231f81..4bf111e1d6 100644 --- a/packages/@glimmer/validator/lib/debug.ts +++ b/packages/@glimmer/validator/lib/debug.ts @@ -3,7 +3,6 @@ import { DEBUG } from '@glimmer/env'; interface AutotrackingTransactionSourceData { context?: string; - error: Error; } export let runInAutotrackingTransaction: @@ -22,7 +21,7 @@ export let assertTagNotConsumed: | undefined | ((tag: Tag, obj?: T, keyName?: keyof T | string | symbol, forceHardError?: boolean) => void); -export let markTagAsConsumed: undefined | ((_tag: Tag, sourceError: Error) => void); +export let markTagAsConsumed: undefined | ((_tag: Tag) => void); if (DEBUG) { let DEPRECATE_IN_AUTOTRACKING_TRANSACTION = false; @@ -145,25 +144,16 @@ if (DEBUG) { message.push(`\`${String(keyName)}\` was first used:\n\n${sourceData.context}`); } - if (sourceData.error.stack) { - let sourceStack = sourceData.error.stack; - let thirdIndex = nthIndex(sourceStack, '\n', 3); - sourceStack = sourceStack.substr(thirdIndex); - - message.push(`Stack trace for the first usage: ${sourceStack}`); - } - message.push(`Stack trace for the update:`); return message.join('\n\n'); }; - markTagAsConsumed = (_tag: Tag, sourceError: Error) => { + markTagAsConsumed = (_tag: Tag) => { if (!AUTOTRACKING_TRANSACTION || AUTOTRACKING_TRANSACTION.has(_tag)) return; AUTOTRACKING_TRANSACTION.set(_tag, { context: debuggingContexts!.map(c => c.replace(/^/gm, ' ').replace(/^ /, '-')).join('\n\n'), - error: sourceError, }); // We need to mark the tag and all of its subtags as consumed, so we need to @@ -172,11 +162,11 @@ if (DEBUG) { let tag = _tag as any; if (tag.subtag) { - markTagAsConsumed!(tag.subtag, sourceError); + markTagAsConsumed!(tag.subtag); } if (tag.subtags) { - tag.subtags.forEach((tag: Tag) => markTagAsConsumed!(tag, sourceError)); + tag.subtags.forEach((tag: Tag) => markTagAsConsumed!(tag)); } }; diff --git a/packages/@glimmer/validator/lib/tracking.ts b/packages/@glimmer/validator/lib/tracking.ts index cdb941a0b4..8544eeb4bc 100644 --- a/packages/@glimmer/validator/lib/tracking.ts +++ b/packages/@glimmer/validator/lib/tracking.ts @@ -31,7 +31,7 @@ class Tracker { this.tags.add(tag); if (DEBUG) { - markTagAsConsumed!(tag, new Error()); + markTagAsConsumed!(tag); } this.last = tag;