[webkit-changes] [WebKit/WebKit] 6c9eb0: Entity storage is not very compact

Ahmad Saleem noreply at github.com
Sun Mar 5 13:48:53 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6c9eb0e31985f0ab9bcfa34198da9cf10f1dfa6a
      https://github.com/WebKit/WebKit/commit/6c9eb0e31985f0ab9bcfa34198da9cf10f1dfa6a
  Author: Ahmad Saleem <ahmad.saleem792+github at gmail.com>
  Date:   2023-03-05 (Sun, 05 Mar 2023)

  Changed paths:
    M Source/WebCore/html/parser/HTMLEntityParser.cpp
    M Source/WebCore/html/parser/HTMLEntitySearch.cpp
    M Source/WebCore/html/parser/HTMLEntityTable.h
    M Source/WebCore/html/parser/create-html-entity-table

  Log Message:
  -----------
  Entity storage is not very compact

https://bugs.webkit.org/show_bug.cgi?id=250640
rdar://problem/104525785

Reviewed by Darin Adler.

Merge - https://chromium.googlesource.com/chromium/blink/+/0c7555da9c7b6059b8f55820b5b21685469a42c1

The entity table contained pointers which both makes it big and prevents
it from being reused as-is from the binary. This changes it to make
the storage more compact by replacing pointers with offsets into a
shared string. Also switching to more compact data types.

The new database will look like:

static const LChar staticEntityStringStorage[] = {
'A', 'E', 'l', 'i', 'g',
';',
'A', 'M', 'P',
';',
'A', 'a', 'c', 'u', 't', 'e',
';',
...

static const HTMLEntityTableEntry staticEntityTable[2231] = {
    { 0x000C6, 0, 0, 5 }, // &AElig
    { 0x000C6, 0, 0, 6 }, // Æ
    { 0x00026, 0, 6, 3 }, // &AMP
    { 0x00026, 0, 6, 4 }, // &
    { 0x000C1, 0, 10, 6 }, // &Aacute
...

It accomplishes the savings by avoiding pointers in the data (resolving pointers
during startup is expensive), using one string instead of 2000+, not storing the
trailing NUL byte, ordering the members for minimum padding, using minimal size
data types and reusing the same string space for things like "amp;" and "amp".

This is performance neutral on local testing and does not have any regression on Speedometer
using M1 Pro Macbook.

* Source/WebCore/html/parser/HTMLEntityParser.cpp:
* Source/WebCore/html/parser/HTMLEntitySearch.cpp:
(HTMLEntitySearch::compare):
* Source/WebCore/html/parser/HTMLEntityTable.h:
* Source/WebCore/html/parser/create-html-entity-table:

Canonical link: https://commits.webkit.org/261245@main




More information about the webkit-changes mailing list