Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-07 Thread Filip Pizlo


Sent from my PDP-11

On Jun 7, 2013, at 6:18 AM, Simon Fraser  wrote:

> Based on the fact that AtomicString is really a singleton string, I’d like to 
> suggest a new name for this class:
> 
> Stringleton

+1

> 
> Simon
> 
> On Jun 3, 2013, at 3:37 PM, Brendan Long  wrote:
> 
>> On 06/01/2013 10:09 PM, Glenn Adams wrote:
>>> But the name did throw me, since I asked myself "what makes this more 
>>> 'atomic' than String, synchronicity wise"? I'm sure I'm not the only one 
>>> who wondered about this.
>> Before asking this question I had assumed AtomicString was an atomic type 
>> (as in, safe to use in multi-threaded code). InternedString would have been 
>> more obvious, but the biggest problem was that searching for "WebKit 
>> AtomicString" didn't return any results that explained what it was. Now the 
>> top hit has an explanation, so it's not a big deal.
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-07 Thread Geoffrey Garen
The Lisp name for this concept is "Symbol".

The C/C++/JavaScript name is "Identifier".

Geoff

On Jun 7, 2013, at 6:18 AM, Simon Fraser  wrote:

> Based on the fact that AtomicString is really a singleton string, I’d like to 
> suggest a new name for this class:
> 
> Stringleton
> 
> Simon
> 
> On Jun 3, 2013, at 3:37 PM, Brendan Long  wrote:
> 
>> On 06/01/2013 10:09 PM, Glenn Adams wrote:
>>> But the name did throw me, since I asked myself "what makes this more 
>>> 'atomic' than String, synchronicity wise"? I'm sure I'm not the only one 
>>> who wondered about this.
>> Before asking this question I had assumed AtomicString was an atomic type 
>> (as in, safe to use in multi-threaded code). InternedString would have been 
>> more obvious, but the biggest problem was that searching for "WebKit 
>> AtomicString" didn't return any results that explained what it was. Now the 
>> top hit has an explanation, so it's not a big deal.
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-07 Thread Simon Fraser
Based on the fact that AtomicString is really a singleton string, I’d like to 
suggest a new name for this class:

Stringleton

Simon

On Jun 3, 2013, at 3:37 PM, Brendan Long  wrote:

> On 06/01/2013 10:09 PM, Glenn Adams wrote:
>> But the name did throw me, since I asked myself "what makes this more 
>> 'atomic' than String, synchronicity wise"? I'm sure I'm not the only one who 
>> wondered about this.
> Before asking this question I had assumed AtomicString was an atomic type (as 
> in, safe to use in multi-threaded code). InternedString would have been more 
> obvious, but the biggest problem was that searching for "WebKit AtomicString" 
> didn't return any results that explained what it was. Now the top hit has an 
> explanation, so it's not a big deal.

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-03 Thread Brendan Long
On 06/01/2013 10:09 PM, Glenn Adams wrote:
> But the name did throw me, since I asked myself "what makes this more
> 'atomic' than String, synchronicity wise"? I'm sure I'm not the only
> one who wondered about this.
Before asking this question I had assumed AtomicString was an atomic
type  (as in, safe to
use in multi-threaded code). InternedString would have been more
obvious, but the biggest problem was that searching for "WebKit
AtomicString" didn't return any results that explained what it was. Now
the top hit  has an
explanation, so it's not a big deal.


signature.asc
Description: OpenPGP digital signature
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-02 Thread Maciej Stachowiak

On Jun 2, 2013, at 3:49 AM, Glenn Adams  wrote:

> 
> On Sun, Jun 2, 2013 at 2:48 AM, Maciej Stachowiak  wrote:
> 
> On Jun 1, 2013, at 8:54 PM, Glenn Adams  wrote:
>> You guys obviously never wrote any Lisp code.
> 
> Um, why do you think I suggested "Symbol"? 
> 
> On Jun 1, 2013, at 9:09 PM, Glenn Adams  wrote:
>> Seriously, if "Atomic" isn't jargon, Intern isn't either.
> 
> Both are jargon. "Atom" and "Intern" in various forms are both used elsewhere 
> so will be relevant to people from some other technical communities. Neither 
> is completely obvious to the novice.
> 
> 
> Overall, I don't think any of the names suggested on this thread are 
> sufficiently better to be worth the transition cost (including my own 
> suggestions of Symbol and Atom).
> 
> Perhaps just adding a brief comment at the head of AtomicString.h to the 
> effect:
> 
> "This class might have been named SymbolString, AtomString, or 
> InternedString, but we're sticking with AtomicString for historical reasons, 
> and since the former are not markedly superior to the latter. Further, the 
> term Atomic is not intended to be read as meaning 'atomic' in the sense of 
> synchronic."

