WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
93731
Use static AtomicStrings for HTTP header field names
https://bugs.webkit.org/show_bug.cgi?id=93731
Summary
Use static AtomicStrings for HTTP header field names
Yong Li
Reported
2012-08-10 11:38:10 PDT
Eevery call to m_httpHeaderFields.contains(<const c string>) constructs a new WTF::String, and calculate its hash again. This can be avoided by using static Strings. I have a patch for it. I haven't been able to tell how much it helps, but theoretically it saves CPU time on string constructing and hashing...
Attachments
Not ready for review yet.
(1021 bytes, patch)
2012-08-10 11:38 PDT
,
Yong Li
no flags
Details
Formatted Diff
Diff
not ready for review
(9.96 KB, patch)
2012-08-10 11:39 PDT
,
Yong Li
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Yong Li
Comment 1
2012-08-10 11:38:53 PDT
Created
attachment 157772
[details]
Not ready for review yet.
Yong Li
Comment 2
2012-08-10 11:39:14 PDT
Comment on
attachment 157772
[details]
Not ready for review yet. oops. not this one
Yong Li
Comment 3
2012-08-10 11:39:52 PDT
Created
attachment 157774
[details]
not ready for review
Yong Li
Comment 4
2012-08-10 11:40:57 PDT
is it worth doing?
Alexey Proskuryakov
Comment 5
2012-08-10 13:13:52 PDT
Comment on
attachment 157774
[details]
not ready for review View in context:
https://bugs.webkit.org/attachment.cgi?id=157774&action=review
I don't know. Probably not much harm, and not much good. Note however that the current patch is strictly a regression. These AtomicStrings have a regular hash pre-calculated, but HashMap uses CaseFoldingHash. So, the pre-caclculated hash will not be used. Generally, it's much easier to start with profiler data and optimize that's taking significant time than to figure out whether a random change improves performance.
> Source/WebCore/platform/network/ResourceRequestBase.cpp:43 > +AtomicString* ResourceRequestBase::headerNameAccept = new AtomicString("Accept");
This is not OK - we can not have global with initializers. No code should be run when WebKit shared library loads. You'll probably need a new file similar to HTMLNames.h.
Yong Li
Comment 6
2012-08-10 13:33:26 PDT
(In reply to
comment #5
)
> (From update of
attachment 157774
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=157774&action=review
> > I don't know. Probably not much harm, and not much good. > > Note however that the current patch is strictly a regression. These AtomicStrings have a regular hash pre-calculated, but HashMap uses CaseFoldingHash. So, the pre-caclculated hash will not be used.
Bang! I forgot this..
> > > Source/WebCore/platform/network/ResourceRequestBase.cpp:43 > > +AtomicString* ResourceRequestBase::headerNameAccept = new AtomicString("Accept"); > > This is not OK - we can not have global with initializers. No code should be run when WebKit shared library loads. > > You'll probably need a new file similar to HTMLNames.h.
Thanks!
Anders Carlsson
Comment 7
2014-06-18 12:38:15 PDT
This has been fixed; we now use an enum for header names.
Alexey Proskuryakov
Comment 8
2014-06-18 21:07:25 PDT
An enum? I wasn't watching these patches carefully, how does that support arbitrary header field names (exposed via XMLHttpRequest)?
Anders Carlsson
Comment 9
2014-06-19 10:25:20 PDT
(In reply to
comment #8
)
> An enum? I wasn't watching these patches carefully, how does that support arbitrary header field names (exposed via XMLHttpRequest)?
We use an enum for the common header types and regular strings for other headers.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug