Hi Ben,
On Thu, Feb 6, 2014 at 9:19 AM, <b...@openinworld.com> wrote: > Clément Bera wrote: > > Hello pharoers, > > The new Cog memory manager, Spur, is simply *amazing*. I saw at FOSDEM > that some of you were interested in it, but unfortunately you were lacking > information about it. > > I wrote a one page article that sums up Spur's new features so every one > can know what will be better. There's no VM technical details here, it's > just about what will change for a regular pharo user. > > > http://clementbera.wordpress.com/2014/02/06/7-points-summary-of-the-spur-memory-manager/ > > Let me know if you think I forgot yet another feature. > > If you have questions, I'll try to answer, but ask Eliot, he implemented > Spur so he can answer your questions much better than I can :-). > > Regards, > > Clément > > > In what way would the speed-up for Characters being immediate improve > Unicode performance, and/or would it be worthwhile having an immediate > representation of UnicodeCharacters? I found Roassal to go an order of > magnitude slower when displaying labels with Unicode (but there may be many > reasons for that) ? > WideString>>at: index "Answer the Character stored in the field of the receiver indexed by the argument." ^ Character value: (self wordAt: index). Character class>>value: anInteger "Answer the Character whose value is anInteger." anInteger > 255 ifTrue: [^self basicNew setValue: anInteger]. ^ CharacterTable at: anInteger + 1. Currently characters are non-immediate and only the first 256 are unique. So every access of a character in a wide string requires an allocation of a character. In Spur, with immediate characters there is no instantiation. Further, because characters are simpler the JIT can produce machine-code to implement the primitives for WideString at: and at:put:, so WideString>>at: and WideString>>#at:put: will be primitive. So access will be very much faster. Here are some numbers measured on my 2.2GHz Core i7 MacBook Pro running 10.6.8. In current Cog | ws | ws := 'Hello world!' asWideString. [1 to: 100 * 1000 * 1000 do: [:i| ws at: 1]] timeToRun 2693 and | ws | ws := 'Hello world!' asWideString. ws at: 1 put: (Character value: 256). [1 to: 100 * 1000 * 1000 do: [:i| ws at: 1]] timeToRun 6100 If you redefine WideString>>at: in Spur to read WideString>>at: index "Primitive. Answer the Character stored in the field of the receiver indexed by the argument. Fail if the index argument is not an Integer or is out of bounds. Essential. See Object documentation whatIsAPrimitive." <primitive: 63> ^ Character value: (self wordAt: index). then | ws | ws := 'Hello world!' asWideString. [1 to: 100 * 1000 * 1000 do: [:i| ws at: 1]] timeToRun 711 and | ws | ws := 'Hello world!' asWideString. ws at: 1 put: (Character value: 256). [1 to: 100 * 1000 * 1000 do: [:i| ws at: 1]] timeToRun 761 These numbers are very noisy because I've got two images, Safari, Chrome and other things running. But you can see that in the case where the character is > 8 bits, the Spur code is > 8 times faster. -- best, Eliot