Explaining the purpose and nature of the class in a comment would be fine. But 
discussing the alternate names not chosen, or what the name doesn't mean -- 
that doesn't seem like good comment material. Too meta.

 - Maciej

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-02 Thread Glenn Adams
On Sun, Jun 2, 2013 at 2:48 AM, Maciej Stachowiak  wrote:

>
> On Jun 1, 2013, at 8:54 PM, Glenn Adams  wrote:
>
> You guys obviously never wrote any Lisp code.
>
>
> Um, why do you think I suggested "Symbol"?
>
> On Jun 1, 2013, at 9:09 PM, Glenn Adams  wrote:
>
> Seriously, if "Atomic" isn't jargon, Intern isn't either.
>
>
> Both are jargon. "Atom" and "Intern" in various forms are both used
> elsewhere so will be relevant to people from some other technical
> communities. Neither is completely obvious to the novice.
>
>
> Overall, I don't think any of the names suggested on this thread are
> sufficiently better to be worth the transition cost (including my own
> suggestions of Symbol and Atom).
>

Perhaps just adding a brief comment at the head of AtomicString.h to the
effect:

"This class might have been named SymbolString, AtomString, or
InternedString, but we're sticking with AtomicString for historical
reasons, and since the former are not markedly superior to the latter.
Further, the term Atomic is not intended to be read as meaning 'atomic' in
the sense of synchronic."


>
> Regards,
> Maciej
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-02 Thread Maciej Stachowiak

On Jun 1, 2013, at 8:54 PM, Glenn Adams  wrote:
> You guys obviously never wrote any Lisp code.

Um, why do you think I suggested "Symbol"? 

On Jun 1, 2013, at 9:09 PM, Glenn Adams  wrote:
> Seriously, if "Atomic" isn't jargon, Intern isn't either.

Both are jargon. "Atom" and "Intern" in various forms are both used elsewhere 
so will be relevant to people from some other technical communities. Neither is 
completely obvious to the novice.


Overall, I don't think any of the names suggested on this thread are 
sufficiently better to be worth the transition cost (including my own 
suggestions of Symbol and Atom).

Regards,
Maciej
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Ryosuke Niwa
On Sat, Jun 1, 2013 at 9:09 PM, Glenn Adams  wrote:

> On Sat, Jun 1, 2013 at 9:56 PM, Darin Adler  wrote:
>
>> On Jun 1, 2013, at 8:54 PM, Glenn Adams  wrote:
>>
>> > You guys obviously never wrote any Lisp code.
>>
>> Lets not play this game. When I met Maciej he was the maintainer of one
>> of the most popular Scheme implementations, if I remember correctly.
>>
>
> Sorry, I forgot to add a smiley... :)
>
> Seriously, if "Atomic" isn't jargon, Intern isn't either.
>

Neither jargon is good but if we're renaming AtomicString, then the new
name ought be significantly better than the old name because renaming WTF
classes used everywhere has a cost: it makes Subversion history less useful
and adds a churn; people reading the old code need to learn both equally
bad jargons "atomic" and "interned" and that they're the same class.

Another reason I don't think InternedString is a good name is the fact
WTFString also does copy-on-write of StringIml.

In general, the name of a class or a function should convey:

   1. what the class does or how it's implemented
   2. what the class is or should be used for

AtomicString does 2 while InternedString does 1.  We should try to come up
with a name that does both.

- R. Niwa
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Simon Fraser
Gecko simply calls these “Atoms”. StringAtom? AtomString?

Simon

On Jun 1, 2013, at 9:09 PM, Glenn Adams  wrote:

