On 6/7/13 6:43 AM, Benjamin Smedberg wrote:
On 6/5/2013 8:42 PM, Patrick Walton wrote:
Topics covered: Interning, mutability, cost of creating string
objects, encoding UTF-8 versus UTF-16.

https://github.com/mozilla/servo/wiki/Strings
I would love to have been invited to this meeting. Was it announced
anywhere?

It was kind of an impromptu thing; should have been announced more widely, sorry.

  * Gecko has mutable strings and this is bad for performance

I'd like to understand/challenge this statement. Is this bad for
performance because you have to check the extra SHARED flag on write?
With auto-sharing forcing immutability, I have trouble believing this is
a big deal in practice. The noticeable problem with auto-sharing right
now is that it requires threadsafe refcounting, which *does* show up in
benchmarks, but that would continue to be a problem with immutable
strings, if they needed to be thread-shareable. Was there discussion
about whether these strings would be at all threadsafe (and the
interning table)?

The tentative conclusion was that thread safety is not needed for the interning table, because the layout thread does not need to intern strings (and CSS parsing is handled on the script thread in Servo), only to access the contents of interned strings. In the rare cases in which layout would need to hang onto a non-static interned string across invocations it could just copy the strings, but bz felt that such cases would be rare.

My primary concern with string builders is that they typically
reallocate when you convert the builder to an immutable string. If we
can avoid that case by reassigning the buffer, then I think most of my
objections go away.

In Rust a "string builder" is just a mutable unique string, and it won't reallocate when you convert it to immutable. (This is the "freeze"/"thaw" pattern.)

Was there discussion about whether string buffers should be refcounted
or GCed (or copied, but I'm pretty sure that would cause memory explosion)?

Ref counting versus GC is determined on a case-by-case basis in Servo. There's no one-size-fits-all solution: we're using threadsafe reference counting, or unique strings, or possibly-interned strings, as the situation calls for it. Admittedly this is kind of a non-answer. :) I'd be curious as to which specific situations you had in mind.

Patrick

_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to