avoid premature Properties.uncompress: allow blob to be stored in another database;
authorwenzelm
Wed, 01 Mar 2023 13:52:11 +0100
changeset 77439 d6bf9ec39d12
parent 77438 0030eabbe6c3
child 77440 80f7a7b66224
avoid premature Properties.uncompress: allow blob to be stored in another database;
src/Pure/Thy/sessions.scala
src/Pure/Tools/build_process.scala
--- a/src/Pure/Thy/sessions.scala	Wed Mar 01 13:30:35 2023 +0100
+++ b/src/Pure/Thy/sessions.scala	Wed Mar 01 13:52:11 2023 +0100
@@ -1591,8 +1591,8 @@
     def read_session_timing(db: SQL.Database, name: String): Properties.T =
       Properties.decode(read_bytes(db, name, Session_Info.session_timing), cache = cache)
 
-    def read_command_timings(db: SQL.Database, name: String): List[Properties.T] =
-      read_properties(db, name, Session_Info.command_timings)
+    def read_command_timings(db: SQL.Database, name: String): Bytes =
+      read_bytes(db, name, Session_Info.command_timings)
 
     def read_theory_timings(db: SQL.Database, name: String): List[Properties.T] =
       read_properties(db, name, Session_Info.theory_timings)
--- a/src/Pure/Tools/build_process.scala	Wed Mar 01 13:30:35 2023 +0100
+++ b/src/Pure/Tools/build_process.scala	Wed Mar 01 13:52:11 2023 +0100
@@ -17,7 +17,7 @@
 
   object Session_Context {
     def empty(session: String, timeout: Time): Session_Context =
-      new Session_Context(session, timeout, Time.zero, Nil)
+      new Session_Context(session, timeout, Time.zero, Bytes.empty)
 
     def apply(
       session: String,
@@ -56,9 +56,10 @@
     val session: String,
     val timeout: Time,
     val old_time: Time,
-    val old_command_timings: List[Properties.T]
+    val old_command_timings_blob: Bytes
   ) {
-    def is_empty: Boolean = old_time.is_zero && old_command_timings.isEmpty
+    def is_empty: Boolean =
+      old_time.is_zero && old_command_timings_blob.is_empty
 
     override def toString: String = session
   }
@@ -149,6 +150,9 @@
     def apply(session: String): Session_Context =
       sessions.getOrElse(session, Session_Context.empty(session, Time.zero))
 
+    def old_command_timings(session: String): List[Properties.T] =
+      Properties.uncompress(apply(session).old_command_timings_blob, cache = store.cache)
+
     def do_store(session: String): Boolean =
       build_heap || Sessions.is_pure(session) || !sessions_structure.build_graph.is_maximal(session)
   }
@@ -652,7 +656,7 @@
 
       val resources =
         new Resources(session_background, log = log,
-          command_timings = build_context(session_name).old_command_timings)
+          command_timings = build_context.old_command_timings(session_name))
 
       val job =
         synchronized {