Hi, I put a line in ExternalStringTable.AddString to output the number of registered external strings (both new and old space) and when running Dromaeo DOM tests the number usually stays around 200 and spikes for one test up to 10000. When browsing sites like mashable.com the number of external strings are at most a few thousands. I think a few dozens of kilobytes for an additional field as pointer cache is a small price to pay to speed up external strings to almost the level of internal strings. This cache would be set on first time the string is accessed and cleared when finalizing or serializing the external string. The upside of this is also that we can speed up other generated string operations such as string compare.
Yang On Tue, Nov 15, 2011 at 9:43 PM, Vitaly Repeshko <[email protected]>wrote: > On Tue, Nov 15, 2011 at 12:35 PM, Yang Guo <[email protected]> wrote: > > I had the impression that the data method in the resource may return > > different pointers, as long as the string content is the same. But in > > the case Vitaly described, it would indeed be easier and better to > > just cache the string pointer. How/when are external strings disposed? > > Would it be possible to replace the resource field by the string > > pointer after the first call of resource()->data(), destruct the > > resource object since we dont need it anymore, and change the map to > > indicate this? > > The data() method indeed may return different pointers (provided the > string content is the same), but it has no way to detect when a > previously returned pointer is no longer required so it has to keep it > valid. That said, I don't think right now V8 really exercises on this > property, most accesses are short lived. > > So, yes, it's tempting to replace the resource pointer with the data > pointer right away, but the embedder relies on the destructor of the > resource object being called when the string is GC'ed to clean up the > native state. Search for "ExternalStringTable". > > > -- Vitaly > > > On Nov 15, 2011, at 20:12, "[email protected]" <[email protected]> wrote: > > > >> My immediate thought would be the same: If we have a word to spare in > the String > >> structure, we might as well let it point directly to the real character > data > >> instead of pointing to an intermediate buffer. > >> It might require tweaking of GC, since it would be a native pointer, > but so is > >> the resource pointer, so it should be doable. > >> > >> We were considering adding such a pointer recently, but the overhead of > adding > >> an extra pointer to all external strings seemed steep. It's a good idea > to only > >> do it to some strings. > >> > >> > >> > >> http://codereview.chromium.org/8568013/ > > > -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
