You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/08/01 07:59:01 UTC
[GitHub] [ignite] ptupitsyn opened a new pull request #8110: IGNITE-13293 .NET: Fix enum serialization performance
ptupitsyn opened a new pull request #8110:
URL: https://github.com/apache/ignite/pull/8110
* Don't send enum metadata more than once
* Cache name-value map per enum type
* Add benchmark
As a result, enum field serialization is on par with int field:
```
| Method | Mean | Error | StdDev | Ratio | RatioSD |
|---------------------- |---------:|---------:|---------:|------:|--------:|
| PutPrimitive | 45.47 us | 0.907 us | 1.330 us | 1.00 | 0.00 |
| PutPrimitiveAsync | 66.28 us | 1.317 us | 1.617 us | 1.45 | 0.05 |
| PutClassWithIntField | 68.34 us | 1.275 us | 1.130 us | 1.49 | 0.05 |
| PutClassWithEnumField | 71.13 us | 1.419 us | 2.734 us | 1.57 | 0.08 |
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] gurustron commented on a change in pull request #8110: IGNITE-13293 .NET: Fix enum serialization performance
Posted by GitBox <gi...@apache.org>.
gurustron commented on a change in pull request #8110:
URL: https://github.com/apache/ignite/pull/8110#discussion_r465259710
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
##########
@@ -1749,6 +1753,76 @@ public static TimeSpan LongToTimeSpan(long ms)
return TimeSpan.FromMilliseconds(ms);
}
+
+ /// <summary>
+ /// Gets the enum values.
+ /// </summary>
+ public static IDictionary<string, int> GetEnumValues(Type enumType)
+ {
+ Debug.Assert(enumType != null);
+ Debug.Assert(enumType.IsEnum);
+
+ Dictionary<string,int> res;
+ if (EnumValues.TryGetValue(enumType, out res))
+ {
+ return res;
+ }
+
+ var values = Enum.GetValues(enumType);
+ res = new Dictionary<string, int>(values.Length);
+
+ var underlyingType = Enum.GetUnderlyingType(enumType);
+
+ foreach (var value in values)
+ {
+ var name = Enum.GetName(enumType, value);
+ Debug.Assert(name != null);
+
+ res[name] = GetEnumValueAsInt(underlyingType, value);
+ }
+
+ EnumValues.Set(enumType, res);
+
+ return res;
+ }
+
+ /// <summary>
+ /// Gets the enum value as int.
+ /// </summary>
+ private static int GetEnumValueAsInt(Type underlyingType, object value)
Review comment:
Should we support long?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] ptupitsyn merged pull request #8110: IGNITE-13293 .NET: Fix enum serialization performance
Posted by GitBox <gi...@apache.org>.
ptupitsyn merged pull request #8110:
URL: https://github.com/apache/ignite/pull/8110
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] ashapkin commented on a change in pull request #8110: IGNITE-13293 .NET: Fix enum serialization performance
Posted by GitBox <gi...@apache.org>.
ashapkin commented on a change in pull request #8110:
URL: https://github.com/apache/ignite/pull/8110#discussion_r464110009
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/EnumsTest.cs
##########
@@ -85,6 +86,11 @@ private static void CheckValue<T>(T val, bool isBinaryEnum = true)
{
Assert.AreEqual(string.Format("{0} [typeId={1}, enumValue={2}, enumValueName={3}]",
typeof(T).FullName, binRes.GetBinaryType().TypeId, binRes.EnumValue, val), binRes.ToString());
+
+ var expectedEnumNames = Enum.GetValues(typeof(T)).OfType<T>().Select(x => x.ToString()).ToList();
+ var actualEnumNames = binRes.GetBinaryType().GetEnumValues().Select(v => v.EnumName).ToList();
Review comment:
Optional: it looks like we need to check this:
Assert.AreSame(binRes.GetBinaryType().GetEnumValues(), binRes.GetBinaryType().GetEnumValues())
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] ptupitsyn commented on a change in pull request #8110: IGNITE-13293 .NET: Fix enum serialization performance
Posted by GitBox <gi...@apache.org>.
ptupitsyn commented on a change in pull request #8110:
URL: https://github.com/apache/ignite/pull/8110#discussion_r464222441
##########
File path: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/EnumsTest.cs
##########
@@ -85,6 +86,11 @@ private static void CheckValue<T>(T val, bool isBinaryEnum = true)
{
Assert.AreEqual(string.Format("{0} [typeId={1}, enumValue={2}, enumValueName={3}]",
typeof(T).FullName, binRes.GetBinaryType().TypeId, binRes.EnumValue, val), binRes.ToString());
+
+ var expectedEnumNames = Enum.GetValues(typeof(T)).OfType<T>().Select(x => x.ToString()).ToList();
+ var actualEnumNames = binRes.GetBinaryType().GetEnumValues().Select(v => v.EnumName).ToList();
Review comment:
I think I understand what you mean - since we cache enum values, we should always return the same collection. However, other nodes may have more values for the same enum (e.g. a newer code version). So the cache we introduced in this change is only for write operations. And when the user asks for all known enum values, we don't use the cache, but load them from the cluster.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org