[Mono-dev] [PATCH] Speed up ByteEncoding.GetString()

Kornél Pál kornelpal at gmail.com
Fri Jun 9 07:50:41 EDT 2006


Hi,

Invoking non-public methods using SRE is widely used by our class library, 
it is supported by the ECMA standards so I don't really understand what you 
mean on "access to internal methods will at some point broken".

Note that even using "new string ((char) 0, length)" is faster than the 
current implementation.

Please approve the patch or please be more specific regarding your 
objections.

Kornél

----- Original Message ----- 
From: "Kornél Pál" <kornelpal at gmail.com>
To: "Miguel de Icaza" <miguel at ximian.com>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Wednesday, June 07, 2006 10:59 AM
Subject: Re: [Mono-dev] [PATCH] Speed up ByteEncoding.GetString()


> Hi,
>
> I understand the nature of your problem, but I if you are speaking about
> CAS
> I think it is not a so big problem. SRE is intended to access non-public
> members as well as public members. When enabling security
> ReflectionPermission controls whether code can access private members of
> other assemblies but this should not be a problem as I18N is part of the
> class library so it can have FullTrust without problems. Problems may
> occur
> in case of executable like mcs.exe but when signing them and granting them
> FullTrust based on public key there should not be problems. Of course
> granting full trust to a public key whose private key is public may may
> imply security problems but this could be solved by restricting the scope
> of
> this key to the directories of Mono.
>
> Note that I attached a corrected patch because the previous one ignored
> the
> index parameter by mistake.
>
> Some performance tests:
>
> Before:
> length, conversion: time
> 1, byte[]: 11578
> 1, byte[] int int: 12282
> 4, byte[]: 12609
> 4, byte[] int int: 12687
> 1024, byte[]: 37125
> 1024, byte[] int int: 37844
> 1048576, byte[]: 23875
> 1048576, byte[] int int: 24125
>
> After:
> length, conversion: time
> 1, byte[]: 3235
> 1, byte[] int int: 3203
> 4, byte[]: 3734
> 4, byte[] int int: 3797
> 1024, byte[]: 13297
> 1024, byte[] int int: 13234
> 1048576, byte[]: 5937
> 1048576, byte[] int int: 5844
>
> The test program is attached.
>
> Kornél
>
> ----- Original Message ----- 
> From: "Miguel de Icaza" <miguel at ximian.com>
> To: "Kornél Pál" <kornelpal at gmail.com>
> Cc: <mono-devel-list at lists.ximian.com>
> Sent: Wednesday, June 07, 2006 6:48 AM
> Subject: Re: [Mono-dev] [PATCH] Speed up ByteEncoding.GetString()
>
>
>> Hello Kornel,
>>
>>> ByteEncoding.GetString() currently uses StringBuilder that is very slow.
>>> I
>>> modified it to use InternalAllocateStr and unsafe code that makes is
>>> much
>>> faster.
>>>
>>> Please review and approve the patch.
>>
>> Am not sure that poking at the internals and using InternalAllocateStr
>> is a good idea.   One possibility would be to use "Friend Assemblies",
>> although that is only supported in the 2.0 profile, not in 1.0.
>>
>> Although today Mono does not enforce at runtime accessibility, this is
>> something that we intend to fix, which means that access to internal
>> methods will at some point broken.   So this would be one of those
>> things we would have to fix.
>>
>> (Today we do violate this rule when using dynamic method invocation, and
>> we would have to find solutions for the places where we do).
>>
>> Miguel.
>




More information about the Mono-devel-list mailing list