From 09378da12776ba025b492a31bd030acfe73f0d12 Mon Sep 17 00:00:00 2001
From: Homer Horwitz
Date: Fri, 2 Jan 2009 17:22:24 +0000
Subject: Use only one (static) (de-)serializer for (de-)serializing SOPs. That
improves performance drastically, at least for Mono, as the (de-)serializers
can then be optimized (and won't use reflection anymore). On my system,
before this change de-/serialization took ~9s/9s, whereas after the change it
takes ~.5/.2s.
---
.../Region/Environment/Scenes/SceneObjectGroup.cs | 25 +++++++++++++++++++---
.../Region/Environment/Scenes/SceneObjectPart.cs | 8 ++++---
2 files changed, 27 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 2f6a61a..18818e7 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -401,9 +401,9 @@ namespace OpenSim.Region.Environment.Scenes
{
SetRootPart(part);
}
-
+
public SceneObjectGroup(string xmlData, bool isOriginalXmlFormat)
- : this(UUID.Zero, xmlData, isOriginalXmlFormat)
+ : this(UUID.Zero, xmlData, isOriginalXmlFormat)
{
}
@@ -423,7 +423,10 @@ namespace OpenSim.Region.Environment.Scenes
{
if (!isOriginalXmlFormat)
throw new Exception("This constructor must specify the xml is in OpenSim's original format");
-
+
+ m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
+ int time = System.Environment.TickCount;
+
// libomv.types changes UUID to Guid
xmlData = xmlData.Replace("", "");
xmlData = xmlData.Replace("", "");
@@ -475,6 +478,7 @@ namespace OpenSim.Region.Environment.Scenes
reader.Close();
sr.Close();
+ m_log.DebugFormat("[SOG]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
}
///
@@ -487,6 +491,9 @@ namespace OpenSim.Region.Environment.Scenes
protected void SetFromXml(string xmlData)
{
+ m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
+ int time = System.Environment.TickCount;
+
// libomv.types changes UUID to Guid
xmlData = xmlData.Replace("", "");
xmlData = xmlData.Replace("", "");
@@ -531,6 +538,8 @@ namespace OpenSim.Region.Environment.Scenes
reader.Close();
sr.Close();
+
+ m_log.DebugFormat("[SOG]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
}
protected virtual SceneObjectPart CreatePartFromXml(XmlTextReader reader)
@@ -714,6 +723,9 @@ namespace OpenSim.Region.Environment.Scenes
public void ToXml(XmlTextWriter writer)
{
+ m_log.DebugFormat("[SOG]: Starting serialization of {0}", Name);
+ int time = System.Environment.TickCount;
+
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
m_rootPart.ToXml(writer);
@@ -735,6 +747,9 @@ namespace OpenSim.Region.Environment.Scenes
writer.WriteEndElement();
writer.WriteEndElement();
+
+ m_log.DebugFormat("[SOG]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
+
}
public string ToXmlString2()
@@ -752,6 +767,9 @@ namespace OpenSim.Region.Environment.Scenes
public void ToXml2(XmlTextWriter writer)
{
+ m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name);
+ int time = System.Environment.TickCount;
+
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
m_rootPart.ToXml(writer);
writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
@@ -769,6 +787,7 @@ namespace OpenSim.Region.Environment.Scenes
writer.WriteEndElement();
writer.WriteEndElement();
+ m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time);
}
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index e8f7011..e864090 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -96,7 +96,11 @@ namespace OpenSim.Region.Environment.Scenes
public class SceneObjectPart : IScriptHost, ISerializable
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
+
+ // use only one serializer to give the runtime a chance to optimize it (it won't do that if you
+ // use a new instance every time)
+ private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
+
#region Fields
[XmlIgnore]
@@ -1619,7 +1623,6 @@ if (m_shape != null) {
///
public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader)
{
- XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader);
part.m_fromUserInventoryItemID = fromUserInventoryItemId;
@@ -3186,7 +3189,6 @@ if (m_shape != null) {
///
public void ToXml(XmlWriter xmlWriter)
{
- XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
serializer.Serialize(xmlWriter, this);
}
--
cgit v1.1