> 
> On Sat, Jun 1, 2013 at 9:56 PM, Darin Adler  wrote:
> On Jun 1, 2013, at 8:54 PM, Glenn Adams  wrote:
> 
> > You guys obviously never wrote any Lisp code.
> 
> Lets not play this game. When I met Maciej he was the maintainer of one of 
> the most popular Scheme implementations, if I remember correctly.
> 
> Sorry, I forgot to add a smiley... :)
> 
> Seriously, if "Atomic" isn't jargon, Intern isn't either. In any case, I 
> don't particularly care either way. Once you learn its function, you forget 
> about the name. But the name did throw me, since I asked myself "what makes 
> this more 'atomic' than String, synchronicity wise"? I'm sure I'm not the 
> only one who wondered about this.
> 
> My reason for suggesting "Interned..." was simply because that was how 
> Ryosuke chose to characterize it as being different from String.

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Glenn Adams
On Sat, Jun 1, 2013 at 9:56 PM, Darin Adler  wrote:

> On Jun 1, 2013, at 8:54 PM, Glenn Adams  wrote:
>
> > You guys obviously never wrote any Lisp code.
>
> Lets not play this game. When I met Maciej he was the maintainer of one of
> the most popular Scheme implementations, if I remember correctly.
>

Sorry, I forgot to add a smiley... :)

Seriously, if "Atomic" isn't jargon, Intern isn't either. In any case, I
don't particularly care either way. Once you learn its function, you forget
about the name. But the name did throw me, since I asked myself "what makes
this more 'atomic' than String, synchronicity wise"? I'm sure I'm not the
only one who wondered about this.

My reason for suggesting "Interned..." was simply because that was how
Ryosuke chose to characterize it as being different from String.


>
> -- Darin
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Darin Adler
On Jun 1, 2013, at 8:54 PM, Glenn Adams  wrote:

> You guys obviously never wrote any Lisp code.

Lets not play this game. When I met Maciej he was the maintainer of one of the 
most popular Scheme implementations, if I remember correctly.

-- Darin
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Glenn Adams
You guys obviously never wrote any Lisp code.

http://books.google.com/books?id=FYoOIWuoXUIC&lpg=PA267&ots=ioaahFTKT0&dq=intern%20special%20form%20maclisp&pg=PA266#v=onepage&q=intern%20special%20form%20maclisp&f=false


On Sat, Jun 1, 2013 at 6:01 PM, Ryosuke Niwa  wrote:

> On Sat, Jun 1, 2013 at 4:45 PM, Maciej Stachowiak  wrote:
>
>>
>> On Jun 1, 2013, at 3:58 PM, Darin Adler  wrote:
>>
>> On May 31, 2013, at 8:01 PM, Glenn Adams  wrote:
>>
>> One thing that always threw me was the term "Atomic" in the class name. I
>> wonder if the term "InternedString" would make it usage more apparent.
>>
>>
>> I personally love the name AtomicString (the string of tomorrow) and have
>> been using that name for it for the past 10 years, but I see that
>> InternedString is what this would be called in Java and .NET context so I
>> guess we could change to help people familiar with those.
>>
>>
>> If we were to change the name, I'd go with Symbol or Atom. But I think
>> AtomicString is a fine name and I don't think InternedString is better. All
>> plausible names I can think of are jargon that you have to learn the first
>> time if you don't know it.
>>
>
> I don't like "InternedString" either.  In general, we should avoid using
> design pattern jargons like interning, mediator, flyweight, etc... when we
> can come up with a more descriptive name.
>
> - R. Niwa
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Ryosuke Niwa
On Sat, Jun 1, 2013 at 4:45 PM, Maciej Stachowiak  wrote:

>
> On Jun 1, 2013, at 3:58 PM, Darin Adler  wrote:
>
> On May 31, 2013, at 8:01 PM, Glenn Adams  wrote:
>
> One thing that always threw me was the term "Atomic" in the class name. I
> wonder if the term "InternedString" would make it usage more apparent.
>
>
> I personally love the name AtomicString (the string of tomorrow) and have
> been using that name for it for the past 10 years, but I see that
> InternedString is what this would be called in Java and .NET context so I
> guess we could change to help people familiar with those.
>
>
> If we were to change the name, I'd go with Symbol or Atom. But I think
> AtomicString is a fine name and I don't think InternedString is better. All
> plausible names I can think of are jargon that you have to learn the first
> time if you don't know it.
>

