The Trunk: Network-topa.166.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Network-topa.166.mcz

commits-2
Tobias Pape uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-topa.166.mcz

==================== Summary ====================

Name: Network-topa.166
Author: topa
Time: 21 October 2015, 8:26:14.656 pm
UUID: d6d9910f-fa67-4c69-9a89-030c81233e90
Ancestors: Network-topa.165

UUIDGenerator
 - Use new Random>>#nextBytes:into:startingAt: (needs Kernel-ul.960) for even more speed
 - Fix UUIDGenerator class>>#initialize to correctly register at startup
 - Do not reset default on startup but rather reseed TheRandom

Timings improved:  '1,190,000 per second. 842 nanoseconds per run.' (0.25 times slower than primitive version)

=============== Diff against Network-topa.165 ===============

Item was changed:
  Object subclass: #UUIDGenerator
+ instanceVariableNames: ''
- instanceVariableNames: 'bits'
  classVariableNames: 'Default TheRandom TheSemaphore'
  poolDictionaries: ''
  category: 'Network-UUID'!
 
  !UUIDGenerator commentStamp: 'topa 10/19/2015 23:23:19' prior: 0!
  I generate a pseudo-random UUID by asking Random for a 128 bit value.
 
  See https://tools.ietf.org/html/rfc4122.html#section-4.4 for reference.!

Item was changed:
  ----- Method: UUIDGenerator class>>default (in category 'instance creation') -----
  default
+ ^ Default ifNil: [Default := self new]
+ !
- Default ifNil: [self generateDefault].
- ^Default!

Item was removed:
- ----- Method: UUIDGenerator class>>generateDefault (in category 'instance creation') -----
- generateDefault
- Default := self new!

Item was changed:
  ----- Method: UUIDGenerator class>>initialize (in category 'class initialization') -----
  initialize
  TheRandom := Random new.
  TheSemaphore := Semaphore forMutualExclusion.
+ Smalltalk addToStartUpList: self!
- Smalltalk addToStartUpList: self after: nil.!

Item was added:
+ ----- Method: UUIDGenerator class>>resetDefault (in category 'class initialization') -----
+ resetDefault
+ Default := nil.!

Item was changed:
  ----- Method: UUIDGenerator class>>startUp (in category 'class initialization') -----
  startUp
+ "Reseed the random"
+ TheSemaphore critical: [TheRandom seed: nil].!
- Default := nil!

Item was added:
+ ----- Method: UUIDGenerator>>fillRandomly: (in category 'instance creation') -----
+ fillRandomly: aUUID
+
+ TheSemaphore critical: [
+ TheRandom nextBytes: 16 "128 bit" into: aUUID startingAt: 1].!

Item was changed:
  ----- Method: UUIDGenerator>>generateBytes:forVersion: (in category 'instance creation') -----
+ generateBytes: aUUID forVersion: aVersion
+ | versionID fixedValue |
+
+ aVersion = 4 ifFalse: [^ self error: 'Unsupported version'].
+
+ self fillRandomly: aUUID.
+ versionID := ((aUUID at: 7) bitAnd: 16r0F) bitOr: 16r40. "Version 4"
+ fixedValue := ((aUUID at: 9) bitAnd: 16r3F) bitOr: 16r80. "Fixed 8..b value"
+ aUUID
+ at: 7 put: versionID;
+ at: 9 put: fixedValue.!
- generateBytes: aPlaceHolder forVersion: aVersion
- aVersion = 4 ifTrue: [self generateFieldsVersion4]
- ifFalse: [self error: 'Unsupported version'].
- self placeFields: aPlaceHolder.!

Item was removed:
- ----- Method: UUIDGenerator>>generateFieldsVersion4 (in category 'instance creation') -----
- generateFieldsVersion4
-  
- TheSemaphore critical: [
- bits := 16rffffffffffffffffffffffffffffffff atRandom: TheRandom. "128 bit"].!

Item was removed:
- ----- Method: UUIDGenerator>>placeFields: (in category 'instance creation') -----
- placeFields: aByteArray
-
- | version fixed |
- bits isLarge
- ifTrue: [ aByteArray replaceFrom: 1 to: bits size with: bits]
- ifFalse: [aByteArray unsignedLongAt: 1 put: bits bigEndian: false].
-
- version := ((aByteArray at: 7) bitAnd: 16r0F) bitOr: 16r40. "Version 4"
- fixed := ((aByteArray at: 9) bitAnd: 16r3F) bitOr: 16r80. "Fixed 8..b value"
- aByteArray
- at: 7 put: version;
- at: 9 put: fixed.!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Network-topa.166.mcz

David T. Lewis
On Thu, Oct 22, 2015 at 06:28:09AM +0000, [hidden email] wrote:

