Skip to content

Commit 39eb259

Browse files
GooolerJakeWharton
andauthored
Fix diff stuck on large JARs (#469)
The issue occurred because JAR parsing performs an expensive `sorted()` operation on all class members. During this sort, Diffuse used `TypeDescriptor.compareTo()` which computed a human-readable `sourceName` on-the-fly for every single comparison, causing tens of millions of string allocations and essentially hanging the JVM due to Garbage Collection (GC) thrashing. (APK parsing bypassed this as its DEX reader does not invoke sorting on members). I changed `TypeDescriptor.compareTo` to directly compare the internal JVM `.value`, which is an instant, allocation-free comparison. Tested it manually. Co-authored-by: Jake Wharton <jw@jakewharton.com>
1 parent 024e06a commit 39eb259

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
## [Unreleased]
44
[Unreleased]: https://github.com/JakeWharton/diffuse/compare/0.3.0...HEAD
5+
56
**Added**
67
- Add `--summary-only` flag.
78

9+
**Fixed**
10+
- Significantly improve `.jar` diff performance.
11+
12+
813
## [0.3.0] - 2024-02-20
914
[0.3.0]: https://github.com/JakeWharton/diffuse/releases/tag/0.3.0
1015

formats/src/main/kotlin/com/jakewharton/diffuse/format/TypeDescriptor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.jakewharton.diffuse.format
33
@JvmInline
44
value class TypeDescriptor(val value: String) : Comparable<TypeDescriptor> {
55
override fun compareTo(other: TypeDescriptor): Int {
6-
return sourceName.compareTo(other.sourceName)
6+
return value.compareTo(other.value)
77
}
88

99
val sourceName

0 commit comments

Comments
 (0)