-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat: improve cold start by generating map fixtures at build time #560
Comments
That sounds like a great idea - it'd be a tradeoff of disk space vs runtime, and I'm quite on the record as not prioritizing disk space. What would the package size/disk space cost be of this approach? |
Ah yes good shout, would def be some chunky fixtures taking up disk space (opposed to just being in-mem at runtime). Not sure off top of my head, but can spin up the branch again to check easy enough and get rough figures! |
Summary
The change appears to reduce cold start by ~81%, also reduce the tarball size by ~7.9 kB, but at the cost of an inflated size on disk by 33.7 kB. So slightly faster cold starts and faster to download the package, but uses more disk. DetailsSpike BranchSee main...jlp-craigmorten:aria-query:spike-generate-maps-build-time. Not production ready(!) for sure, just a hack to get the JSON generated and then manually pasted in. Wouldn't be a big stretch to iron out. Current Package Stats$ npm pack
npm notice
npm notice 📦 [email protected]
npm notice Tarball Contents
npm notice 10.2kB LICENSE
npm notice 7.1kB README.md
npm notice 5.8kB lib/ariaPropsMap.js
npm notice 7.1kB lib/domMap.js
npm notice 6.0kB lib/elementRoleMap.js
npm notice 503B lib/etc/roles/abstract/commandRole.js
npm notice 571B lib/etc/roles/abstract/compositeRole.js
npm notice 596B lib/etc/roles/abstract/inputRole.js
npm notice 519B lib/etc/roles/abstract/landmarkRole.js
npm notice 585B lib/etc/roles/abstract/rangeRole.js
npm notice 1.1kB lib/etc/roles/abstract/roletypeRole.js
npm notice 526B lib/etc/roles/abstract/sectionheadRole.js
npm notice 704B lib/etc/roles/abstract/sectionRole.js
npm notice 593B lib/etc/roles/abstract/selectRole.js
npm notice 489B lib/etc/roles/abstract/structureRole.js
npm notice 483B lib/etc/roles/abstract/widgetRole.js
npm notice 517B lib/etc/roles/abstract/windowRole.js
npm notice 1.6kB lib/etc/roles/ariaAbstractRoles.js
npm notice 5.4kB lib/etc/roles/ariaDpubRoles.js
npm notice 703B lib/etc/roles/ariaGraphicsRoles.js
npm notice 9.6kB lib/etc/roles/ariaLiteralRoles.js
npm notice 746B lib/etc/roles/dpub/docAbstractRole.js
npm notice 779B lib/etc/roles/dpub/docAcknowledgmentsRole.js
npm notice 761B lib/etc/roles/dpub/docAfterwordRole.js
npm notice 758B lib/etc/roles/dpub/docAppendixRole.js
npm notice 681B lib/etc/roles/dpub/docBacklinkRole.js
npm notice 807B lib/etc/roles/dpub/docBiblioentryRole.js
npm notice 789B lib/etc/roles/dpub/docBibliographyRole.js
npm notice 684B lib/etc/roles/dpub/docBibliorefRole.js
npm notice 755B lib/etc/roles/dpub/docChapterRole.js
npm notice 746B lib/etc/roles/dpub/docColophonRole.js
npm notice 764B lib/etc/roles/dpub/docConclusionRole.js
npm notice 744B lib/etc/roles/dpub/docCoverRole.js
npm notice 740B lib/etc/roles/dpub/docCreditRole.js
npm notice 755B lib/etc/roles/dpub/docCreditsRole.js
npm notice 752B lib/etc/roles/dpub/docDedicationRole.js
npm notice 784B lib/etc/roles/dpub/docEndnoteRole.js
npm notice 774B lib/etc/roles/dpub/docEndnotesRole.js
npm notice 746B lib/etc/roles/dpub/docEpigraphRole.js
npm notice 758B lib/etc/roles/dpub/docEpilogueRole.js
npm notice 752B lib/etc/roles/dpub/docErrataRole.js
npm notice 664B lib/etc/roles/dpub/docExampleRole.js
npm notice 746B lib/etc/roles/dpub/docFootnoteRole.js
npm notice 758B lib/etc/roles/dpub/docForewordRole.js
npm notice 782B lib/etc/roles/dpub/docGlossaryRole.js
npm notice 681B lib/etc/roles/dpub/docGlossrefRole.js
npm notice 763B lib/etc/roles/dpub/docIndexRole.js
npm notice 770B lib/etc/roles/dpub/docIntroductionRole.js
npm notice 678B lib/etc/roles/dpub/docNoterefRole.js
npm notice 748B lib/etc/roles/dpub/docNoticeRole.js
npm notice 722B lib/etc/roles/dpub/docPagebreakRole.js
npm notice 749B lib/etc/roles/dpub/docPagefooterRole.js
npm notice 749B lib/etc/roles/dpub/docPageheaderRole.js
npm notice 773B lib/etc/roles/dpub/docPagelistRole.js
npm notice 745B lib/etc/roles/dpub/docPartRole.js
npm notice 755B lib/etc/roles/dpub/docPrefaceRole.js
npm notice 758B lib/etc/roles/dpub/docPrologueRole.js
npm notice 581B lib/etc/roles/dpub/docPullquoteRole.js
npm notice 731B lib/etc/roles/dpub/docQnaRole.js
npm notice 750B lib/etc/roles/dpub/docSubtitleRole.js
npm notice 740B lib/etc/roles/dpub/docTipRole.js
npm notice 757B lib/etc/roles/dpub/docTocRole.js
npm notice 892B lib/etc/roles/graphics/graphicsDocumentRole.js
npm notice 964B lib/etc/roles/graphics/graphicsObjectRole.js
npm notice 677B lib/etc/roles/graphics/graphicsSymbolRole.js
npm notice 636B lib/etc/roles/literal/alertdialogRole.js
npm notice 641B lib/etc/roles/literal/alertRole.js
npm notice 763B lib/etc/roles/literal/applicationRole.js
npm notice 642B lib/etc/roles/literal/articleRole.js
npm notice 646B lib/etc/roles/literal/bannerRole.js
npm notice 595B lib/etc/roles/literal/blockquoteRole.js
npm notice 1.3kB lib/etc/roles/literal/buttonRole.js
npm notice 671B lib/etc/roles/literal/captionRole.js
npm notice 767B lib/etc/roles/literal/cellRole.js
npm notice 933B lib/etc/roles/literal/checkboxRole.js
npm notice 612B lib/etc/roles/literal/codeRole.js
npm notice 1.1kB lib/etc/roles/literal/columnheaderRole.js
npm notice 2.5kB lib/etc/roles/literal/comboboxRole.js
npm notice 1.2kB lib/etc/roles/literal/complementaryRole.js
npm notice 656B lib/etc/roles/literal/contentinfoRole.js
npm notice 587B lib/etc/roles/literal/definitionRole.js
npm notice 619B lib/etc/roles/literal/deletionRole.js
npm notice 568B lib/etc/roles/literal/dialogRole.js
npm notice 561B lib/etc/roles/literal/directoryRole.js
npm notice 650B lib/etc/roles/literal/documentRole.js
npm notice 618B lib/etc/roles/literal/emphasisRole.js
npm notice 531B lib/etc/roles/literal/feedRole.js
npm notice 583B lib/etc/roles/literal/figureRole.js
npm notice 986B lib/etc/roles/literal/formRole.js
npm notice 2.1kB lib/etc/roles/literal/genericRole.js
npm notice 892B lib/etc/roles/literal/graphicsDocumentRole.js
npm notice 964B lib/etc/roles/literal/graphicsObjectRole.js
npm notice 677B lib/etc/roles/literal/graphicsSymbolRole.js
npm notice 963B lib/etc/roles/literal/gridcellRole.js
npm notice 648B lib/etc/roles/literal/gridRole.js
npm notice 858B lib/etc/roles/literal/groupRole.js
npm notice 971B lib/etc/roles/literal/headingRole.js
npm notice 876B lib/etc/roles/literal/imgRole.js
npm notice 621B lib/etc/roles/literal/insertionRole.js
npm notice 896B lib/etc/roles/literal/linkRole.js
npm notice 1.4kB lib/etc/roles/literal/listboxRole.js
npm notice 873B lib/etc/roles/literal/listitemRole.js
npm notice 719B lib/etc/roles/literal/listRole.js
npm notice 539B lib/etc/roles/literal/logRole.js
npm notice 589B lib/etc/roles/literal/mainRole.js
npm notice 685B lib/etc/roles/literal/markRole.js
npm notice 517B lib/etc/roles/literal/marqueeRole.js
npm notice 577B lib/etc/roles/literal/mathRole.js
npm notice 843B lib/etc/roles/literal/menubarRole.js
npm notice 749B lib/etc/roles/literal/menuitemcheckboxRole.js
npm notice 825B lib/etc/roles/literal/menuitemradioRole.js
npm notice 926B lib/etc/roles/literal/menuitemRole.js
npm notice 1.0kB lib/etc/roles/literal/menuRole.js
npm notice 689B lib/etc/roles/literal/meterRole.js
npm notice 600B lib/etc/roles/literal/navigationRole.js
npm notice 468B lib/etc/roles/literal/noneRole.js
npm notice 512B lib/etc/roles/literal/noteRole.js
npm notice 871B lib/etc/roles/literal/optionRole.js
npm notice 619B lib/etc/roles/literal/paragraphRole.js
npm notice 686B lib/etc/roles/literal/presentationRole.js
npm notice 714B lib/etc/roles/literal/progressbarRole.js
npm notice 776B lib/etc/roles/literal/radiogroupRole.js
npm notice 770B lib/etc/roles/literal/radioRole.js
npm notice 934B lib/etc/roles/literal/regionRole.js
npm notice 784B lib/etc/roles/literal/rowgroupRole.js
npm notice 1.0kB lib/etc/roles/literal/rowheaderRole.js
npm notice 938B lib/etc/roles/literal/rowRole.js
npm notice 746B lib/etc/roles/literal/scrollbarRole.js
npm notice 792B lib/etc/roles/literal/searchboxRole.js
npm notice 528B lib/etc/roles/literal/searchRole.js
npm notice 749B lib/etc/roles/literal/separatorRole.js
npm notice 949B lib/etc/roles/literal/sliderRole.js
npm notice 901B lib/etc/roles/literal/spinbuttonRole.js
npm notice 639B lib/etc/roles/literal/statusRole.js
npm notice 618B lib/etc/roles/literal/strongRole.js
npm notice 621B lib/etc/roles/literal/subscriptRole.js
npm notice 625B lib/etc/roles/literal/superscriptRole.js
npm notice 628B lib/etc/roles/literal/switchRole.js
npm notice 663B lib/etc/roles/literal/tableRole.js
npm notice 689B lib/etc/roles/literal/tablistRole.js
npm notice 519B lib/etc/roles/literal/tabpanelRole.js
npm notice 733B lib/etc/roles/literal/tabRole.js
npm notice 641B lib/etc/roles/literal/termRole.js
npm notice 2.3kB lib/etc/roles/literal/textboxRole.js
npm notice 577B lib/etc/roles/literal/timeRole.js
npm notice 524B lib/etc/roles/literal/timerRole.js
npm notice 635B lib/etc/roles/literal/toolbarRole.js
npm notice 529B lib/etc/roles/literal/tooltipRole.js
npm notice 729B lib/etc/roles/literal/treegridRole.js
npm notice 701B lib/etc/roles/literal/treeitemRole.js
npm notice 768B lib/etc/roles/literal/treeRole.js
npm notice 878B lib/index.js
npm notice 3.6kB lib/roleElementMap.js
npm notice 6.9kB lib/rolesMap.js
npm notice 867B lib/util/iterationDecorator.js
npm notice 641B lib/util/iteratorProxy.js
npm notice 1.9kB package.json
npm notice Tarball Details
npm notice name: aria-query
npm notice version: 5.3.0
npm notice filename: aria-query-5.3.0.tgz
npm notice package size: 25.9 kB
npm notice unpacked size: 176.8 kB
npm notice shasum: 94387e97bcb8042cd77b7a3e116d6ceece08c0c7
npm notice integrity: sha512-AtCI2F3YFpXWJ[...]yVApbW/1bQD3A==
npm notice total files: 157
npm notice
aria-query-5.3.0.tgz Inlined Package Stats$ npm pack
npm notice
npm notice 📦 [email protected]
npm notice Tarball Contents
npm notice 10.2kB LICENSE
npm notice 7.1kB README.md
npm notice 5.8kB lib/ariaPropsMap.js
npm notice 7.1kB lib/domMap.js
npm notice 12.5kB lib/elementRoleMapInlined.js
npm notice 941B lib/index.js
npm notice 10.7kB lib/roleElementMapInlined.js
npm notice 152.6kB lib/rolesMapInlined.js
npm notice 867B lib/util/iterationDecorator.js
npm notice 641B lib/util/iteratorProxy.js
npm notice 1.9kB package.json
npm notice Tarball Details
npm notice name: aria-query
npm notice version: 5.3.0
npm notice filename: aria-query-5.3.0.tgz
npm notice package size: 18.0 kB
npm notice unpacked size: 210.5 kB
npm notice shasum: ae456cc3a058d08b8148a203916b2db483ab4fb6
npm notice integrity: sha512-8ZCF2dxN+jAWv[...]PK5nBOyc59jQQ==
npm notice total files: 11
npm notice
aria-query-5.3.0.tgz Naive Bench Results// bench.js
const start = performance.now();
require("./lib");
const end = performance.now();
console.log(end - start); Feel free to bench properly. Current$ for i in {1..10} do; node bench.js done
34.60670804977417
31.507415771484375
31.12391710281372
39.288166999816895
35.209917068481445
30.495333194732666
29.474791049957275
25.6645827293396
33.73620796203613
34.629374980926514
30.73420810699463 Average: 32.40642027ms
Inlined$ for i in {1..10} do; node bench.js done
7.842292308807373
5.534459114074707
7.0758748054504395
5.635583877563477
5.023416042327881
5.843708038330078
6.834457874298096
5.313292026519775
6.106416702270508
6.104750156402588
6.098165988922119 Average: 6.12840154ms |
Something that strikes me as curious with this project's setup is the mix of build time code generation vs runtime map generation.
Namely, the
./scripts/breakUpAriaJSON.js
enables the generation of role files, but when it comes to the maps:elementRoles
,roleElement
, androles
, these are generated at runtime.Doing a very noddy bench test it looks like the generation of the above maps at runtime results in a cold start between 60-80ms when first requiring
aria-query
into a commonjs Node 18.20.3 project (M1 MacBook Pro 2021, 32GB RAM).If instead the underlying map data is generated at build time as JSON (something we can do as there is no business logic in this project, just representations of static fixtures) and then just wrapped by the map facade the coldstart drops to ~6-7ms.
For many consumers an extra overhead at startup of ~50-70ms is probably a drop in the ocean, but at the scale this project is used there is some potential for wide scale good in reduced compute demand and improved start times?
Update: seems my naive bench from this morning can't be replicated, and now seeing cold start at ~30-40ms for the project as-is.
The text was updated successfully, but these errors were encountered: