Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/17/11 10:59:06 (14 years ago)
Author:
epitzer
Message:

Use an asynchronous buffer to allow parallel execution of zip (de)compression and (de)serialization (#1530)

Location:
branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs

    r5445 r6211  
    257257          {"typeName", lastTypeToken.TypeName },
    258258          {"serializer", lastTypeToken.Serializer }});
    259       }
    260       finally {
     259      } finally {
    261260        lastTypeToken = null;
    262261      }
     
    333332            zipStream.PutNextEntry(new ZipEntry("data.xml") { DateTime = DateTime.MinValue });
    334333            StreamWriter writer = new StreamWriter(zipStream);
    335             foreach (ISerializationToken token in serializer) {
    336               string line = generator.Format(token);
    337               writer.Write(line);
     334            foreach (ISerializationToken token in new AsyncBuffer<ISerializationToken>(serializer)) {
     335              writer.Write(generator.Format(token));
    338336            }
    339337            writer.Flush();
    340338            zipStream.PutNextEntry(new ZipEntry("typecache.xml") { DateTime = DateTime.MinValue });
    341             foreach (string line in generator.Format(serializer.TypeCache)) {
     339            foreach (string line in new AsyncBuffer<string>(generator.Format(serializer.TypeCache))) {
    342340              writer.Write(line);
    343341            }
     
    368366        File.Copy(tempfile, filename, true);
    369367        File.Delete(tempfile);
    370       }
    371       catch (Exception) {
     368      } catch (Exception) {
    372369        Logger.Warn("Exception caught, no data has been written.");
    373370        throw;
     
    438435        serializer.InterleaveTypeInformation = true;
    439436        XmlGenerator generator = new XmlGenerator();
    440         foreach (ISerializationToken token in serializer) {
     437        foreach (ISerializationToken token in new AsyncBuffer<ISerializationToken>(serializer)) {
    441438          string line = generator.Format(token);
    442439          writer.Write(line);
  • branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Default/Xml/XmlParser.cs

    r5445 r6211  
    7575        try {
    7676          iterator = handlers[reader.Name].Invoke();
    77         }
    78         catch (KeyNotFoundException) {
     77        } catch (KeyNotFoundException) {
    7978          throw new PersistenceException(String.Format(
    8079            "Invalid XML tag \"{0}\" in persistence file.",
     
    176175        }
    177176        return typeCache;
    178       }
    179       catch (PersistenceException) {
     177      } catch (PersistenceException) {
    180178        throw;
    181       }
    182       catch (Exception e) {
     179      } catch (Exception e) {
    183180        throw new PersistenceException("Unexpected exception during type cache parsing.", e);
    184181      }
     
    196193          return Deserialize(file);
    197194        }
    198       }
    199       finally {
     195      } finally {
    200196        TimeSpan end = System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime;
    201197        Tracing.Logger.Info(string.Format(
     
    226222          XmlParser parser = new XmlParser(reader);
    227223          Deserializer deserializer = new Deserializer(new TypeMapping[] { });
    228           return deserializer.Deserialize(parser);
    229         }
    230       }
    231       catch (PersistenceException) {
     224          return deserializer.Deserialize(new AsyncBuffer<ISerializationToken>(parser));
     225        }
     226      } catch (PersistenceException) {
    232227        throw;
    233       }
    234       catch (Exception x) {
     228      } catch (Exception x) {
    235229        throw new PersistenceException("Unexpected exception during deserialization", x);
    236230      }
     
    258252        XmlParser parser = new XmlParser(
    259253          new StreamReader(zipFile.GetInputStream(data)));
    260         object result = deSerializer.Deserialize(parser);
     254        object result = deSerializer.Deserialize(new AsyncBuffer<ISerializationToken>(parser));
    261255        zipFile.Close();
    262256        return result;
    263       }
    264       catch (PersistenceException) {
     257      } catch (PersistenceException) {
    265258        throw;
    266       }
    267       catch (Exception e) {
     259      } catch (Exception e) {
    268260        throw new PersistenceException("Unexpected exception during deserialization", e);
    269261      }
  • branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj

    r6173 r6211  
    177177    <Compile Include="Default\DebugString\PrimitiveSerializers\UShort2DebugStringSerializer.cs" />
    178178    <Compile Include="Default\DebugString\PrimitiveSerializers\ValueType2DebugStringSerializerBase.cs" />
     179    <Compile Include="Default\Xml\AsyncBuffer.cs" />
    179180    <Compile Include="Default\Xml\Compact\ByteArray2XmlSerializer.cs" />
    180181    <Compile Include="Default\Xml\Compact\CompactXmlSerializerBase.cs" />
Note: See TracChangeset for help on using the changeset viewer.