I don't like "InternedString" either.  In general, we should avoid using
design pattern jargons like interning, mediator, flyweight, etc... when we
can come up with a more descriptive name.

- R. Niwa
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Maciej Stachowiak

On Jun 1, 2013, at 3:58 PM, Darin Adler  wrote:

> On May 31, 2013, at 8:01 PM, Glenn Adams  wrote:
> 
>> One thing that always threw me was the term "Atomic" in the class name. I 
>> wonder if the term "InternedString" would make it usage more apparent.
> 
> I personally love the name AtomicString (the string of tomorrow) and have 
> been using that name for it for the past 10 years, but I see that 
> InternedString is what this would be called in Java and .NET context so I 
> guess we could change to help people familiar with those.

If we were to change the name, I'd go with Symbol or Atom. But I think 
AtomicString is a fine name and I don't think InternedString is better. All 
plausible names I can think of are jargon that you have to learn the first time 
if you don't know it.

Regards,
Maciej

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-06-01 Thread Darin Adler
On May 31, 2013, at 8:01 PM, Glenn Adams  wrote:

> One thing that always threw me was the term "Atomic" in the class name. I 
> wonder if the term "InternedString" would make it usage more apparent.

I personally love the name AtomicString (the string of tomorrow) and have been 
using that name for it for the past 10 years, but I see that InternedString is 
what this would be called in Java and .NET context so I guess we could change 
to help people familiar with those.

-- Darin
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Myles C. Maxfield
+1 :-)

On Friday, May 31, 2013, Glenn Adams wrote:

>
> On Fri, May 31, 2013 at 6:14 PM, Rafael Brandao 
>  'rafael.l...@openbossa.org');>
> > wrote:
>
>> This thread contains really useful information, so I've created a new
>> topic on https://trac.webkit.org/wiki/EfficientStrings and pointed to
>> here.
>>
>
> One thing that always threw me was the term "Atomic" in the class name. I
> wonder if the term "InternedString" would make it usage more apparent.
>
>
>>
>> Best regards,
>> Rafael
>>
>>
>> On Fri, May 31, 2013 at 8:32 PM, Ryosuke Niwa 
>> 
>> > wrote:
>>
>>> We shouldn't use AtomicString if the string we're about to create
>>> doesn't get shared across multiple AtomicStrings.
>>>
>>> For example, if we had used AtomicString for the strings inside Text
>>> nodes, then we may end up filling up the atomic string table with all these
>>> really long strings that don't typically appear more than once.  It also
>>> slows down the hash map look up for all other atomic strings.
>>>
>>> On Fri, May 31, 2013 at 3:00 PM, Brendan Long 
>>> 
>>> > wrote:
>>>
  So should I just never use String and always use AtomicString?


 On 05/31/2013 03:14 PM, Daker Pinheiro wrote:

 It is faster to compare and hash AtomicString than regular Strings.


 On Fri, May 31, 2013 at 5:57 PM, Brendan Long 
 
 > wrote:

> I hope this isn't a stupid question, but I can't find any references to
> what the difference between AtomicString and String is. It looks like
> AtomicString is generally preferred, but I don't know why. Can someone
> fill me in on this? Is there any refences for the classes in WTF?
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org  'webkit-dev@lists.webkit.org');>
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>


  --
 Daker Fernandes Pinheiro
 http://codecereal.blogspot.com



 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org >>> 'webkit-dev@lists.webkit.org');>
 https://lists.webkit.org/mailman/listinfo/webkit-dev


>>>
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org >> 'webkit-dev@lists.webkit.org');>
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>>
>>>
>>
>>
>> --
>> Rafael Brandao @ INdT
>>
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org > 'webkit-dev@lists.webkit.org');>
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Ryosuke Niwa
Great!  Maybe we even want to add it to
http://www.webkit.org/coding/technical-articles.html after converting it to
a web page?

- R. Niwa