> Tobias Pape uploaded a new version of Network to project The Trunk:
> http://source.squeak.org/trunk/Network-topa.166.mcz
>
> ==================== Summary ====================
>
> Name: Network-topa.166
> Author: topa
> Time: 21 October 2015, 8:26:14.656 pm
> UUID: d6d9910f-fa67-4c69-9a89-030c81233e90
> Ancestors: Network-topa.165
>
> UUIDGenerator
>  - Use new Random>>#nextBytes:into:startingAt: (needs Kernel-ul.960) for even more speed
>  - Fix UUIDGenerator class>>#initialize to correctly register at startup
>  - Do not reset default on startup but rather reseed TheRandom
>
> Timings improved:  '1,190,000 per second. 842 nanoseconds per run.' (0.25 times slower than primitive version)
>

This is outstanding. The UUID plugin has long been a source of problems in
the VM, partly due to issues in various Linux distributions.

  http://bugs.squeak.org/view.php?id=7358

Making the plugin unnecessary is a big improvement.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Network-topa.166.mcz

Tobias Pape

On 22.10.2015, at 14:37, David T. Lewis <[hidden email]> wrote:

> On Thu, Oct 22, 2015 at 06:28:09AM +0000, [hidden email] wrote:
>> Tobias Pape uploaded a new version of Network to project The Trunk:
>> http://source.squeak.org/trunk/Network-topa.166.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Network-topa.166
>> Author: topa
>> Time: 21 October 2015, 8:26:14.656 pm
>> UUID: d6d9910f-fa67-4c69-9a89-030c81233e90
>> Ancestors: Network-topa.165
>>
>> UUIDGenerator
>> - Use new Random>>#nextBytes:into:startingAt: (needs Kernel-ul.960) for even more speed
>> - Fix UUIDGenerator class>>#initialize to correctly register at startup
>> - Do not reset default on startup but rather reseed TheRandom
>>
>> Timings improved:  '1,190,000 per second. 842 nanoseconds per run.' (0.25 times slower than primitive version)
>>
>
> This is outstanding. The UUID plugin has long been a source of problems in
> the VM, partly due to issues in various Linux distributions.
>
>  http://bugs.squeak.org/view.php?id=7358
>
> Making the plugin unnecessary is a big improvement.

Thats what I thought.
Probably we want to present this (Mersenne PRNG + new UUID gen) to
the Pharo core developers (cc) so that we can just remove the UUID plugin
from the VMs (cc vm-dev)?

Best regards
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] [squeak-dev] The Trunk: Network-topa.166.mcz

Marcus Denker-4

> On 22 Oct 2015, at 14:49, Tobias Pape <[hidden email]> wrote:
>
>
> On 22.10.2015, at 14:37, David T. Lewis <[hidden email]> wrote:
>
>> On Thu, Oct 22, 2015 at 06:28:09AM +0000, [hidden email] wrote:
>>> Tobias Pape uploaded a new version of Network to project The Trunk:
>>> http://source.squeak.org/trunk/Network-topa.166.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Network-topa.166
>>> Author: topa
>>> Time: 21 October 2015, 8:26:14.656 pm
>>> UUID: d6d9910f-fa67-4c69-9a89-030c81233e90
>>> Ancestors: Network-topa.165
>>>
>>> UUIDGenerator
>>> - Use new Random>>#nextBytes:into:startingAt: (needs Kernel-ul.960) for even more speed
>>> - Fix UUIDGenerator class>>#initialize to correctly register at startup
>>> - Do not reset default on startup but rather reseed TheRandom
>>>
>>> Timings improved:  '1,190,000 per second. 842 nanoseconds per run.' (0.25 times slower than primitive version)
>>>
>>
>> This is outstanding. The UUID plugin has long been a source of problems in
>> the VM, partly due to issues in various Linux distributions.
>>
>> http://bugs.squeak.org/view.php?id=7358
>>
>> Making the plugin unnecessary is a big improvement.
>
> Thats what I thought.
> Probably we want to present this (Mersenne PRNG + new UUID gen) to
> the Pharo core developers (cc) so that we can just remove the UUID plugin
> from the VMs (cc vm-dev)?
>

That sounds good!

        Marcus


Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] [squeak-dev] The Trunk: Network-topa.166.mcz

Marcus Denker-4

> On 22 Oct 2015, at 16:13, Marcus Denker <[hidden email]> wrote:
>>>
>>
>> Thats what I thought.
>> Probably we want to present this (Mersenne PRNG + new UUID gen) to
>> the Pharo core developers (cc) so that we can just remove the UUID plugin
>> from the VMs (cc vm-dev)?
>>
>
> That sounds good!

I added an issue tracker entry so we do not forget:

        https://pharo.fogbugz.com/f/cases/16846/integrate-non-Plugin-UUIDGenerator-from-Squeak


        Marcus

