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

Integrated develop #32

Merged
merged 3 commits into from
Apr 3, 2024
Merged

Conversation

haxr369
Copy link
Contributor

@haxr369 haxr369 commented Apr 3, 2024

개요

  1. AtomicInteger를 이용한 카운터
  2. CompletableFuture를 이용한 카운터
  3. Synchronized를 이용한 카운터

변경 사항

✨ Feat : 새로운 기
✅ Test : 테스트 코드 추가

추가 정보

  • 각 카운터데 대해서 수행시간과 메모리 사용량을 테이블 형식으로 Readme에 작성

관련 이슈

haxr369 added 3 commits April 3, 2024 13:05
✅ Test : 테스트 코드 추가

1. SynchronizedCounter 와 CompletableFutureCounter를 생성
2. 두 카운터의 테스트를 작성
3. 테스트는 Integer.MAX_VALUE만큼 실행시키는 것이였으나 OutOfMemory 문제가 발생해서 500만번 수행
1. CompletableFuture 자료형은 스레드에 안전하지 않다.
2. 따라서 counter 값을 읽고 업데이트하는 과정을 하나의 단일 연산으로 만들어줘야한다.
3. CompleableFutureCounter에 대한 테스트도 작성 완료
✅ Test : 테스트 코드 추가

1. CompletableFutureCounter의 테스트를 다른 카운터와 동일하게 작성
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 90.47619% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 82.75%. Comparing base (ed4626c) to head (d7e8a86).

Files Patch % Lines
.../concurrency/counter/CompletableFutureCounter.java 81.81% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             develop      #32       +/-   ##
==============================================
+ Coverage      62.50%   82.75%   +20.25%     
- Complexity         4       14       +10     
==============================================
  Files              2        5        +3     
  Lines              8       29       +21     
==============================================
+ Hits               5       24       +19     
- Misses             3        5        +2     
Flag Coverage Δ
unittests 82.75% <90.47%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@haxr369
Copy link
Contributor Author

haxr369 commented Apr 3, 2024

Describe the bug

#32 에 AtomicCounterTest에서 아래 그림처럼 카운트 횟수를 지정하는 totalCount를 Integer.MAX_VALUE로 하면 Out Of Memory가 뜨는 문제가 발생합니다.

image
Caused by: java.lang.OutOfMemoryError: Java heap space
	at java.base/java.util.concurrent.AbstractExecutorService.newTaskFor(AbstractExecutorService.java:98)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:122)
	at com.thread.concurrency.AtomicCounterTest.여러_더하기_수행_Executor(AtomicCounterTest.java:37)
	at java.base/java.lang.invoke.LambdaForm$DMH/0x000000a000288800.invokeVirtual(LambdaForm$DMH)
	at java.base/java.lang.invoke.LambdaForm$MH/0x000000a000190800.invoke(LambdaForm$MH)
	at java.base/java.lang.invoke.Invokers$Holder.invokeExact_MT(Invokers$Holder)

To Reproduce
Steps to reproduce the behavior:

  1. Go to src/test/java/com/thread/concurrency/AtomicCounterTest.java
  2. totalCount를 Integer.MAX_VALUE로 변경
  3. 테스트 실행
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

@ooMia ooMia mentioned this pull request Apr 3, 2024
@ooMia ooMia added the enhancement New feature or request label Apr 3, 2024
@ooMia ooMia added this to the 스레드 동시성 제어 milestone Apr 3, 2024
@ooMia
Copy link
Contributor

ooMia commented Apr 3, 2024

문제는 별도 이슈로 분리했어요

@ooMia ooMia self-requested a review April 3, 2024 07:56
Copy link
Contributor

@ooMia ooMia left a comment

Choose a reason for hiding this comment

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

우선 승인하겠습니다.

@ooMia ooMia merged commit 35d3cbf into spring-templates:develop Apr 3, 2024
3 checks passed
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
No open projects
Development

Successfully merging this pull request may close these issues.

AtomicCounter 테스트 멀티 쓰레드 자원 업데이트 문제
2 participants