René's URL Explorer Experiment


Title: [item63] String '+' 연산 성능은 개선된걸까 · Issue #89 · back-end-study/effective-java · GitHub

Open Graph Title: [item63] String '+' 연산 성능은 개선된걸까 · Issue #89 · back-end-study/effective-java

X Title: [item63] String '+' 연산 성능은 개선된걸까 · Issue #89 · back-end-study/effective-java

Description: 질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 질문 2) 이렇게 개선됐는데 왜 아직도 String '+' 연산은 엄청 느릴까요? 질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 366p 마지막 문단 자바 6 이후 문자열 연결 성능을 다방면으로 개선했지만, … 책에는 자바6 이후 문자열 연결 성능을 개선했다고 되어있지만 아무리 찾아봐도 자바5 부터 String ‘+’ operator는 컴파일 시 StringBuil...

Open Graph Description: 질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 질문 2) 이렇게 개선됐는데 왜 아직도 String '+' 연산은 엄청 느릴까요? 질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 366p 마지막 문단 자바 6 이후 문자열 연결 성능을 다방면으로 개선했지만, … 책에는 자바6 이후 문자열 연결 성능을 개선했다고 되어있지만 아무리 찾아봐도 자바5 ...

X Description: 질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 질문 2) 이렇게 개선됐는데 왜 아직도 String '+' 연산은 엄청 느릴까요? 질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 366p 마지막 문단 자바 6 이후 문자열 연결 성능을 다방면으로 개선했지만, … 책에는 자바6 이후 문자열 연결 성능을 개선했다고 되어있지만 아무리 찾...

