René's URL Explorer Experiment


Title: Performance [P3]: Lazily load sandbox runtime API exports by berndverst · Pull Request #208 · microsoft/durabletask-python · GitHub

Open Graph Title: Performance [P3]: Lazily load sandbox runtime API exports by berndverst · Pull Request #208 · microsoft/durabletask-python

X Title: Performance [P3]: Lazily load sandbox runtime API exports by berndverst · Pull Request #208 · microsoft/durabletask-python

Description: Summary Importing durabletask.azuremanaged.preview.sandboxes eagerly imported both the sandbox client and the sandbox worker. The worker module pulls in ManagedIdentityCredential from azure-identity plus the core worker graph, so merely touching the sandboxes namespace — even to declare a worker profile or reference a type — paid that entire cost at process startup. This replaces the eager re-exports in the package initializer with PEP 562 lazy exports: a module-level __getattr__ resolves each public name from its defining submodule on first access and caches it in the module globals. TYPE_CHECKING imports keep type checkers, IDEs, and pyright --strict fully aware of the names. Backwards compatibility is preserved exactly: Every exported name and its import path is unchanged. __all__ is byte-for-byte identical, so from ... import * still exports the same six names. dir() still lists the public names (via a module-level __dir__). Submodules (client, helpers, worker, worker_profiles, ...) remain reachable as package attributes, matching the attribute binding the eager imports used to produce as a side effect. Unknown attributes still raise a normal AttributeError. Before / after Measured on the same machine with durabletask and durabletask.azuremanaged installed editable, median of 9 runs each, HEAD~1 vs HEAD: Metric Before (eager) After (lazy) Change -X importtime cumulative for durabletask.azuremanaged.preview.sandboxes 965.7 ms 376.0 ms -61.1% Wall clock, full python -c "import ...sandboxes" process 1144.1 ms 532.5 ms -53.5% len(sys.modules) after import 548 296 -252 modules Raw -X importtime tail lines: before: import time: 852 | 965731 | durabletask.azuremanaged.preview.sandboxes after: import time: 845 | 375998 | durabletask.azuremanaged.preview.sandboxes azure.identity alone accounts for ~890 ms of cumulative import time on this machine, and it is no longer loaded unless SandboxWorker is actually used: before: worker loaded True | azure.identity loaded True after: worker loaded False | azure.identity loaded False Interaction with #196 #196 makes the analogous lazy-export change to the core durabletask/__init__.py. Because the sandboxes package is reached through durabletask, there are two independent doors to the worker graph, and closing only one leaves the other open. Measured here as a full 2x2 on import durabletask.azuremanaged.preview.sandboxes — module counts are deterministic, times are the median of 7 runs of the summed -X importtime self-times (which include the ~87 ms interpreter floor): Configuration Modules Median import time Neither (main) 548 1079.9 ms #196 alone 548 — no change 1037.6 ms #197 alone (this PR) 296 452.7 ms Both 84 92.6 ms Two honest conclusions from that table: #196 alone does nothing for this import path (548 -> 548). The eager sandbox worker import removed by this PR was pulling the core worker graph in directly, bypassing the core initializer's laziness entirely. This PR is the load-bearing change for the sandboxes path. The 296 modules remaining after this PR are grpc/protobuf and friends, still pulled in by the parent durabletask package. That is #196's scope and is deliberately untouched here. With both changes landed the import drops to 84 modules — only 6 above the bare-interpreter floor of 78, i.e. from 470 modules of overhead down to 6. The two PRs are therefore complementary rather than additive, and they touch disjoint files (verified: no path overlap between the branches). These figures were reproduced independently in this worktree; the module counts match the #196 author's measurements exactly. Verification New tests in tests/durabletask-azuremanaged/test_sandboxes_extension.py. Because that module imports the sandbox worker at module scope, the lazy-import assertions run in a subprocess: test_sandbox_package_defers_worker_runtime_imports — asserts ...sandboxes.worker, ...sandboxes.client, ...sandboxes.transport, and azure.identity are absent from sys.modules after importing the package, then asserts __all__, dir(), that every exported name resolves to the same object as a direct import, and that submodule attributes still work. test_sandbox_package_star_import_matches_all — asserts from ... import * yields exactly the __all__ names and does not leak the lazy-import plumbing. test_sandbox_package_raises_attribute_error_for_unknown_attributes — asserts a proper AttributeError and correct hasattr behavior. Confirmed these fail against the pre-change initializer (the lazy-import probe reports client, transport, worker, and azure.identity as eagerly imported). Provider unit tests: test_sandboxes_extension.py + test_durabletask_grpc_interceptor.py — 45 passed (42 before this change, plus the 3 new tests). Core unit tests: pytest tests/durabletask --ignore-glob="*_e2e.py" — 681 passed, 7 skipped, no regressions against the recorded baseline. flake8: clean on both changed Python files. The TYPE_CHECKING imports are resolved properly rather than suppressed — pyflakes treats names listed in __all__ as used, so no noqa was needed. pyright (repo pyrightconfig.json, strict): zero errors in the changed file and zero anywhere under durabletask-azuremanaged/durabletask. pymarkdownlnt: the changelog addition introduces no new findings. autopep8: --diff is empty for both changed files. Fixes #197

