Skip to content
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

Feature: 유저 프로필 (기본, 소개글) 생성/수정 (#PC-80) #7

Merged
merged 15 commits into from
Dec 26, 2024

Conversation

Lujaec
Copy link
Member

@Lujaec Lujaec commented Dec 24, 2024

🔗 관련 이슈

티켓: #PC-80
깃이슈: #6

✨ 작업 내용

  • 프로필 (기본, 소개글) 생성/수정 기능

✅ 체크리스트

  • 코드가 정상적으로 컴파일되나요?
  • 테스트 코드를 통과했나요?
  • merge할 브랜치의 위치를 확인했나요?
  • Label을 지정했나요?

📋 참고 사항

  • KakaoOauthProviderTest가 테스트 실패하는데 확인 부탁드립니다.
  • api 모듈에 user 클래스가 있는데, common 모듈에서 관리하는게 나을 거 같아서, api 모듈에 있던 user 클래스는 일단 주석 처리해놨고 common에 새로 만들어서 작업했습니다

@Lujaec Lujaec added the enhancement New feature or request label Dec 24, 2024
@Lujaec Lujaec self-assigned this Dec 24, 2024
@Lujaec Lujaec requested a review from devchlee12 December 25, 2024 06:05
@Lujaec
Copy link
Member Author

Lujaec commented Dec 25, 2024

저도 공통 응답을 넣긴 했는데, 찬호님께 더 디테일한거 같아서 찬호님 꺼로 사용하는게 좋을거 같아요

Copy link
Member

@devchlee12 devchlee12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

Comment on lines 11 to 17
private static final Random RANDOM = new Random();

public static String generateNickname() {
String animal = ANIMAL_NAMES.get(RANDOM.nextInt(ANIMAL_NAMES.size()));
int number = RANDOM.nextInt(10000) + 1;
return animal + number;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

자바 공식문서에 따르면, java.util.Random을 멀티스레드에서 동시에 이용할 때 성능 저하를 보일 수 있다고 합니다.
ThreadLocalRandom을 고려해보는 것은 어떨까요?

아래는 오라클 공식문서의 설명입니다!

the concurrent use of the same java.util.Random instance across threads may encounter contention and consequent poor performance. Consider instead using ThreadLocalRandom in multithreaded designs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAVA의 Radmom은 시드 값을 기반으로 난수 값을 생성한다고 합니다. 그래서 시드 값이 같으면 같은 난수를 생성하며, 다르면 동일하지 않은 값을 생성합니다. 그래서, Random은 시드 값으로 난수를 생성하고 나면 시드를 업데이트 해야하는데, 여러 개의 쓰레드에서 동시에 업데이트하려고 할 때, 순서를 보장하기 위해 CAS연산을 진행하며 이떄 성능저하가 발생하는 것 같습니다.

ThreadLocalRandom은 Radmon이 여러 쓰레드에게 공유되어 발생했던 문제를, 각 스레드마다 고유한 난수 생성기와 시드를 할당 함으로써 해결한다고 합니다. 그리고 ThreadLocal이란 방식으로 Random을 각 쓰레드에게 배정해주는 방법도 있는 거 같은데, ThreadLcoalRandom 사용법이 더 간단하고 효율적인 것 같습니다.

ThreadLcoalRandom로 수정하겠습니다 ~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

자세한 정보 감사합니다!
고생하셨습니다.

@devchlee12 devchlee12 merged commit 048d861 into main Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants