[JS IR IC] Implement fast path invalidation check

Compute library md5 hash and check it first with cached one. If hashes
are equal it means that cache is up-to-date and no additional checks are
needed

 - store library hashes (flat + trans) into cache info file
 - change invalidator return value
This commit is contained in:
Roman Artemev
2021-12-13 17:18:09 +03:00
committed by teamcity
parent 5ba6ca4c16
commit b719865c25
6 changed files with 132 additions and 48 deletions
@@ -203,7 +203,7 @@ interface PersistentCacheConsumer {
fun commitSourceMap(path: String, mapData: ByteArray)
fun invalidateForFile(path: String)
fun commitLibraryPath(libraryPath: String)
fun commitLibraryPath(libraryPath: String, flatHash: ULong, transHash: ULong)
companion object {
val EMPTY = object : PersistentCacheConsumer {
@@ -234,7 +234,7 @@ interface PersistentCacheConsumer {
}
override fun commitLibraryPath(libraryPath: String) {
override fun commitLibraryPath(libraryPath: String, flatHash: ULong, transHash: ULong) {
}
@@ -333,7 +333,7 @@ class PersistentCacheConsumerImpl(private val cachePath: String) : PersistentCac
commitByteArrayToCacheFile(path, fileSourceMap, mapData)
}
override fun commitLibraryPath(libraryPath: String) {
override fun commitLibraryPath(libraryPath: String, flatHash: ULong, transHash: ULong) {
val infoFile = File(File(cachePath), "info")
if (infoFile.exists()) {
infoFile.delete()
@@ -342,7 +342,8 @@ class PersistentCacheConsumerImpl(private val cachePath: String) : PersistentCac
PrintWriter(infoFile).use {
it.println(libraryPath)
it.println("0")
it.println(flatHash.toString(16))
it.println(transHash.toString(16))
}
}
}