Closed Bug 197301 Opened 22 years ago Closed 7 years ago

[gtk2] combine XInternAtom calls to improve perf

Categories

(Core :: XUL, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: blizzard, Assigned: blizzard)

References

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

Should combine these into a single XInternAtoms() call if we can.  Keithp knows
the names of the atoms in question.
Here's a list of all of the atoms that Mozilla uses at startup time.  If
XInternAtoms was called before they were used, a single round trip would collect
all of the names and stick them into the Xlib cache.  Subsequent XInternAtom
calls from Mozilla or Gtk+ would then not require a separate round trip.

This may seem like a petty performance improvement, but with Blizzard's current
Gtk2 codebase, this turns out to be one of the most time consuming part of
application startup.

MANAGER
UTF8_STRING
WM_CLIENT_LEADER
WM_DELETE_WINDOW
WM_LOCALE_NAME
WM_PROTOCOLS
WM_TAKE_FOCUS
XdndAware
_MOTIF_DRAG_RECEIVER_INFO
_MOZILLA_COMMAND
_MOZILLA_LOCK
_MOZILLA_RESPONSE
_MOZILLA_USER
_MOZILLA_VERSION
_NET_WM_DESKTOP
_NET_WM_ICON
_NET_WM_ICON_NAME
_NET_WM_NAME
_NET_WM_PID
_NET_WM_PING
_NET_WM_STATE
_NET_WM_STATE_FULLSCREEN
_NET_WM_STATE_MAXIMIZED_HORZ
_NET_WM_STATE_MAXIMIZED_VERT
_NET_WM_STATE_STICKY
_NET_WM_WINDOW_TYPE
_NET_WM_WINDOW_TYPE_NORMAL
_XSETTINGS_S0
_XSETTINGS_SETTINGS
i'm not sure if this is the proper location in the code to do this, but i
figured the call should be made right after gtk_init() (and thus the connection
to the X server is opened).  it _seems_ to make startup a little faster (on my
gtk2 build), but that is more than likely just wishful thinking/my imagination.
Summary: [gtk2] combine XInternAtom calls to increase perf → [gtk2] combine XInternAtom calls to improve perf
Keywords: perf
can we get this to bake on a Linux or Sun tinderbox to verify the performance
improvement ?
can you replace the hardcoded 29 with NS_ARRAY_LENGTH(cache_atoms)? that makes
it more obvious where the number comes from, and avoids having to change it when
new items are added.
Attached patch version 0.2 (deleted) — Splinter Review
biesi: Can you review this?
Who could sr? blizzard says "not doing reviews".
Attachment #131091 - Attachment is obsolete: true
Attachment #196835 - Flags: review?(cbiesinger)
Comment on attachment 196835 [details] [diff] [review]
version 0.2

sorry, I'd rather not. please try someone who actually knows X11.
Attachment #196835 - Flags: review?(cbiesinger)
Comment on attachment 196835 [details] [diff] [review]
version 0.2

Maybe bryner? I have no idea, really.
Attachment #196835 - Flags: review?(bryner)
Comment on attachment 196835 [details] [diff] [review]
version 0.2

How much of a perf win is this?
Comment on attachment 196835 [details] [diff] [review]
version 0.2

I have an Seamonkey objdir build with the patch applied, and run
measure-simple.pl. Revoke the patch and go into 'obj/xpfe/bootstrap', execute
'make' and run measure-simple.pl again.

If that is the right way to do it, the startup win here is almost nonexistent
(around 0.01sec average from 3 startups).
The performance win in the local case will be negligible, but in the remote case
you've eliminated 28 round trips. Multiply that by the RTT for your connection
and you get a good idea of the startup performance improvement.
Comment on attachment 196835 [details] [diff] [review]
version 0.2

Should we do this on Mac, too?

Also, maybe cache_atoms should be const.
Comment on attachment 196835 [details] [diff] [review]
version 0.2

Code-wise it's fine, but I think it's hard to read if you're looking through the startup sequence and then run into this giant list of atoms.  I think what I'd prefer is if the atom list was defined in a separate header file (exported from widget/src/gtk2), which nsAppRunner pulls in.  The array should be |static const char * const cache_atoms[] = { }|, too (you don't need to explicitly put the length when intializing an array this way).
Attachment #196835 - Flags: review?(bryner) → review-
QA Contact: jrgmorrison → xptoolkit.widgets
We removed gtk2 in bug 1278282. Even if this bug might still be relevant with gtk3, it has been 10 years...
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: