diff options
author | Homer Horwitz | 2009-01-02 17:22:24 +0000 |
---|---|---|
committer | Homer Horwitz | 2009-01-02 17:22:24 +0000 |
commit | 09378da12776ba025b492a31bd030acfe73f0d12 (patch) | |
tree | ec8e599431d937e444a2e00aa324710c2403ba4f | |
parent | Get build working on MonoDevelop again. (diff) | |
download | opensim-SC_OLD-09378da12776ba025b492a31bd030acfe73f0d12.zip opensim-SC_OLD-09378da12776ba025b492a31bd030acfe73f0d12.tar.gz opensim-SC_OLD-09378da12776ba025b492a31bd030acfe73f0d12.tar.bz2 opensim-SC_OLD-09378da12776ba025b492a31bd030acfe73f0d12.tar.xz |
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.
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 25 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 8 |
2 files changed, 27 insertions, 6 deletions
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 | |||
401 | { | 401 | { |
402 | SetRootPart(part); | 402 | SetRootPart(part); |
403 | } | 403 | } |
404 | 404 | ||
405 | public SceneObjectGroup(string xmlData, bool isOriginalXmlFormat) | 405 | public SceneObjectGroup(string xmlData, bool isOriginalXmlFormat) |
406 | : this(UUID.Zero, xmlData, isOriginalXmlFormat) | 406 | : this(UUID.Zero, xmlData, isOriginalXmlFormat) |
407 | { | 407 | { |
408 | } | 408 | } |
409 | 409 | ||
@@ -423,7 +423,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
423 | { | 423 | { |
424 | if (!isOriginalXmlFormat) | 424 | if (!isOriginalXmlFormat) |
425 | throw new Exception("This constructor must specify the xml is in OpenSim's original format"); | 425 | throw new Exception("This constructor must specify the xml is in OpenSim's original format"); |
426 | 426 | ||
427 | m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | ||
428 | int time = System.Environment.TickCount; | ||
429 | |||
427 | // libomv.types changes UUID to Guid | 430 | // libomv.types changes UUID to Guid |
428 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); | 431 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); |
429 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); | 432 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); |
@@ -475,6 +478,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
475 | 478 | ||
476 | reader.Close(); | 479 | reader.Close(); |
477 | sr.Close(); | 480 | sr.Close(); |
481 | m_log.DebugFormat("[SOG]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
478 | } | 482 | } |
479 | 483 | ||
480 | /// <summary> | 484 | /// <summary> |
@@ -487,6 +491,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
487 | 491 | ||
488 | protected void SetFromXml(string xmlData) | 492 | protected void SetFromXml(string xmlData) |
489 | { | 493 | { |
494 | m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | ||
495 | int time = System.Environment.TickCount; | ||
496 | |||
490 | // libomv.types changes UUID to Guid | 497 | // libomv.types changes UUID to Guid |
491 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); | 498 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); |
492 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); | 499 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); |
@@ -531,6 +538,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
531 | 538 | ||
532 | reader.Close(); | 539 | reader.Close(); |
533 | sr.Close(); | 540 | sr.Close(); |
541 | |||
542 | m_log.DebugFormat("[SOG]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
534 | } | 543 | } |
535 | 544 | ||
536 | protected virtual SceneObjectPart CreatePartFromXml(XmlTextReader reader) | 545 | protected virtual SceneObjectPart CreatePartFromXml(XmlTextReader reader) |
@@ -714,6 +723,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
714 | 723 | ||
715 | public void ToXml(XmlTextWriter writer) | 724 | public void ToXml(XmlTextWriter writer) |
716 | { | 725 | { |
726 | m_log.DebugFormat("[SOG]: Starting serialization of {0}", Name); | ||
727 | int time = System.Environment.TickCount; | ||
728 | |||
717 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | 729 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); |
718 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); | 730 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); |
719 | m_rootPart.ToXml(writer); | 731 | m_rootPart.ToXml(writer); |
@@ -735,6 +747,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
735 | 747 | ||
736 | writer.WriteEndElement(); | 748 | writer.WriteEndElement(); |
737 | writer.WriteEndElement(); | 749 | writer.WriteEndElement(); |
750 | |||
751 | m_log.DebugFormat("[SOG]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
752 | |||
738 | } | 753 | } |
739 | 754 | ||
740 | public string ToXmlString2() | 755 | public string ToXmlString2() |
@@ -752,6 +767,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
752 | 767 | ||
753 | public void ToXml2(XmlTextWriter writer) | 768 | public void ToXml2(XmlTextWriter writer) |
754 | { | 769 | { |
770 | m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name); | ||
771 | int time = System.Environment.TickCount; | ||
772 | |||
755 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | 773 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); |
756 | m_rootPart.ToXml(writer); | 774 | m_rootPart.ToXml(writer); |
757 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | 775 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); |
@@ -769,6 +787,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
769 | 787 | ||
770 | writer.WriteEndElement(); | 788 | writer.WriteEndElement(); |
771 | writer.WriteEndElement(); | 789 | writer.WriteEndElement(); |
790 | m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); | ||
772 | } | 791 | } |
773 | 792 | ||
774 | /// <summary> | 793 | /// <summary> |
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 | |||
96 | public class SceneObjectPart : IScriptHost, ISerializable | 96 | public class SceneObjectPart : IScriptHost, ISerializable |
97 | { | 97 | { |
98 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 98 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
99 | 99 | ||
100 | // use only one serializer to give the runtime a chance to optimize it (it won't do that if you | ||
101 | // use a new instance every time) | ||
102 | private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); | ||
103 | |||
100 | #region Fields | 104 | #region Fields |
101 | 105 | ||
102 | [XmlIgnore] | 106 | [XmlIgnore] |
@@ -1619,7 +1623,6 @@ if (m_shape != null) { | |||
1619 | /// <returns></returns> | 1623 | /// <returns></returns> |
1620 | public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader) | 1624 | public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader) |
1621 | { | 1625 | { |
1622 | XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); | ||
1623 | SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader); | 1626 | SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader); |
1624 | part.m_fromUserInventoryItemID = fromUserInventoryItemId; | 1627 | part.m_fromUserInventoryItemID = fromUserInventoryItemId; |
1625 | 1628 | ||
@@ -3186,7 +3189,6 @@ if (m_shape != null) { | |||
3186 | /// <param name="xmlWriter"></param> | 3189 | /// <param name="xmlWriter"></param> |
3187 | public void ToXml(XmlWriter xmlWriter) | 3190 | public void ToXml(XmlWriter xmlWriter) |
3188 | { | 3191 | { |
3189 | XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); | ||
3190 | serializer.Serialize(xmlWriter, this); | 3192 | serializer.Serialize(xmlWriter, this); |
3191 | } | 3193 | } |
3192 | 3194 | ||