Skip to content

Commit 2815771

Browse files
authored
Clarify locality impact on ArrayList vs LinkedList performance
Updated phrasing for clarity regarding locality and performance differences between ArrayList and LinkedList.
1 parent 086650f commit 2815771

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • src/content/posts/2026-02-25-arraylist-vs-linkedlist-cache-locality

src/content/posts/2026-02-25-arraylist-vs-linkedlist-cache-locality/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ McCalpin은 이미 1990년대 중반에 "cache miss 한 번 처리하는 동안
175175

176176
- pointer chasing이 과거에 없던 문제가 된 게 아니라
177177
- **예전보다 miss penalty(특히 cycle 기준)가 더 커져서**
178-
- locality 차이가 실제 벽시계 시간에 더 크게 번역되기 쉬워졌습니다.
178+
- locality 차이가 실제 수행 시간에 더 크게 반영되기 쉬워졌습니다.
179179

180-
"옛날엔 LinkedList도 충분히 빨랐다"는 단정은 조심해야 하지만, "현대 CPU에서는 locality를 놓치면 비용이 더 빠르게 커진다"는 방향은 역사적으로도 일관된 설명입니다.
180+
즉 현대 CPU에서는 캐시 때문에 locality를 놓치면 비용이 더 커집니다.
181181

182182
[^memory-wall]: Wulf, McKee, "Hitting the Memory Wall: Implications of the Obvious" (1995) — https://libraopen.lib.virginia.edu/downloads/4b29b598d
183183
[^mccalpin-balance]: John D. McCalpin, "Memory Bandwidth and Machine Balance in Current High Performance Computers" (1995) — https://www.cs.virginia.edu/~mccalpin/papers/balance/
@@ -240,12 +240,12 @@ Big-O는 여전히 중요합니다. 다만 **현대 CPU에서 데이터가 어
240240
| `buildFromPayload` 시간 (ns/op) | 65536 | 100677.722 | 158964.547 | LinkedList가 약 1.58배 느림 |
241241
| `buildFromPayload` 할당량 (B/op) | 65536 | 262186.3 | 1572867.7 | LinkedList가 약 6.00배 더 많이 할당 |
242242

243-
즉 이 케이스에서는 LinkedList가 실행시간뿐 아니라, 노드 객체 생성 비용 때문에 메모리 할당량에서도 명확히 불리했습니다.
243+
즉 이 벤치마크에서는 LinkedList가 실행시간뿐 아니라, Node 객체 생성 비용 때문에 메모리 할당량에서도 불리했습니다.
244244

245245
관찰 포인트는 세 가지입니다.
246246

247247
1. `getMiddle`처럼 임의 접근 성격이 강한 연산은 Array 계열(`ArrayList`)이 압도적으로 유리합니다.
248-
2. `head insert/remove`, `iterator remove`처럼 노드 재연결이 핵심인 연산은 `LinkedList`매우 크게 앞섭니다.
248+
2. `head insert/remove`, `iterator remove`처럼 노드 재연결이 핵심인 연산은 `LinkedList`가 크게 앞섭니다.
249249
3. `deque offer/poll` 시나리오에서는 `ArrayDeque``LinkedList`보다 꾸준히 빠른 기본값으로 관측됩니다.
250250

251251

0 commit comments

Comments
 (0)