On Fri, May 31, 2013 at 5:14 PM, Rafael Brandao
wrote:

> This thread contains really useful information, so I've created a new
> topic on https://trac.webkit.org/wiki/EfficientStrings and pointed to
> here.
>
> Best regards,
> Rafael
>
>
> On Fri, May 31, 2013 at 8:32 PM, Ryosuke Niwa  wrote:
>
>> We shouldn't use AtomicString if the string we're about to create doesn't
>> get shared across multiple AtomicStrings.
>>
>> For example, if we had used AtomicString for the strings inside Text
>> nodes, then we may end up filling up the atomic string table with all these
>> really long strings that don't typically appear more than once.  It also
>> slows down the hash map look up for all other atomic strings.
>>
>> On Fri, May 31, 2013 at 3:00 PM, Brendan Long wrote:
>>
>>>  So should I just never use String and always use AtomicString?
>>>
>>>
>>> On 05/31/2013 03:14 PM, Daker Pinheiro wrote:
>>>
>>> It is faster to compare and hash AtomicString than regular Strings.
>>>
>>>
>>> On Fri, May 31, 2013 at 5:57 PM, Brendan Long wrote:
>>>
 I hope this isn't a stupid question, but I can't find any references to
 what the difference between AtomicString and String is. It looks like
 AtomicString is generally preferred, but I don't know why. Can someone
 fill me in on this? Is there any refences for the classes in WTF?


 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 https://lists.webkit.org/mailman/listinfo/webkit-dev


>>>
>>>
>>>  --
>>> Daker Fernandes Pinheiro
>>> http://codecereal.blogspot.com
>>>
>>>
>>>
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>>
>>>
>>
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>>
>
>
> --
> Rafael Brandao @ INdT
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Glenn Adams
On Fri, May 31, 2013 at 6:14 PM, Rafael Brandao
wrote:

> This thread contains really useful information, so I've created a new
> topic on https://trac.webkit.org/wiki/EfficientStrings and pointed to
> here.
>

One thing that always threw me was the term "Atomic" in the class name. I
wonder if the term "InternedString" would make it usage more apparent.


>
> Best regards,
> Rafael
>
>
> On Fri, May 31, 2013 at 8:32 PM, Ryosuke Niwa  wrote:
>
>> We shouldn't use AtomicString if the string we're about to create doesn't
>> get shared across multiple AtomicStrings.
>>
>> For example, if we had used AtomicString for the strings inside Text
>> nodes, then we may end up filling up the atomic string table with all these
>> really long strings that don't typically appear more than once.  It also
>> slows down the hash map look up for all other atomic strings.
>>
>> On Fri, May 31, 2013 at 3:00 PM, Brendan Long wrote:
>>
>>>  So should I just never use String and always use AtomicString?
>>>
>>>
>>> On 05/31/2013 03:14 PM, Daker Pinheiro wrote:
>>>
>>> It is faster to compare and hash AtomicString than regular Strings.
>>>
>>>
>>> On Fri, May 31, 2013 at 5:57 PM, Brendan Long wrote:
>>>
 I hope this isn't a stupid question, but I can't find any references to
 what the difference between AtomicString and String is. It looks like
 AtomicString is generally preferred, but I don't know why. Can someone
 fill me in on this? Is there any refences for the classes in WTF?


 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 https://lists.webkit.org/mailman/listinfo/webkit-dev


>>>
>>>
>>>  --
>>> Daker Fernandes Pinheiro
>>> http://codecereal.blogspot.com
>>>
>>>
>>>
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>>
>>>
>>
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>>
>
>
> --
> Rafael Brandao @ INdT
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Rafael Brandao
This thread contains really useful information, so I've created a new topic
on https://trac.webkit.org/wiki/EfficientStrings and pointed to here.

Best regards,
Rafael


On Fri, May 31, 2013 at 8:32 PM, Ryosuke Niwa  wrote:

> We shouldn't use AtomicString if the string we're about to create doesn't
> get shared across multiple AtomicStrings.
>
> For example, if we had used AtomicString for the strings inside Text
> nodes, then we may end up filling up the atomic string table with all these
> really long strings that don't typically appear more than once.  It also
> slows down the hash map look up for all other atomic strings.
>
> On Fri, May 31, 2013 at 3:00 PM, Brendan Long wrote:
>
>>  So should I just never use String and always use AtomicString?
>>
>>
>> On 05/31/2013 03:14 PM, Daker Pinheiro wrote:
>>
>> It is faster to compare and hash AtomicString than regular Strings.
>>
>>
>> On Fri, May 31, 2013 at 5:57 PM, Brendan Long wrote:
>>
>>> I hope this isn't a stupid question, but I can't find any references to
>>> what the difference between AtomicString and String is. It looks like
>>> AtomicString is generally preferred, but I don't know why. Can someone
>>> fill me in on this? Is there any refences for the classes in WTF?
>>>
>>>
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>>
>>>
>>
>>
>>  --
>> Daker Fernandes Pinheiro
>> http://codecereal.blogspot.com
>>
>>
>>
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>


-- 
Rafael Brandao @ INdT
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Ryosuke Niwa
We shouldn't use AtomicString if the string we're about to create doesn't
get shared across multiple AtomicStrings.

For example, if we had used AtomicString for the strings inside Text nodes,
then we may end up filling up the atomic string table with all these really
long strings that don't typically appear more than once.  It also slows
down the hash map look up for all other atomic strings.

On Fri, May 31, 2013 at 3:00 PM, Brendan Long  wrote:

>  So should I just never use String and always use AtomicString?
>
>
> On 05/31/2013 03:14 PM, Daker Pinheiro wrote:
>
> It is faster to compare and hash AtomicString than regular Strings.
>
>
> On Fri, May 31, 2013 at 5:57 PM, Brendan Long wrote:
>
>> I hope this isn't a stupid question, but I can't find any references to
>> what the difference between AtomicString and String is. It looks like
>> AtomicString is generally preferred, but I don't know why. Can someone
>> fill me in on this? Is there any refences for the classes in WTF?
>>
>>
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>>
>
>
>  --
> Daker Fernandes Pinheiro
> http://codecereal.blogspot.com
>
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Darin Adler
On May 31, 2013, at 3:27 PM, Adam Barth  wrote:

> I believe we store a bit on StringImpl that makes conversion from String and 
> StringImpl to AtomicString fast
> if the underlying StringImpl is already in the AtomicStringTable.

Good point. Converting back to an atomic string costs only a single bit test 
and branch now; it’s almost free. My mistake.

-- Darin
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Adam Barth
On Fri, May 31, 2013 at 3:18 PM, Darin Adler  wrote:
> On May 31, 2013, at 1:57 PM, Brendan Long  wrote:
>> I hope this isn't a stupid question, but I can't find any references to what 
>> the difference between AtomicString and String is.
>
> WTF::AtomicString is a class that has four differences from the normal 
> WTF::String class:
>
> 1) It’s more expensive to create a new atomic string than a non-atomic 
> string; doing so requires a lookup in a per-thread atomic string hash table.
>
> 2) It’s very inexpensive to compare one atomic string with another. The cost 
> is just a pointer comparison. The actual string length and data don’t need to 
> be compared, because on any one thread no AtomicString can be equal to any 
> other AtomicString.
>
> 3) If a particular string already exists in the atomic string table, 
> allocating another string that is equal to it does not cost any additional 
> memory. The atomic string is shared and the cost is looking it up in the 
> per-thread atomic string hash table and incrementing its reference count.
>
> 4) There are special considerations if you want to use an atomic string on a 
> thread other than the one it was created on since each thread has its own 
> atomic string hash table.
>
> Generally speaking, we use AtomicString to make string comparisons fast and 
> to save memory when many equal strings are likely to be allocated. For 
> example, we use AtomicString for HTML attribute names so we can compare them 
> quickly, and for both HTML attribute names and values since it’s common to 
> have many identical ones and we save memory.
>
> It’s not a good idea to spend the extra cost to construct an AtomicString if 
> neither the comparison nor the memory savings applies.
>
> It’s unnecessarily costly to convert an atomic string to a non-atomic string 
> and then back to an atomic string, since it requires an additional hash table 
> lookup. Thus if you’re starting with an atomic string it’s best to keep the 
> value in variables of type AtomicString and AtomicStringImpl* if possible.