Opengraph URL: https://github.com/back-end-study/effective-java/issues/89

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[item63] String '+' 연산 성능은 개선된걸까","articleBody":"- 질문 1) JDK 6에서 어떤 부분이 개선됐을까요?\r\n- 질문 2) 이렇게 개선됐는데 왜 아직도 String '+' 연산은 엄청 느릴까요?\r\n\r\n## 질문 1) JDK 6에서 어떤 부분이 개선됐을까요?\r\n\r\n\u003e 366p 마지막 문단  \r\n\u003e 자바 6 이후 문자열 연결 성능을 다방면으로 개선했지만, …\r\n\r\n책에는 자바6 이후 문자열 연결 성능을 개선했다고 되어있지만 아무리 찾아봐도 자바5 부터 String ‘+’ operator는 컴파일 시 StringBuilder(또는 StringBuffer)로 변환되도록 변경된 내용 밖에 찾지 못했습니다. \r\n\r\n**자바6에서 어떤 부분이 개선됐는지 궁금합니다 😭**\r\n\r\n\u003cimg width=\"921\" alt=\"image\" src=\"https://user-images.githubusercontent.com/42997924/207633244-ea4a70cc-a9ef-4dec-bd82-2ccad7d06418.png\"\u003e\r\n\r\n출처 : [JDK 5 docs : String](https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html)\r\n\r\n이것마저도 String ‘+’ 연산보다 객체 생성 비용과 메모리 사용을 줄일 수 있었지만, 문제가 해결되지는 않았습니다.\r\n\r\n1. StringBuilder와 String Buffer는 기본적으로 초기 capacity가 16 characters로 설정되고, 이는 사이즈가 작아서 재할당으로 인한 추가 비용이 발생하기 쉽습니다.\r\n2. loop를 돌 때 StringBuilder 객체가 반복적으로 생성되기 때문에 비효율적입니다.\r\n\r\n추가적으로, JDK 9 버전 부터는 이를 개선하기 위해 `StringConcatFactory` 를 도입했습니다.\r\n\r\n- 참고 : [JDK 9 docs : StringConcatFactory](https://docs.oracle.com/javase/9/docs/api/java/lang/invoke/StringConcatFactory.html)\r\n\r\nJDK8 버전과 JDK 11버전으로 각각 컴파일하여 바이트코드를 분석한 글을 참고하면 아래와 같습니다.\r\n\r\n![image](https://user-images.githubusercontent.com/42997924/207643423-5e418056-bed0-4dde-a901-e2a0a12ae993.png)\r\n\r\n출처 : https://jerry92k.tistory.com/50\r\n\r\n좌측 JDK8 버전은 반복문(L5) 안에서 `NEW java/lang/StringBuilder`를 통해 새로운 StringBuilder 객체를 생성하고, JDK11 버전은 `StringConcatFatory.makeConcatWithConstants` 메서드를 통해 처리하는 것을 알 수 있습니다.\r\n\r\n## 질문 2) 이렇게 개선됐는데 왜 아직도 String '+' 연산은 엄청 느릴까요?\r\n\r\nJDK 버전이 올라가면서 String ‘+’ 연산이 개선됐기 때문에 더이상 StringBuilder를 사용하지 않아도 된다는 의견은 어렵지 않게 찾아볼 수 있습니다.\r\n\r\n- https://dzone.com/articles/string-concatenation-performacne-improvement-in-ja\r\n- https://choichumji.tistory.com/135\r\n\r\n그런데 제가 JDK 18 버전 기준으로 테스트해보니 여전히 큰 성능 차이를 확인할 수 있었습니다.\r\n\r\n\u003cimg width=\"895\" alt=\"image\" src=\"https://user-images.githubusercontent.com/42997924/207639365-aa701bc1-9b60-40f2-92e3-2fe0f00b0367.png\"\u003e\r\n(10번 연산)\r\n\r\n\r\n\u003cimg width=\"895\" alt=\"image\" src=\"https://user-images.githubusercontent.com/42997924/207639500-f758f1ba-1989-4cbc-b087-815978ce47cf.png\"\u003e\r\n(1,000번 연산)\r\n\r\n\u003cimg width=\"895\" alt=\"image\" src=\"https://user-images.githubusercontent.com/42997924/207639659-08e138fc-0578-4076-9ee6-8f8ad7849e00.png\"\u003e\r\n(50,000번 연산)\r\n\r\n1,000번 50,000번 연산은 당연히 느려지겠지만, 적어도 10번 연산에서는 ‘+’ 연산에서도 내부적으로 StringBuilder를 생성해서 활용하기 때문에 성능 차이가 거의 없어야 할 것 같은데.. (실행할 때마다 차이는 있지만) 200배 이상 느린게 이상합니다.\r\n\r\n\u003cimg width=\"692\" alt=\"image\" src=\"https://user-images.githubusercontent.com/42997924/207641712-68173d2b-5ac0-4802-a2ec-653ec3307aba.png\"\u003e\r\n\r\n(String ‘+’ 연산과 StringBuilder의 Bytecode 비교)\r\n\r\n혹시나 하여 ByteCode를 확인해보아도 JDK 9 버전에 추가된 `makeConcatWithConstants` 메서드로 ‘+’연산을 처리하고 있었습니다.\r\n\r\n이유를 아시는 분이 있다면 도와주세요!","author":{"url":"https://github.com/jun108059","@type":"Person","name":"jun108059"},"datePublished":"2022-12-14T15:57:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/89/effective-java/issues/89"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:67365b75-c901-e02e-f3f5-bdd9c2f3fc7d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8FBC:1A7259:82DFA7:AEC326:6A5B4041
html-safe-nonce6e1ed075a2649a9aada31afb0239b8d3e146f3b9245fe141fe30436dc34f114b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkJDOjFBNzI1OTo4MkRGQTc6QUVDMzI2OjZBNUI0MDQxIiwidmlzaXRvcl9pZCI6IjI0MzQxNzcwNDYxMTkzOTk0ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacaac51fd68b7adff4659fe19ecf23b558209253ed38dc74b529914e91fea32423
hovercard-subject-tagissue:1496932166
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/back-end-study/effective-java/89/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6acea792b2a58ff8fd3b9a28793d6e91e4c5d381b41b04c2d331fa7cb19105d8/back-end-study/effective-java/issues/89
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6acea792b2a58ff8fd3b9a28793d6e91e4c5d381b41b04c2d331fa7cb19105d8/back-end-study/effective-java/issues/89
og:image:alt질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 질문 2) 이렇게 개선됐는데 왜 아직도 String '+' 연산은 엄청 느릴까요? 질문 1) JDK 6에서 어떤 부분이 개선됐을까요? 366p 마지막 문단 자바 6 이후 문자열 연결 성능을 다방면으로 개선했지만, … 책에는 자바6 이후 문자열 연결 성능을 개선했다고 되어있지만 아무리 찾아봐도 자바5 ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejun108059
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
turbo-cache-controlno-preview
go-importgithub.com/back-end-study/effective-java git https://github.com/back-end-study/effective-java.git
octolytics-dimension-user_id112924294
octolytics-dimension-user_loginback-end-study
octolytics-dimension-repository_id533175487
octolytics-dimension-repository_nwoback-end-study/effective-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id533175487
octolytics-dimension-repository_network_root_nwoback-end-study/effective-java
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
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/back-end-study/effective-java/issues/89#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fback-end-study%2Feffective-java%2Fissues%2F89
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/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/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/enterprise/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%2Fback-end-study%2Feffective-java%2Fissues%2F89
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=back-end-study%2Feffective-java
Reloadhttps://github.com/back-end-study/effective-java/issues/89
Reloadhttps://github.com/back-end-study/effective-java/issues/89
Reloadhttps://github.com/back-end-study/effective-java/issues/89
Please reload this pagehttps://github.com/back-end-study/effective-java/issues/89
back-end-study https://github.com/back-end-study
effective-javahttps://github.com/back-end-study/effective-java
Notifications https://github.com/login?return_to=%2Fback-end-study%2Feffective-java
Fork 4 https://github.com/login?return_to=%2Fback-end-study%2Feffective-java
Star 45 https://github.com/login?return_to=%2Fback-end-study%2Feffective-java
Code https://github.com/back-end-study/effective-java
Issues 22 https://github.com/back-end-study/effective-java/issues
Pull requests 6 https://github.com/back-end-study/effective-java/pulls
Discussions https://github.com/back-end-study/effective-java/discussions
Actions https://github.com/back-end-study/effective-java/actions
Projects https://github.com/back-end-study/effective-java/projects
Wiki https://github.com/back-end-study/effective-java/wiki
Security and quality 0 https://github.com/back-end-study/effective-java/security
Insights https://github.com/back-end-study/effective-java/pulse
Code https://github.com/back-end-study/effective-java
Issues https://github.com/back-end-study/effective-java/issues
Pull requests https://github.com/back-end-study/effective-java/pulls
Discussions https://github.com/back-end-study/effective-java/discussions
Actions https://github.com/back-end-study/effective-java/actions
Projects https://github.com/back-end-study/effective-java/projects
Wiki https://github.com/back-end-study/effective-java/wiki
Security and quality https://github.com/back-end-study/effective-java/security
Insights https://github.com/back-end-study/effective-java/pulse
[item63] String '+' 연산 성능은 개선된걸까https://github.com/back-end-study/effective-java/issues/89#top
https://github.com/iamsojung
https://github.com/jun108059
👨🏻‍💻 question토론하고 싶은 질문입니다.https://github.com/back-end-study/effective-java/issues?q=state%3Aopen%20label%3A%22%F0%9F%91%A8%F0%9F%8F%BB%E2%80%8D%F0%9F%92%BB%20question%22
chapter9https://github.com/back-end-study/effective-java/milestone/7
https://github.com/jun108059
jun108059https://github.com/jun108059
on Dec 14, 2022https://github.com/back-end-study/effective-java/issues/89#issue-1496932166
https://user-images.githubusercontent.com/42997924/207633244-ea4a70cc-a9ef-4dec-bd82-2ccad7d06418.png
JDK 5 docs : Stringhttps://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html
JDK 9 docs : StringConcatFactoryhttps://docs.oracle.com/javase/9/docs/api/java/lang/invoke/StringConcatFactory.html
https://user-images.githubusercontent.com/42997924/207643423-5e418056-bed0-4dde-a901-e2a0a12ae993.png
https://jerry92k.tistory.com/50https://jerry92k.tistory.com/50
https://dzone.com/articles/string-concatenation-performacne-improvement-in-jahttps://dzone.com/articles/string-concatenation-performacne-improvement-in-ja
https://choichumji.tistory.com/135https://choichumji.tistory.com/135
https://user-images.githubusercontent.com/42997924/207639365-aa701bc1-9b60-40f2-92e3-2fe0f00b0367.png
https://user-images.githubusercontent.com/42997924/207639500-f758f1ba-1989-4cbc-b087-815978ce47cf.png
https://user-images.githubusercontent.com/42997924/207639659-08e138fc-0578-4076-9ee6-8f8ad7849e00.png
https://user-images.githubusercontent.com/42997924/207641712-68173d2b-5ac0-4802-a2ec-653ec3307aba.png
iamsojunghttps://github.com/iamsojung
jun108059https://github.com/jun108059
👨🏻‍💻 question토론하고 싶은 질문입니다.https://github.com/back-end-study/effective-java/issues?q=state%3Aopen%20label%3A%22%F0%9F%91%A8%F0%9F%8F%BB%E2%80%8D%F0%9F%92%BB%20question%22
chapter9No due datehttps://github.com/back-end-study/effective-java/milestone/7
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.