[Mono-dev] [PATCH] Speed up ByteEncoding.GetString()
Kornél Pál
kornelpal at gmail.com
Tue Jun 13 23:21:43 EDT 2006
Hi,
The results:
length, conversion: time
1, byte[]: 3391
1, byte[] int int: 3187
4, byte[]: 3641
4, byte[] int int: 3625
1024, byte[]: 14266
1024, byte[] int int: 14187
1048576, byte[]: 8703
1048576, byte[] int int: 8812
Altough I didn't attached performance tests for this patch it's still fast
indeed. These seem to be a bit slower than the patch using reflection but I
think it's still correct that this implementation is about three time faster
than the previous implementation in SVN. Note there is little improvement on
using InternalAllocateStr when is not called using call instruction. Using
delegates is the fastest late binding solution but it's still way slower
than call.
It may be improper to assume that there is an internal method called
InternalAllocateStr even more improper to assume that strings can be
modified but I don't think that using reflection to access non-public
members is improper. If the code has ReflectionPermissionFlag.MemberAccess
permission it works properly. Otherwise MethodAccessException is thrown that
can be identified. If we believe that our class library has to work properly
without full trust we should avoid unsafe code, P/Invoke and almost
everything that requires more permissions than
SecurityPermissionFlag.Execution. If we assume full trust however we can use
unsafe code, P/Invoke, reflection as well as anything else in our class
library. Note that MS.NET class library assemblies assume as well that they
are executed with full trust. Also note that I'm not fighting for
InternalAllocateStr I just speaking about reflection
I attached a test that shows the relation of reflection and CAS.
Kornél
----- Original Message -----
From: "Atsushi Eno" <atsushi at ximian.com>
To: "Kornél Pál" <kornelpal at gmail.com>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Wednesday, June 14, 2006 3:47 AM
Subject: Re: [Mono-dev] [PATCH] Speed up ByteEncoding.GetString()
>> I committed the patch. Note according to my test result this
>> implementation
>> is about three times faster than the previous one so I consider it to be
>> obvious improvement. Of course this only affects ByteEncoding.GetString()
>> but other encodings were not using StringBuilder so they are faster
>> altough
>> they could be improved using unsafe code but that requires some
>> infrastructural changes in I18N.
>
> No, you didn't post anything about the perf. result *after* the
> change to remove improper reflection stuff.
>
>> For the referenced bug:
>>
>> When calling for example MethodInfo.Invoke or Delegate.CreateDelegate
>> without ReflectionPermissionFlag.MemberAccess permission
>> MethodAccessException has to be thrown. But I don't think that this is a
>> mysterious bug. This behaviour is documented on MSDN and if you search
>> for MethodAccessException you will find the methods that throw
>> MethodAccessException with the description when they trow it.
>
> Well, I know. Otherwise it is too weird that I mentioned that
> bug here.
>
> Atsushi Eno
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: AllocateStringTest.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060614/1758ff31/attachment.pl
More information about the Mono-devel-list
mailing list