After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 678576 - GIOScheduler performance enhancements
GIOScheduler performance enhancements
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-06-21 21:12 UTC by Colin Walters
Modified: 2012-06-25 21:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GIOScheduler: Avoid constant iteration over pending job list (2.30 KB, patch)
2012-06-21 21:12 UTC, Colin Walters
committed Details | Review
GIOScheduler: Use a GList, not GSList for jobs (2.60 KB, patch)
2012-06-21 21:12 UTC, Colin Walters
committed Details | Review
Revert "GIOScheduler: Avoid constant iteration over pending job list" (2.25 KB, patch)
2012-06-25 14:40 UTC, Allison Karlitskaya (desrt)
none Details | Review
Revert "GIOScheduler: Avoid constant iteration over pending job list" (2.25 KB, patch)
2012-06-25 14:42 UTC, Allison Karlitskaya (desrt)
committed Details | Review
GIOScheduler: Disconnect from cancellable after job completes (1.76 KB, patch)
2012-06-25 15:46 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2012-06-21 21:12:22 UTC
This bit is the top CPU usage in my app.
Comment 1 Colin Walters 2012-06-21 21:12:24 UTC
Created attachment 216969 [details] [review]
GIOScheduler: Avoid constant iteration over pending job list

The iteration over the list (while holding a mutex) was a serious
performance hit for asynchronous I/O.  We can just use
g_cancellable_connect().
Comment 2 Colin Walters 2012-06-21 21:12:27 UTC
Created attachment 216970 [details] [review]
GIOScheduler: Use a GList, not GSList for jobs

In general, code using g_slist_delete_link() is broken, because it
potentially requires an O(n) traversal.  Just switch to GList in this
case.

The performance hit here was exacerbated by the fact that we were
holding a mutex that needed to be accessed by all threads.
Comment 3 Matthias Clasen 2012-06-22 11:00:10 UTC
Review of attachment 216969 [details] [review]:

Looks reasonable. Do we have any tests that exercise this functionality ?
Comment 4 Matthias Clasen 2012-06-22 11:21:50 UTC
Review of attachment 216970 [details] [review]:

Looks fine, but this may very well be superseded by the GTask work soon...
Comment 5 Colin Walters 2012-06-22 15:40:35 UTC
(In reply to comment #3)
> Review of attachment 216969 [details] [review]:
> 
> Looks reasonable. Do we have any tests that exercise this functionality ?

Yep, gio/tests/cancellable.c hits this heavily.
Comment 6 Colin Walters 2012-06-22 15:44:01 UTC
(In reply to comment #4)
> Review of attachment 216970 [details] [review]:
> 
> Looks fine, but this may very well be superseded by the GTask work soon...

True.  There'll likely be code outside of GLib using GSimpleAsyncResult for quite a while though.

These patches are also a convenient target for backporting if someone else hits this problem.
Comment 7 Colin Walters 2012-06-22 15:48:47 UTC
Attachment 216969 [details] pushed as 2839297 - GIOScheduler: Avoid constant iteration over pending job list
Attachment 216970 [details] pushed as 991d07d - GIOScheduler: Use a GList, not GSList for jobs
Comment 8 Allison Karlitskaya (desrt) 2012-06-25 14:37:02 UTC
The GCancellable patch is causing crashes (including in the regression tests...).

After looking at it for a bit I think the best thing to do is revert it for the release today and revisit the issue after...
Comment 9 Allison Karlitskaya (desrt) 2012-06-25 14:40:47 UTC
Created attachment 217207 [details] [review]
Revert "GIOScheduler: Avoid constant iteration over pending job list"

This reverts commit 2839297686a9305b4fa909b93c337ef1d1a5e94b.

Conflicts:

	gio/gioscheduler.c
Comment 10 Allison Karlitskaya (desrt) 2012-06-25 14:42:02 UTC
Created attachment 217208 [details] [review]
Revert "GIOScheduler: Avoid constant iteration over pending job list"

This reverts commit 2839297686a9305b4fa909b93c337ef1d1a5e94b.

Conflicts:

	gio/gioscheduler.c
Comment 11 Colin Walters 2012-06-25 15:21:14 UTC
(In reply to comment #8)
> The GCancellable patch is causing crashes (including in the regression
> tests...).
> 
> After looking at it for a bit I think the best thing to do is revert it for the
> release today and revisit the issue after...

Can you give me more information?  What host environment?  Which tests are crashing?  Can you give stack traces?
Comment 12 Colin Walters 2012-06-25 15:46:46 UTC
Created attachment 217220 [details] [review]
GIOScheduler: Disconnect from cancellable after job completes

This was causing crashes when a cancellable was canceled after the job
had completed.
Comment 13 Allison Karlitskaya (desrt) 2012-06-25 21:07:48 UTC
Comment on attachment 217208 [details] [review]
Revert "GIOScheduler: Avoid constant iteration over pending job list"

Committed and did the 2.33.3 release.
Comment 14 Allison Karlitskaya (desrt) 2012-06-25 21:08:20 UTC
Comment on attachment 217220 [details] [review]
GIOScheduler: Disconnect from cancellable after job completes

Reverted the previous commit and committed this on master after the release.

We've already gotten feedback that it was fixing the issues that everyone was seeing and the testcases are passing as well.