René's URL Explorer Experiment


Title: Poor groupBy performance · Issue #288 · functionaljava/functionaljava · GitHub

Open Graph Title: Poor groupBy performance · Issue #288 · functionaljava/functionaljava

X Title: Poor groupBy performance · Issue #288 · functionaljava/functionaljava

Description: Running this code: import fj.data.List; import fj.data.TreeMap; public class GroupByPerf { public static void main(String[] args) { System.out.println("warmup"); for (int i = 0; i < 10; i++) { testIt(5000); } System.out.println("real run...

Open Graph Description: Running this code: import fj.data.List; import fj.data.TreeMap; public class GroupByPerf { public static void main(String[] args) { System.out.println("warmup"); for (int i = 0; i < 10; i++) { test...

X Description: Running this code: import fj.data.List; import fj.data.TreeMap; public class GroupByPerf { public static void main(String[] args) { System.out.println("warmup"); for (int i = 0; i < 10...

Opengraph URL: https://github.com/functionaljava/functionaljava/issues/288

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Poor groupBy performance","articleBody":"Running this code:\n\n``` java\nimport fj.data.List;\nimport fj.data.TreeMap;\n\npublic class GroupByPerf\n{\n    public static void main(String[] args)\n    {\n        System.out.println(\"warmup\");\n        for (int i = 0; i \u003c 10; i++)\n        {\n            testIt(5000);\n\n        }\n\n        System.out.println(\"real run\");\n        for (int i = 0; i \u003c 100000; i++)\n        {\n            testIt(50000);\n\n        }\n    }\n\n    public static void testIt(int size)\n    {\n        List\u003cShrubbery> sh = List.range(0, size).map(x -> new Shrubbery(x%20, String.valueOf(x)));\n        long now = System.currentTimeMillis();\n        TreeMap\u003cLong, List\u003cShrubbery>> grouped = sh.groupBy(x -> x.id);\n        System.out.println(\"duration \" + (System.currentTimeMillis()-now));\n    }\n\n    public static class Shrubbery\n    {\n        public final long id;\n        public final String name;\n\n        public Shrubbery(long id, String name)\n        {\n            this.id = id;\n            this.name = name;\n        }\n    }\n```\n\n, yields ~350 millisecond run time for each iteration post the warmup phase, on my machine.\n\nI did a flight recording with jmc, a large portion of the time is spent rebalancing the underlying set, or otherwise in the set.\n\nI took a shot at a naive hashmap implementation, of course the semantic of the method is changed, but they are still grouped:\n\n``` java\nprivate static \u003cA, B> HashMap\u003cA, List\u003cB>> groupBy(List\u003cB> list, F\u003cB,A> keyF)\n    {\n        HashMap\u003cA, List.Buffer\u003cB>> res = HashMap.hashMap();\n        list.foreachDoEffect(x-> {\n            A key = keyF.f(x);\n            Option\u003cList.Buffer\u003cB>> entry = res.get(key);\n            if(entry.isSome())\n            {\n                entry.some().snoc(x);\n            }\n            else\n            {\n                res.set(key, List.Buffer.\u003cB>empty().snoc(x));\n            }\n        });\n\n        return res.map(x->x, x->x.toList());\n    }\n```\n\nThe performance of the above code is roughly on par with javautil Stream. (1-2 millis per run)\n\nDo you think should be at least a variant of the groupBy method which does not use a red-black tree? I am sure there are good reasons the signature is as it is, but also I think 300ms for 50000 elements is not something one will use in production.\n","author":{"url":"https://github.com/dimitarg","@type":"Person","name":"dimitarg"},"datePublished":"2016-07-18T12:06:28Z","url":"https://github.com/functionaljava/functionaljava/issues/288"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ae33ff53-b0a3-7b78-fed8-ce435379ef03
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE678:352ABC:1878C9:22515F:6AFBDF1E
html-safe-noncebbfa7b492715239d4480df0b3eb87f88536afec3ea34fab9ce6e8729d1fd038e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjc4OjM1MkFCQzoxODc4Qzk6MjI1MTVGOjZBRkJERjFFIiwidmlzaXRvcl9pZCI6IjI0NzkyMzQ3MTkxMDM1NzM3OTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacd5933d4a0969df2225a863dc000f2d51a1a8860dc3d8d8c085c59da1bd19e60e
hovercard-subject-tagissue:166078740
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/functionaljava/functionaljava/288/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c9e0f84155d5807ece616c5a77e4776eb976399478d64800f847e711d31e035e/functionaljava/functionaljava/issues/288
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c9e0f84155d5807ece616c5a77e4776eb976399478d64800f847e711d31e035e/functionaljava/functionaljava/issues/288
og:image:altRunning this code: import fj.data.List; import fj.data.TreeMap; public class GroupByPerf { public static void main(String[] args) { System.out.println("warmup"); for (int i = 0; i < 10; i++) { test...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedimitarg
hostnamegithub.com
expected-hostnamegithub.com
None744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec
turbo-cache-controlno-preview
go-importgithub.com/functionaljava/functionaljava git https://github.com/functionaljava/functionaljava.git
octolytics-dimension-user_id458836
octolytics-dimension-user_loginfunctionaljava
octolytics-dimension-repository_id1033614
octolytics-dimension-repository_nwofunctionaljava/functionaljava
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1033614
octolytics-dimension-repository_network_root_nwofunctionaljava/functionaljava
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
releasedf859c48a4c8b4c0009c19bb4e82101aacb4b998
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/functionaljava/functionaljava/issues/288#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffunctionaljava%2Ffunctionaljava%2Fissues%2F288
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%2Ffunctionaljava%2Ffunctionaljava%2Fissues%2F288
Sign uphttps://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=functionaljava%2Ffunctionaljava
Reloadhttps://github.com/functionaljava/functionaljava/issues/288
Reloadhttps://github.com/functionaljava/functionaljava/issues/288
Reloadhttps://github.com/functionaljava/functionaljava/issues/288
functionaljavahttps://github.com/functionaljava
functionaljavahttps://github.com/functionaljava/functionaljava
Codehttps://github.com/functionaljava/functionaljava
Issues28 (28)https://github.com/functionaljava/functionaljava/issues
Pull requests4 (4)https://github.com/functionaljava/functionaljava/pulls
Actionshttps://github.com/functionaljava/functionaljava/actions
Projectshttps://github.com/functionaljava/functionaljava/projects
Wikihttps://github.com/functionaljava/functionaljava/wiki
Security and qualityhttps://github.com/functionaljava/functionaljava/security
Insightshttps://github.com/functionaljava/functionaljava/pulse
https://github.com/functionaljava/functionaljava
New issuehttps://github.com/login?return_to=https://github.com/functionaljava/functionaljava/issues/288
New issuehttps://github.com/login?return_to=https://github.com/functionaljava/functionaljava/issues/288
Poor groupBy performancehttps://github.com/functionaljava/functionaljava/issues/288#top
v4.7https://github.com/functionaljava/functionaljava/milestone/14
https://github.com/dimitarg
dimitarghttps://github.com/dimitarg
on Jul 18, 2016https://github.com/functionaljava/functionaljava/issues/288#issue-166078740
https://github.com/dimitarg
dimitarghttps://github.com/dimitarg
on Jul 18, 2016https://github.com/functionaljava/functionaljava/issues/288#issuecomment-233312153
https://github.com/jbgi
jbgihttps://github.com/jbgi
on Jul 18, 2016https://github.com/functionaljava/functionaljava/issues/288#issuecomment-233436634
@dimitarghttps://github.com/dimitarg
current implementationhttps://github.com/functionaljava/functionaljava/blob/master/core/src/main/java/fj/data/List.java#L1387
@mperryhttps://github.com/mperry
@MartinSeelerhttps://github.com/MartinSeeler
https://github.com/MartinSeeler
MartinSeelerhttps://github.com/MartinSeeler
on Jul 18, 2016https://github.com/functionaljava/functionaljava/issues/288#issuecomment-233439561
jbgihttps://github.com/jbgi
on Jul 18, 2016https://github.com/functionaljava/functionaljava/issues/288#event-726729912
Improve performance of List#groupBy via a mutable buffer. Fix functio…https://github.com/jbgi/functionaljava/commit/10b1c79a02162cb222e3d9de9b118ae2b32e769b
functio…https://github.com/functionaljava/functionaljava/issues/288
https://docs.github.com/articles/closing-issues-via-commit-messages
10b1c79https://github.com/jbgi/functionaljava/commit/10b1c79a02162cb222e3d9de9b118ae2b32e769b
https://github.com/dimitarg
dimitarghttps://github.com/dimitarg
on Jul 19, 2016https://github.com/functionaljava/functionaljava/issues/288#issuecomment-233551873
https://github.com/jbgi
jbgihttps://github.com/jbgi
on Jul 19, 2016https://github.com/functionaljava/functionaljava/issues/288#issuecomment-233559291
@dimitarghttps://github.com/dimitarg
my branchhttps://github.com/jbgi/functionaljava/tree/fix-groupby-perf
jbgihttps://github.com/jbgi
completedhttps://github.com/functionaljava/functionaljava/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
10b1c79https://github.com/functionaljava/functionaljava/commit/10b1c79a02162cb222e3d9de9b118ae2b32e769b
on Jul 20, 2016https://github.com/functionaljava/functionaljava/issues/288#event-729142203
jbgihttps://github.com/jbgi
on Jul 20, 2016https://github.com/functionaljava/functionaljava/issues/288#event-729142204
Merge pull request #291 from jbgi/fix-groupby-perfhttps://github.com/functionaljava/functionaljava/commit/353507b134a90b32f14c3f1aae2cb6dd7ef3d7bd
#291https://github.com/functionaljava/functionaljava/pull/291
https://docs.github.com/articles/closing-issues-via-commit-messages
353507bhttps://github.com/functionaljava/functionaljava/commit/353507b134a90b32f14c3f1aae2cb6dd7ef3d7bd
jbgihttps://github.com/jbgi
on Sep 12, 2016https://github.com/functionaljava/functionaljava/issues/288#event-785709160
Sign up for freehttps://github.com/signup?return_to=https://github.com/functionaljava/functionaljava/issues/288
Sign in to commenthttps://github.com/login?return_to=https://github.com/functionaljava/functionaljava/issues/288
v4.7https://github.com/functionaljava/functionaljava/milestone/14
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.