본문 바로가기

분류 전체보기21

Memory Consistency Model Memory Consistency Model 의 필요성 아래에서 2개의 Thread로 코드들을 실행시키는 예를 보자. - initial int A, flag = 0; - Thread 1 A = 1; flag = 1; - Thread 2 while (flag == 0); print(A); 이때 컴파일러는 소스코드의 program order를 제대로 컴파일 되었다 해도, 오른쪽에서 A 는 0을 출력할 수도 있다. 프로세서의 OOO Execution으로 인한 메모리 access 순서가 바뀌었을 수도 있고, 아니면 하필 Thread 1 Cache에서 flag에 대한 write만 먼저 메인메모리에 먼저 반영되었을 수도 있다. * 참고로 동일한 프로세서의 동일한 address에 대한 write는 그 순서가 항상 보.. 2023. 10. 24.
Cache coherency protocols * 이글의 내용 및 그림들의 많은 부분을 아래 자료들로 부터 참고해 왔습니다. - Computer Architecture: A Quantitative Approach ( 6th edition ) - Prof. Dr. Ben H. Juurlink youtube ( https://www.youtube.com/@prof.dr.benh.juurlink5459/videos ) Introduction to Multiprocessor System Memory Architectures 여러프로세서와 캐시 및 메모리를 구성하는 방법은 크게 Centralized Shared-Memory Architectures, Distributed Shared-Memory ( DSM ) 로 나눌 수 있다. Centralized Shar.. 2023. 10. 24.
Instruction-Level Parallelism : Hardware Based Speculation for Out-of-Order Execution * 이글의 내용 및 그림들의 많은 부분을 아래 자료들로 부터 참고해 왔습니다. - Computer Architecture: A Quantitative Approach ( 6th edition ) - Prof. Dr. Ben H. Juurlink youtube ( https://www.youtube.com/@prof.dr.benh.juurlink5459/videos ) * 이글은 프로세서의 Out-of-Order Execution 에 대한 심화내용이니, 해당 내용을 모른다면 이전글 Instruction-Level Parallelism : Out-Of-Order Execution( https://zbvs.tistory.com/36 )을 참고하세요. Key Ideas for H/W Based Out-of-Or.. 2023. 10. 24.
Instruction-Level Parallelism : Out-Of-Order Execution * 이글의 내용 및 그림들의 많은 부분을 아래 자료들로 부터 참고해 왔습니다. - Computer Architecture: A Quantitative Approach ( 6th edition ) - Prof. Dr. Ben H. Juurlink youtube ( https://www.youtube.com/@prof.dr.benh.juurlink5459/videos ) Instruction-Level Parallelism: Concepts and Challenges What is Instruction Level Parallelism? 아래 loop를 봐보자. 비록 x[i] = x[i] + y[i]; 부분에서는 병렬적으로 실행할 부분이 적지만, 각 Iteration 1회는 서로 의존적이지 않으므로 병렬적으로.. 2023. 10. 24.
Kafka: Exactly-Once Semantics ( * Kafka Definitive Guide - Chapter 8. Exactly-Once Semantics 내용에 기타 Reference 자료를 추가해 정리해놓은 글입니다. ) Idempotent Producer 어떤 연산이 있을 때 몇번을 재 실행해도 그 결과 State가 동일하다면 Idempotent 하다고 한다. ex-1) UPDATE t SET x=18 where y=5 는 Idempotent 하다. ex-2) UPDATE t SET x=x+1 where y=5 는 Idempotent 하지 않다. Producing 과정에서 Duplicated Producing은 Leader가 Message를 받고 성공적으로 Replication을 수행한 후 Producer에게 성공 메시지를 보내는 찰나에 L.. 2022. 2. 12.
Hypervisor ( x64 ) # CPU/MMU Memory Mapping Memory Mapping http://haifux.org/lectures/312/High-Level%20Introduction%20to%20the%20Low-Level%20of%20Virtualization.pdf x64라도 access 하려는 virtual address의 [63:48] 비트는 쓰이지 않는다. CR3 레지스터는 PM L4 (PageMap Level4) 물리 주소를 가리키고 access 하려는 virtual address의 [47:39] 비트는 PM L4에 Offset값으로 쓰인다. PML4 엔트리의 구조는 다음과 같다. PML4 Entry의 [51:12] 비트는 다음 레벨( PDPT ) 테이블의 물리 주소를 가리킨다. 같은방식으로 반복해서 .. 2022. 1. 16.
Garbage Collection 알고리즘 - 2 참고자료 https://www.amazon.com/Garbage-Collection-Handbook-Management-Algorithms/dp/1420082795 http://www.cs.technion.ac.il/~erez/courses/gc/ https://v8.dev/blog/concurrent-marking # Reference Counting https://www.cs.technion.ac.il/~erez/courses/gc/lectures/08-reference-counting.pdf ( 이 내용은 CPython 문서를 참고했다. https://devguide.python.org/garbage_collector/ ) Reference가 추가 될 때마다 ref count를 증가시키고, Refe.. 2021. 12. 31.
Garbage Collection 알고리즘 - 1 참고 자료 http://www.cs.technion.ac.il/~erez/courses/gc/ https://www.amazon.com/Garbage-Collection-Handbook-Management-Algorithms/dp/1420082795 # 마크-스윕 ( mark-sweep ) http://www.cs.technion.ac.il/~erez/courses/gc/lectures/01-Basics.pdf 우선 마크-스윕은 Reachable한 오브젝트를 마킹한다음 마킹이 안된 object를 Free시키는 방법이다. Free 상태인 메모리는 반드시 Free상태인 Chunk를 list로 관리한다( glibc malloc 의 메모리 관리 방법이랑 비슷하게 ). 중간 중간에 위치하는 사용가능한 메모리 청크.. 2021. 12. 31.
CPU Cache 사상과 회로 구성 참고 글 : https://www.clear.rice.edu/comp425/slides/L24.pdf 이 글은 다음과 같은 시스템을 가정하고 보자. * 메인 메모리 : 4GB ( 32bit 메모리 주소 ) * Cache size : 64KB ( 2^16 bytes ) * Block ( Line ) size : 64byte ( 2^6 bytes ) -> 따라서 메인 메모리의 총 블록 수는 : 2^32 / 2^6 = 2^26 -> 캐시의 총 블록 수는 : 26^16 / 2^6 = 2^10 Fully Associative Mapping ( 완전 연관 사상 ) 완전 연관 사상에서는 하나의 캐시 블록(Line)이 그 어떤 메인메모리 블록이라도 캐싱할 수 있다. 예를들어 하나의 캐시 블록은 26 bit의 Tag값을.. 2021. 12. 4.
Java synchronized 키워드와 Memory Barrier 자바를 공부해본 사람이라면 effective java (3rd) 라는 유명한 책에서 다음과 같은 예제 코드를 본 적이 있을 것이다. public class StopThread { private static boolean stopRequested; public static void main(String[] args) throws InterruptedException { Thread backgroundThread = new Thread(() -> { int i = 0; while (!stopRequested) i++; }); backgroundThread.start(); TimeUnit.SECONDS.sleep(1); stopRequested = true; } } 실행 시 JVM은 먹통이 되고 실행되지 않는.. 2021. 11. 3.
Git Internal - 이문서는 git internal pdf문서 (https://github.com/pluralsight/git-internals-pdf)의 Understanding Git파트에서 몇몇 부분을 추가해 정리한 내용입니다. Git Object Type Git이 repository를 저장할 땐 4가지의 Git Object Blob, Tree, Commit, Tag 를 이용해 저장한다. git object들은.git 디렉토리에 zlib으로 compressed 되어 저장된다. 그리고 그 Object의 이름은 [compress 되기 전의 content데이터+헤더값]의 sha-1 hash가 object의 이름이 된다. 헤더값은 [종류]\x20[decimal ascii size]\x00 포맷이다. 즉 Objec가 blo.. 2021. 11. 2.
Kubernetes Network POD network POD 의 기본 네트워크 POD는 하나의 namespace를 공유하는 여러개의 container로 이루어진 단위이다. 아래에서 POD1을 보면 puase, container1, container2가 하나의 POD를 이루는걸 볼 수 있다. 모든 process가 죽어버리면 network namespace도 사라져버리는데 이를 방지하기 위해 pause container가 따로 존재한다. pause container는 sleep을 주구장창하면서 pod를 위한 network namespace를 유지해준다. 그림에서 보듯 2개의 POD가 있다고 하자. 왼쪽을 POD1 이라 하고 오른쪽을 POD2 라고 하자. POD1이 POD2에 패킷을 보내고 싶다면 어떻게든 dest IP가 10.0.2.2인 .. 2021. 6. 23.