I don't mean to intrude, but I believe we store a bit on StringImpl
that makes conversion from String and StringImpl to AtomicString fast
if the underlying StringImpl is already in the AtomicStringTable:

https://trac.webkit.org/browser/trunk/Source/WTF/wtf/text/AtomicString.h#L185

ALWAYS_INLINE static PassRefPtr add(StringImpl* r)
{
if (!r || r->isAtomic())
return r;
return addSlowCase(r);
}

Adam
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Darin Adler
On May 31, 2013, at 1:57 PM, Brendan Long  wrote:

> I hope this isn't a stupid question, but I can't find any references to what 
> the difference between AtomicString and String is.

WTF::AtomicString is a class that has four differences from the normal 
WTF::String class:

1) It’s more expensive to create a new atomic string than a non-atomic string; 
doing so requires a lookup in a per-thread atomic string hash table.

2) It’s very inexpensive to compare one atomic string with another. The cost is 
just a pointer comparison. The actual string length and data don’t need to be 
compared, because on any one thread no AtomicString can be equal to any other 
AtomicString.

3) If a particular string already exists in the atomic string table, allocating 
another string that is equal to it does not cost any additional memory. The 
atomic string is shared and the cost is looking it up in the per-thread atomic 
string hash table and incrementing its reference count.

4) There are special considerations if you want to use an atomic string on a 
thread other than the one it was created on since each thread has its own 
atomic string hash table.

Generally speaking, we use AtomicString to make string comparisons fast and to 
save memory when many equal strings are likely to be allocated. For example, we 
use AtomicString for HTML attribute names so we can compare them quickly, and 
for both HTML attribute names and values since it’s common to have many 
identical ones and we save memory.

It’s not a good idea to spend the extra cost to construct an AtomicString if 
neither the comparison nor the memory savings applies.

It’s unnecessarily costly to convert an atomic string to a non-atomic string 
and then back to an atomic string, since it requires an additional hash table 
lookup. Thus if you’re starting with an atomic string it’s best to keep the 
value in variables of type AtomicString and AtomicStringImpl* if possible.

-- Darin
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Brendan Long
So should I just never use String and always use AtomicString?

On 05/31/2013 03:14 PM, Daker Pinheiro wrote:
> It is faster to compare and hash AtomicString than regular Strings.
>
>
> On Fri, May 31, 2013 at 5:57 PM, Brendan Long  > wrote:
>
> I hope this isn't a stupid question, but I can't find any
> references to
> what the difference between AtomicString and String is. It looks like
> AtomicString is generally preferred, but I don't know why. Can someone
> fill me in on this? Is there any refences for the classes in WTF?
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org 
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
>
>
> -- 
> Daker Fernandes Pinheiro
> http://codecereal.blogspot.com
>



signature.asc
Description: OpenPGP digital signature
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Yoav Weiss
Are there any advantages to String over AtomicString?


On Fri, May 31, 2013 at 11:14 PM, Daker Pinheiro <
daker.pinhe...@openbossa.org> wrote:

> It is faster to compare and hash AtomicString than regular Strings.
>
>
> On Fri, May 31, 2013 at 5:57 PM, Brendan Long wrote:
>
>> I hope this isn't a stupid question, but I can't find any references to
>> what the difference between AtomicString and String is. It looks like
>> AtomicString is generally preferred, but I don't know why. Can someone
>> fill me in on this? Is there any refences for the classes in WTF?
>>
>>
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>>
>
>
> --
> Daker Fernandes Pinheiro
> http://codecereal.blogspot.com
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] When should I use AtomicString vs String?

2013-05-31 Thread Daker Pinheiro
It is faster to compare and hash AtomicString than regular Strings.


On Fri, May 31, 2013 at 5:57 PM, Brendan Long  wrote:

> I hope this isn't a stupid question, but I can't find any references to
> what the difference between AtomicString and String is. It looks like
> AtomicString is generally preferred, but I don't know why. Can someone
> fill me in on this? Is there any refences for the classes in WTF?
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>


-- 
Daker Fernandes Pinheiro
http://codecereal.blogspot.com
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev