WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
150590
[GTK] Use a persistent main loop source in RunLoop glib implementation
https://bugs.webkit.org/show_bug.cgi?id=150590
Summary
[GTK] Use a persistent main loop source in RunLoop glib implementation
Carlos Garcia Campos
Reported
2015-10-27 07:26:21 PDT
It's more efficient than creating and destroying a new source for every dispatch and it simplifies the code.
Attachments
Patch
(10.45 KB, patch)
2015-10-27 07:33 PDT
,
Carlos Garcia Campos
zan
: review+
Details
Formatted Diff
Diff
Patch for landing
(10.02 KB, patch)
2015-10-30 04:21 PDT
,
Carlos Garcia Campos
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Carlos Garcia Campos
Comment 1
2015-10-27 07:33:08 PDT
Created
attachment 264130
[details]
Patch
Zan Dobersek
Comment 2
2015-10-28 00:54:46 PDT
Comment on
attachment 264130
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=264130&action=review
> Source/WTF/wtf/glib/RunLoopGLib.cpp:146 > stop(); > + g_source_destroy(m_source.get());
Is stop() still bringing anything here, given that the source is destroyed afterwards?
> Source/WTF/wtf/glib/RunLoopGLib.cpp:152 > + gint64 current = g_get_monotonic_time(); > + g_source_set_ready_time(m_source.get(), m_fireInterval.count() ? current + m_fireInterval.count() : current);
I'd advise special-casing the 0-microsecond delay here, which is the most common.
> gint64 delay = 0; > if (m_fireInterval.count()) > delay = g_get_monotonic_time() + m_fireInterval.count() > g_source_set_ready_time(m_source.get(), delay);
That way you avoid querying the monotonic time for most cases, and 0 delay still means 'dispatch ASAP' in GLib.
> Source/WTF/wtf/glib/RunLoopGLib.cpp:157 > + stop();
Is stop() useful here? The source's ready time is updated afterwards anyway.
Carlos Garcia Campos
Comment 3
2015-10-29 04:47:27 PDT
(In reply to
comment #2
)
> Comment on
attachment 264130
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=264130&action=review
> > > Source/WTF/wtf/glib/RunLoopGLib.cpp:146 > > stop(); > > + g_source_destroy(m_source.get()); > > Is stop() still bringing anything here, given that the source is destroyed > afterwards?
Nope, it can be just removed.
> > Source/WTF/wtf/glib/RunLoopGLib.cpp:152 > > + gint64 current = g_get_monotonic_time(); > > + g_source_set_ready_time(m_source.get(), m_fireInterval.count() ? current + m_fireInterval.count() : current); > > I'd advise special-casing the 0-microsecond delay here, which is the most > common.
Ok.
> > gint64 delay = 0; > > if (m_fireInterval.count()) > > delay = g_get_monotonic_time() + m_fireInterval.count() > > g_source_set_ready_time(m_source.get(), delay); > > That way you avoid querying the monotonic time for most cases, and 0 delay > still means 'dispatch ASAP' in GLib.
Ah, right, I guess we can do this too g_source_set_ready_time(m_source.get(), m_fireInterval.count() ? g_get_monotonic_time() + m_fireInterval.count() : 0);
> > Source/WTF/wtf/glib/RunLoopGLib.cpp:157 > > + stop(); > > Is stop() useful here? The source's ready time is updated afterwards anyway.
Nope, it's also useless
Carlos Garcia Campos
Comment 4
2015-10-29 05:20:33 PDT
Committed
r191728
: <
http://trac.webkit.org/changeset/191728
>
WebKit Commit Bot
Comment 5
2015-10-29 06:09:18 PDT
Re-opened since this is blocked by
bug 150668
Carlos Garcia Campos
Comment 6
2015-10-30 04:21:54 PDT
Created
attachment 264389
[details]
Patch for landing Found the problem of the timeouts in the bots. I was cancelling the persistent source in RunLoop:stop(). In case of nested main loop, if there are pedning tasks in the parent loop, the source is invalidated and the pending tasks are never done. We don't really need to cancel the source on stop, since the main loop will be stopped anyway and the main context won't process more sources. So, this patch simply removes the set_ready_time to -1 line in RunLoop::stop()
Carlos Garcia Campos
Comment 7
2015-10-30 04:29:11 PDT
Committed
r191786
: <
http://trac.webkit.org/changeset/191786
>
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