René's URL Explorer Experiment


Title: Document Megaplot memory performance best practices · Issue #69 · PAIR-code/megaplot · GitHub

Open Graph Title: Document Megaplot memory performance best practices · Issue #69 · PAIR-code/megaplot

X Title: Document Megaplot memory performance best practices · Issue #69 · PAIR-code/megaplot

Description: Create a document which lists performance best practices such as minimizing memory allocations within callbacks. It's common in JavaScript, especially when using D3, to use object literals to pass values. Often in the browser, the perfor...

Open Graph Description: Create a document which lists performance best practices such as minimizing memory allocations within callbacks. It's common in JavaScript, especially when using D3, to use object literals to pass ...

X Description: Create a document which lists performance best practices such as minimizing memory allocations within callbacks. It's common in JavaScript, especially when using D3, to use object literals to p...

Opengraph URL: https://github.com/PAIR-code/megaplot/issues/69

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Document Megaplot memory performance best practices","articleBody":"Create a document which lists performance best practices such as minimizing memory allocations within callbacks.\r\n\r\n---\r\n\r\nIt's common in JavaScript, especially when using D3, to use object literals to pass values. Often in the browser, the performance implication of creating these short-lived objects is negligible compared to DOM operations such as reflow and paint.\r\n\r\nHowever, in Megaplot, memory operations are often among the more expensive, and so developers should take care to avoid creating short-lived objects, especially in callbacks which may be invoked many times.\r\n\r\nFor example, Megaplot allows colors to be specified by their individual component:\r\n\r\n```ts\r\nconst sprite = scene.createSprite();\r\nsprite.enter(s =\u003e {\r\n  s.FillColorR = 255;\r\n  s.FillColorG = 0;\r\n  s.FillColorB = 255;\r\n  s.FillColorOpacity = 1;\r\n});\r\n```\r\n\r\nThis is verbose, and so Megaplot offers destructuring assignment as well as individual component assignment.\r\n\r\nHere's the same example, but using destructuring with an object literal:\r\n\r\n```ts\r\nconst sprite = scene.createSprite();\r\nsprite.enter(s =\u003e {\r\n  s.FillColor = [255, 0, 255, 1];\r\n});\r\n```\r\n\r\nSince only a single Sprite is being created, and its `enter()` callback is invoked only once, this code has the effect of instatiating only one copy of the array `[255, 0, 255, 1]`.\r\n\r\nThe problem is when the same approach is taken with selections:\r\n\r\n```ts\r\nconst selection = scene.createSelection();\r\nselection.onInit(s =\u003e {\r\n  s.FillColor = [255, 0, 255, 1];\r\n});\r\nselection.bind(data);\r\n```\r\n\r\nWhen the selection is bound to the array of data, the selection's `onInit()` callback is called for each Sprite/datum pair. That means that a short-lived copy of the array `[255, 0, 255, 1]` is created and destroyed many times. These allocation and deallocation operations are significantly costlier than mere memory access at scale, and so it's better to declare constants outside of the callbacks like so:\r\n\r\n```ts\r\nconst INIT_FILL_COLOR = [255, 0, 255, 1];\r\nconst selection = scene.createSelection();\r\nselection.onInit(s =\u003e {\r\n  s.FillColor = INIT_FILL_COLOR;\r\n});\r\nselection.bind(data);\r\n```\r\n","author":{"url":"https://github.com/jimbojw","@type":"Person","name":"jimbojw"},"datePublished":"2022-10-05T10:44:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/69/megaplot/issues/69"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:72d0479b-55a8-9f78-284c-2f899963a930
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD718:88322:3B7FBE:56E8AC:6A4E0450
html-safe-nonce54e7677aa564fea95d4cac0079586630ea5a62b4e36d9ec845e8ab16423f9626
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzE4Ojg4MzIyOjNCN0ZCRTo1NkU4QUM6NkE0RTA0NTAiLCJ2aXNpdG9yX2lkIjoiNDc3NTA2MTQ4NjYxNDQ3OTk1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac77c3eac5e76bf14e03953cbfdd6964a0a428c97f49fad2bc5c1b51c2e28fc4a2
hovercard-subject-tagissue:1397594303
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PAIR-code/megaplot/69/issue_layout
twitter:imagehttps://opengraph.githubassets.com/2bfed60ff8556118582f7d6a484f5995ef4cb657844aa165adaed169f937f1d9/PAIR-code/megaplot/issues/69
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/2bfed60ff8556118582f7d6a484f5995ef4cb657844aa165adaed169f937f1d9/PAIR-code/megaplot/issues/69
og:image:altCreate a document which lists performance best practices such as minimizing memory allocations within callbacks. It's common in JavaScript, especially when using D3, to use object literals to pass ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejimbojw
hostnamegithub.com
expected-hostnamegithub.com
Nonedf0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6
turbo-cache-controlno-preview
go-importgithub.com/PAIR-code/megaplot git https://github.com/PAIR-code/megaplot.git
octolytics-dimension-user_id29804435
octolytics-dimension-user_loginPAIR-code
octolytics-dimension-repository_id451893434
octolytics-dimension-repository_nwoPAIR-code/megaplot
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id451893434
octolytics-dimension-repository_network_root_nwoPAIR-code/megaplot
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release52bde38e24398476f8eb1e0760c81346c6a00812
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PAIR-code/megaplot/issues/69#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPAIR-code%2Fmegaplot%2Fissues%2F69
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPAIR-code%2Fmegaplot%2Fissues%2F69
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PAIR-code%2Fmegaplot
Reloadhttps://github.com/PAIR-code/megaplot/issues/69
Reloadhttps://github.com/PAIR-code/megaplot/issues/69
Reloadhttps://github.com/PAIR-code/megaplot/issues/69
Please reload this pagehttps://github.com/PAIR-code/megaplot/issues/69
PAIR-code https://github.com/PAIR-code
megaplothttps://github.com/PAIR-code/megaplot
Notifications https://github.com/login?return_to=%2FPAIR-code%2Fmegaplot
Fork 3 https://github.com/login?return_to=%2FPAIR-code%2Fmegaplot
Star 21 https://github.com/login?return_to=%2FPAIR-code%2Fmegaplot
Code https://github.com/PAIR-code/megaplot
Issues 34 https://github.com/PAIR-code/megaplot/issues
Pull requests 24 https://github.com/PAIR-code/megaplot/pulls
Actions https://github.com/PAIR-code/megaplot/actions
Projects https://github.com/PAIR-code/megaplot/projects
Security and quality 0 https://github.com/PAIR-code/megaplot/security
Insights https://github.com/PAIR-code/megaplot/pulse
Code https://github.com/PAIR-code/megaplot
Issues https://github.com/PAIR-code/megaplot/issues
Pull requests https://github.com/PAIR-code/megaplot/pulls
Actions https://github.com/PAIR-code/megaplot/actions
Projects https://github.com/PAIR-code/megaplot/projects
Security and quality https://github.com/PAIR-code/megaplot/security
Insights https://github.com/PAIR-code/megaplot/pulse
Document Megaplot memory performance best practiceshttps://github.com/PAIR-code/megaplot/issues/69#top
documentationImprovements or additions to documentationhttps://github.com/PAIR-code/megaplot/issues?q=state%3Aopen%20label%3A%22documentation%22
https://github.com/jimbojw
jimbojwhttps://github.com/jimbojw
on Oct 5, 2022https://github.com/PAIR-code/megaplot/issues/69#issue-1397594303
documentationImprovements or additions to documentationhttps://github.com/PAIR-code/megaplot/issues?q=state%3Aopen%20label%3A%22documentation%22
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.