--
Marcus Denker  —  2Denker GmbH
http://www.2denker.de 
Reply | Threaded
Open this post in threaded view
|

Re: [Vm-dev] [squeak-dev] The Trunk: Network-topa.166.mcz

Henrik Sperre Johansen
In reply to this post by Tobias Pape

> On 22 Oct 2015, at 2:49 , Tobias Pape <[hidden email]> wrote:
>
>
>
> On 22.10.2015, at 14:37, David T. Lewis <[hidden email]> wrote:
>
>> On Thu, Oct 22, 2015 at 06:28:09AM +0000, [hidden email] wrote:
>>> Tobias Pape uploaded a new version of Network to project The Trunk:
>>> http://source.squeak.org/trunk/Network-topa.166.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Network-topa.166
>>> Author: topa
>>> Time: 21 October 2015, 8:26:14.656 pm
>>> UUID: d6d9910f-fa67-4c69-9a89-030c81233e90
>>> Ancestors: Network-topa.165
>>>
>>> UUIDGenerator
>>> - Use new Random>>#nextBytes:into:startingAt: (needs Kernel-ul.960) for even more speed
>>> - Fix UUIDGenerator class>>#initialize to correctly register at startup
>>> - Do not reset default on startup but rather reseed TheRandom
>>>
>>> Timings improved:  '1,190,000 per second. 842 nanoseconds per run.' (0.25 times slower than primitive version)
>>>
>>
>> This is outstanding. The UUID plugin has long been a source of problems in
>> the VM, partly due to issues in various Linux distributions.
>>
>> http://bugs.squeak.org/view.php?id=7358
>>
>> Making the plugin unnecessary is a big improvement.
>
> Thats what I thought.
> Probably we want to present this (Mersenne PRNG + new UUID gen) to
> the Pharo core developers (cc) so that we can just remove the UUID plugin
> from the VMs (cc vm-dev)?
>
> Best regards
> -Tobias
In the release version of Squeak 5.0, the Mersenne Twister is initialized using a single seed restricted to 32bit.
Has this been changed since to use a wider ranged value?
Otherwise, you run into problems with potential collisions from separate image starts rather too fast for UUID uses... (IMHO)

Cheers,
Henry



signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] [Vm-dev] [squeak-dev] The Trunk: Network-topa.166.mcz

Levente Uzonyi-2
On Thu, 22 Oct 2015, Henrik Johansen wrote:

>
>> On 22 Oct 2015, at 2:49 , Tobias Pape <[hidden email]> wrote:
>>
>>
>>
>> On 22.10.2015, at 14:37, David T. Lewis <[hidden email]> wrote:
>>
>>> On Thu, Oct 22, 2015 at 06:28:09AM +0000, [hidden email] wrote:
>>>> Tobias Pape uploaded a new version of Network to project The Trunk:
>>>> http://source.squeak.org/trunk/Network-topa.166.mcz
>>>>
>>>> ==================== Summary ====================
>>>>
>>>> Name: Network-topa.166
>>>> Author: topa
>>>> Time: 21 October 2015, 8:26:14.656 pm
>>>> UUID: d6d9910f-fa67-4c69-9a89-030c81233e90
>>>> Ancestors: Network-topa.165
>>>>
>>>> UUIDGenerator
>>>> - Use new Random>>#nextBytes:into:startingAt: (needs Kernel-ul.960) for even more speed
>>>> - Fix UUIDGenerator class>>#initialize to correctly register at startup
>>>> - Do not reset default on startup but rather reseed TheRandom
>>>>
>>>> Timings improved:  '1,190,000 per second. 842 nanoseconds per run.' (0.25 times slower than primitive version)
>>>>
>>>
>>> This is outstanding. The UUID plugin has long been a source of problems in
>>> the VM, partly due to issues in various Linux distributions.
>>>
>>> http://bugs.squeak.org/view.php?id=7358
>>>
>>> Making the plugin unnecessary is a big improvement.
>>
>> Thats what I thought.
>> Probably we want to present this (Mersenne PRNG + new UUID gen) to
>> the Pharo core developers (cc) so that we can just remove the UUID plugin
>> from the VMs (cc vm-dev)?
>>
>> Best regards
>> -Tobias
>
> In the release version of Squeak 5.0, the Mersenne Twister is initialized using a single seed restricted to 32bit.
> Has this been changed since to use a wider ranged value?
> Otherwise, you run into problems with potential collisions from separate image starts rather too fast for UUID uses... (IMHO)

No, that's still something to be done[1].

Levente

[1] http://lists.squeakfoundation.org/pipermail/squeak-dev/2015-October/186409.html

>
> Cheers,
> Henry
>