-
Notifications
You must be signed in to change notification settings - Fork 455
perf: reduce calls to Path.resolve #14460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Calls to `Path.resolve` turn out to be quite expensive. We try to avoid them by checking whether a Path object actually needs to be resolved. In many cases, we just need to check whether the path is absolute or a link and then only resolve when necessary.
|
Bootstrap import analysisComparison of import times between this PR and base. SummaryThe average import time from this PR is: 279 ± 4 ms. The average import time from base is: 275 ± 5 ms. The import time difference between this PR and base is: 3.9 ± 0.2 ms. Import time breakdownThe following import paths have appeared:
|
Performance SLOsCandidate: prf/avoid-resolve-calls (89c7fa4) ❌ Test Failures (4 suites)❌ djangosimple - 16/26🔵 No baseline data available for this suite ❌ appsecTime: ✅ 20.654ms (SLO: <22.300ms -7.4%) Memory: ❌ 66.629MB (SLO: <66.000MB +1.0%) ✅ exception-replay-enabledTime: ✅ 1.368ms (SLO: <1.450ms -5.7%) Memory: ✅ 64.821MB (SLO: <66.000MB 🟡 -1.8%) ❌ iastTime: ✅ 20.687ms (SLO: <22.250ms -7.0%) Memory: ❌ 66.620MB (SLO: <66.000MB +0.9%) ✅ profilerTime: ✅ 15.312ms (SLO: <16.550ms -7.5%) Memory: ✅ 52.868MB (SLO: <53.500MB 🟡 -1.2%) ✅ span-code-originTime: ✅ 26.386ms (SLO: <28.200ms -6.4%) Memory: ✅ 67.760MB (SLO: <68.500MB 🟡 -1.1%) ❌ tracerTime: ✅ 20.635ms (SLO: <21.750ms -5.1%) Memory: ❌ 66.627MB (SLO: <66.000MB +1.0%) ❌ tracer-and-profilerTime: ✅ 22.377ms (SLO: <23.500ms -4.8%) Memory: ❌ 67.633MB (SLO: <67.000MB +0.9%) ❌ tracer-dont-create-db-spansTime: ✅ 19.497ms (SLO: <21.500ms -9.3%) Memory: ❌ 66.629MB (SLO: <66.000MB +1.0%) ❌ tracer-nativeTime: ✅ 20.689ms (SLO: <21.750ms -4.9%) Memory: ❌ 67.823MB (SLO: <66.000MB +2.8%) ❌ tracer-no-cachesTime: ✅ 18.549ms (SLO: <19.650ms -5.6%) Memory: ❌ 66.665MB (SLO: <66.000MB +1.0%) ❌ tracer-no-databasesTime: ✅ 18.932ms (SLO: <20.100ms -5.8%) Memory: ❌ 66.277MB (SLO: <66.000MB +0.4%) ❌ tracer-no-middlewareTime: ✅ 20.424ms (SLO: <21.500ms -5.0%) Memory: ❌ 66.672MB (SLO: <66.000MB +1.0%) ❌ tracer-no-templatesTime: ✅ 20.569ms (SLO: <22.000ms -6.5%) Memory: ❌ 66.622MB (SLO: <66.000MB +0.9%) ❌ errortrackingdjangosimple - 3/6🔵 No baseline data available for this suite ❌ errortracking-enabled-allTime: ✅ 18.199ms (SLO: <19.850ms -8.3%) Memory: ❌ 66.633MB (SLO: <65.500MB +1.7%) ❌ errortracking-enabled-userTime: ✅ 18.188ms (SLO: <19.400ms -6.2%) Memory: ❌ 66.528MB (SLO: <65.500MB +1.6%) ❌ tracer-enabledTime: ✅ 18.148ms (SLO: <19.450ms -6.7%) Memory: ❌ 66.530MB (SLO: <65.500MB +1.6%) ❌ flasksimple - 15/17🔵 No baseline data available for this suite ✅ appsec-getTime: ✅ 4.592ms (SLO: <4.750ms -3.3%) Memory: ✅ 63.819MB (SLO: <64.500MB 🟡 -1.1%) ✅ appsec-postTime: ✅ 6.622ms (SLO: <6.750ms 🟡 -1.9%) Memory: ✅ 64.232MB (SLO: <64.500MB 🟡 -0.4%) ✅ appsec-telemetryTime: ✅ 4.590ms (SLO: <4.750ms -3.4%) Memory: ✅ 63.858MB (SLO: <64.500MB 🟡 -1.0%) ✅ debuggerTime: ✅ 1.857ms (SLO: <2.000ms -7.1%) Memory: ✅ 44.748MB (SLO: <45.000MB 🟡 -0.6%) ✅ iast-getTime: ✅ 1.857ms (SLO: <2.000ms -7.1%) Memory: ✅ 44.099MB (SLO: <49.000MB 📉 -10.0%) ❌ profilerTime: ✅ 1.917ms (SLO: <2.100ms -8.7%) Memory: ❌ 46.812MB (SLO: <46.500MB +0.7%) ✅ tracerTime: ✅ 3.376ms (SLO: <3.650ms -7.5%) Memory: ✅ 52.770MB (SLO: <53.500MB 🟡 -1.4%) ❌ tracer-nativeTime: ✅ 3.383ms (SLO: <3.650ms -7.3%) Memory: ❌ 54.028MB (SLO: <53.500MB +1.0%) ❌ flasksqli - 5/6🔵 No baseline data available for this suite ✅ appsec-enabledTime: ✅ 3.966ms (SLO: <4.200ms -5.6%) Memory: ✅ 64.055MB (SLO: <66.000MB -2.9%) ❌ iast-enabledTime: ✅ 2.545ms (SLO: <2.800ms -9.1%) Memory: ❌ 59.553MB (SLO: <59.000MB +0.9%) ✅ tracer-enabledTime: ✅ 2.095ms (SLO: <2.250ms -6.9%) Memory: ✅ 52.652MB (SLO: <53.500MB 🟡 -1.6%) 🔵 No Baseline Data (20 suites)🔵 coreapiscenario - 12/12 (2 unstable)🔵 No baseline data available for this suite
|
Calls to
Path.resolve
turn out to be quite expensive. We try to avoid them by checking whether a Path object actually needs to be resolved. In many cases, we just need to check whether the path is absolute or a link and then only resolve when necessary.Performance Analysis
We take Symbol DB as a part of the codebase that exercises the code of interest. The before flame graph shows the CPU cost of calls to
resolve
. The after flame graph shows how they can be avoided in many cases.Before
After
Checklist
Reviewer Checklist