[JS IR IC] Use fingerprints form klib && use 128 bytes hash

Optimization: instead of calculating fingerprints manually each time
 the patch allows using precalculated fingerprints from the klib.

 Optimization: share one md5 digest for all IC infrastructure.
This commit is contained in:
Alexander Korepanov
2022-12-15 14:53:35 +01:00
committed by Space Team
parent c502cae437
commit dd268d67ff
6 changed files with 121 additions and 118 deletions
@@ -15,7 +15,7 @@ import java.io.File
@JvmInline
value class FingerprintHash(val hash: Hash128Bits) {
override fun toString(): String {
return "${hash.highBytes.toString(Character.MAX_RADIX)}$HASH_SEPARATOR${hash.lowBytes.toString(Character.MAX_RADIX)}"
return "${hash.lowBytes.toString(Character.MAX_RADIX)}$HASH_SEPARATOR${hash.highBytes.toString(Character.MAX_RADIX)}"
}
companion object {
@@ -23,7 +23,7 @@ value class FingerprintHash(val hash: Hash128Bits) {
internal fun fromString(s: String): FingerprintHash? {
val hashes = s.split(HASH_SEPARATOR).mapNotNull { it.toULongOrNull(Character.MAX_RADIX) }
return hashes.takeIf { it.size == 2 }?.let { FingerprintHash(Hash128Bits(it[0], it[1])) }
return hashes.takeIf { it.size == 2 }?.let { FingerprintHash(Hash128Bits(lowBytes = it[0], highBytes = it[1])) }
}
}
}
@@ -77,7 +77,7 @@ value class SerializedKlibFingerprint(val klibFingerprint: FingerprintHash) {
if (isDirectory) {
listFiles()!!.sortedBy { it.name }.forEach { f ->
val filePrefix = "$prefix${f.name}/"
combinedHash = calculateKlibHash(filePrefix, cityHash128WithSeed(combinedHash, filePrefix.toByteArray()))
combinedHash = f.calculateKlibHash(filePrefix, cityHash128WithSeed(combinedHash, filePrefix.toByteArray()))
}
} else {
forEachBlock { buffer, bufferSize ->