Open Graph Description: Summary Importing durabletask.azuremanaged.preview.sandboxes eagerly imported both the sandbox client and the sandbox worker. The worker module pulls in ManagedIdentityCredential from azure-identit...

X Description: Summary Importing durabletask.azuremanaged.preview.sandboxes eagerly imported both the sandbox client and the sandbox worker. The worker module pulls in ManagedIdentityCredential from azure-identit...

Opengraph URL: https://github.com/microsoft/durabletask-python/pull/208

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:4b9eca2a-2e89-bd94-04ee-33ffab82f691
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9FEE:195CE:113E54:16A5F9:6AFE44BC
html-safe-nonce55e1972c753529601b47053fec1c2f6cd2ecffafccf2e5fe6ecf7bddfd714504
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkVFOjE5NUNFOjExM0U1NDoxNkE1Rjk6NkFGRTQ0QkMiLCJ2aXNpdG9yX2lkIjoiMTkzMzIwODM5MjgyMjU3MjIyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaccd15512ea2e9b034989f2414f1afc41eda176face4b54cd77c7fed8af00d9636
hovercard-subject-tagpull_request:4139825635
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/microsoft/durabletask-python/pull/208/files
twitter:imagehttps://avatars.githubusercontent.com/u/4535280?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/4535280?s=400&v=4
og:image:altSummary Importing durabletask.azuremanaged.preview.sandboxes eagerly imported both the sandbox client and the sandbox worker. The worker module pulls in ManagedIdentityCredential from azure-identit...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonef1a5901e2377b0af2a0b303f9528678f1475d04b9219dca1e993344196eaa07c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id627664515
octolytics-dimension-repository_nwomicrosoft/durabletask-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id627664515
octolytics-dimension-repository_network_root_nwomicrosoft/durabletask-python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasece393ea11ad276623b946bc9663d3e7d6f564275
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/durabletask-python/pull/208/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fpull%2F208%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fpull%2F208%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=microsoft%2Fdurabletask-python
Reloadhttps://github.com/microsoft/durabletask-python/pull/208/files
Reloadhttps://github.com/microsoft/durabletask-python/pull/208/files
Reloadhttps://github.com/microsoft/durabletask-python/pull/208/files
microsofthttps://github.com/microsoft
durabletask-pythonhttps://github.com/microsoft/durabletask-python
Codehttps://github.com/microsoft/durabletask-python
Issues15 (15)https://github.com/microsoft/durabletask-python/issues
Pull requests12 (12)https://github.com/microsoft/durabletask-python/pulls
Actionshttps://github.com/microsoft/durabletask-python/actions
Projectshttps://github.com/microsoft/durabletask-python/projects
Security and qualityhttps://github.com/microsoft/durabletask-python/security
Insightshttps://github.com/microsoft/durabletask-python/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmicrosoft%2Fdurabletask-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmicrosoft%2Fdurabletask-python%2Fissues%2Fnew%2Fchoose
Bernd Verst (berndverst)https://github.com/berndverst
mainhttps://github.com/microsoft/durabletask-python/tree/main
berndverst-lazy-sandbox-exportshttps://github.com/microsoft/durabletask-python/tree/berndverst-lazy-sandbox-exports
Conversation 6 https://github.com/microsoft/durabletask-python/pull/208
Commits 5 https://github.com/microsoft/durabletask-python/pull/208/commits
Checks 24 https://github.com/microsoft/durabletask-python/pull/208/checks
Files changed https://github.com/microsoft/durabletask-python/pull/208/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/208/files
Performance [P3]: Lazily load sandbox runtime API exports https://github.com/microsoft/durabletask-python/pull/208/files#top
Show all changes 5 commits https://github.com/microsoft/durabletask-python/pull/208/files
f81efa1 Lazily load sandbox runtime API exports Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/208/commits/f81efa19eaaaa1f32f84d8b53e0250442e3e17b5
1548feb Merge remote-tracking branch 'origin/main' into berndverst-lazy-sandb… Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/208/commits/1548feba3f7b07bf30edae41cb8f5d66be152149
416a8ef Bound the isolated import probe subprocess with a timeout Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/208/commits/416a8ef498d1bd9260cc5492ff76318208291ab8
2cf6a12 Merge remote-tracking branch 'origin/main' into berndverst-lazy-sandb… Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/208/commits/2cf6a12bba2b81382b619b11a3a6eff1736268e8
1ef45d4 Merge remote-tracking branch 'origin/main' into berndverst-lazy-sandb… Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/208/commits/1ef45d448c16e4f811f185ceb1a77ce316f733a3
Clear filters https://github.com/microsoft/durabletask-python/pull/208/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/208/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/208/files
CHANGELOG.md https://github.com/microsoft/durabletask-python/pull/208/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
__init__.py https://github.com/microsoft/durabletask-python/pull/208/files#diff-5350c7ba1aa1425079990e0bc983eafce7fa61df5af6b69ca0b68cd0a124381b
test_sandboxes_extension.py https://github.com/microsoft/durabletask-python/pull/208/files#diff-1623484725e2c99a6166e35b1c3de34ecfad701e2fe111b36461ea0535ef6d5d
durabletask-azuremanaged/CHANGELOG.mdhttps://github.com/microsoft/durabletask-python/pull/208/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
View file https://github.com/microsoft/durabletask-python/blob/1ef45d448c16e4f811f185ceb1a77ce316f733a3/durabletask-azuremanaged/CHANGELOG.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/208/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/208/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
https://github.com/microsoft/durabletask-python/pull/208/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
durabletask-azuremanaged/durabletask/azuremanaged/preview/sandboxes/__init__.pyhttps://github.com/microsoft/durabletask-python/pull/208/files#diff-5350c7ba1aa1425079990e0bc983eafce7fa61df5af6b69ca0b68cd0a124381b
View file https://github.com/microsoft/durabletask-python/blob/1ef45d448c16e4f811f185ceb1a77ce316f733a3/durabletask-azuremanaged/durabletask/azuremanaged/preview/sandboxes/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/208/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/208/files#diff-5350c7ba1aa1425079990e0bc983eafce7fa61df5af6b69ca0b68cd0a124381b
https://github.com/microsoft/durabletask-python/pull/208/files#diff-5350c7ba1aa1425079990e0bc983eafce7fa61df5af6b69ca0b68cd0a124381b
tests/durabletask-azuremanaged/test_sandboxes_extension.pyhttps://github.com/microsoft/durabletask-python/pull/208/files#diff-1623484725e2c99a6166e35b1c3de34ecfad701e2fe111b36461ea0535ef6d5d
View file https://github.com/microsoft/durabletask-python/blob/1ef45d448c16e4f811f185ceb1a77ce316f733a3/tests/durabletask-azuremanaged/test_sandboxes_extension.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/208/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/208/files#diff-1623484725e2c99a6166e35b1c3de34ecfad701e2fe111b36461ea0535ef6d5d
https://github.com/microsoft/durabletask-python/pull/208/files#diff-1623484725e2c99a6166e35b1c3de34ecfad701e2fe111b36461ea0535ef6d5d
https://github.com/microsoft/durabletask-python/pull/208/files#diff-1623484725e2c99a6166e35b1c3de34ecfad701e2fe111b36461ea0535ef6d5d
https://github.com/microsoft/durabletask-python/pull/208/files#diff-1623484725e2c99a6166e35b1c3de34ecfad701e2fe111b36461ea0535ef6d5d
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/208/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.