[webkit-gtk] dns prefetching knob

Marco Peereboom slash at peereboom.us
Wed Mar 9 09:44:06 PST 2011


On Wed, Mar 09, 2011 at 08:55:37AM -0800, Martin Robinson wrote:
> On Wed, Mar 9, 2011 at 6:28 AM, Marco Peereboom <slash at peereboom.us> wrote:
> > Hence the knobbing part. ??Some people have legitimate use for it which
> > is of course fine. ??I want it for performance reasons but also to
> > prevent DNS tracking. ??Between DNS prefetching, link hovering and the
> > empty DNS lookups webkit generates one can get near pixel resolution on
> > how the user moves his mouse. ??This comes in handy for "Online
> > Behavioral Tracking". ??Being a practical paranoid I'd like to prevent
> > that.
> 
> Is it possible for you to make the tools you used to generate your
> performance number available publically? This would help us fix any
> performance issues that exist as bugs. This may very well be some
> weird corner case that we're hitting in libsoup. Let's fix it!

Sure, it is far less interesting than you'd hope for ;-)

The patch at the bottom is what generates the numbers I quoted.  It goes
against the in tree cvs version of xxxterm.

Tree is at:
CVSROOT=anoncvs at opensource.conformal.com:/anoncvs/xxxterm

The DNS lookup stuff I measured with the adsuck stats but I don't think
that is pertinent to this discussion.  If you guys want a rundown on
that as well let me know and I'll show ya.

> I do not think there is any harm in exposing this setting. I do
> believe that those pushing for it should try to clarify what it is
> though. From what I gather it's effectively two pieces:
> 
> 1. A backport of a Settings.cpp DNS prefetch change to the stable branch.

Correct.

> 2. New code which exposes this setting in the WebKitWebSettings WebKitGTK+ API.

Right.

> Really it should just be the change to WebKitWebSettings and a request
> to merge both changes back into the stable branch. Be aware that we
> are desperately close to cutting the stable branch for 1.4.x.

This is why I really really really would like to get this cranking :-)

> --Martin

Index: xxxterm.c
===================================================================
RCS file: /cvs/xxxterm/xxxterm/xxxterm.c,v
retrieving revision 1.348
diff -u -p -u -p -r1.348 xxxterm.c
--- xxxterm.c	8 Mar 2011 23:19:36 -0000	1.348
+++ xxxterm.c	9 Mar 2011 17:38:34 -0000
@@ -218,6 +218,9 @@ struct tab {
 	WebKitWebSettings	*settings;
 	int			font_size;
 	gchar			*user_agent;
+
+	struct timeval		sod;
+	struct timeval		eod;
 };
 TAILQ_HEAD(tab_list, tab);
 
@@ -492,6 +495,7 @@ char		*user_agent = NULL;
 int		save_rejected_cookies = 0;
 time_t		session_autosave = 0;
 int		guess_search = 0;
+int		dns_prefetch = FALSE;
 
 struct settings;
 struct key_binding;
@@ -5768,6 +5772,7 @@ notify_load_status_cb(WebKitWebView* wvi
 	struct history		*h, find;
 	const gchar		*s_loading;
 	struct karg		a;
+	struct timeval		elapsed;
 
 	DNPRINTF(XT_D_URL, "notify_load_status_cb: %d\n",
 	    webkit_web_view_get_load_status(wview));
@@ -5780,6 +5785,7 @@ notify_load_status_cb(WebKitWebView* wvi
 	switch (webkit_web_view_get_load_status(wview)) {
 	case WEBKIT_LOAD_PROVISIONAL:
 		/* 0 */
+		gettimeofday(&t->sod, NULL);
 		abort_favicon_download(t);
 #if GTK_CHECK_VERSION(2, 20, 0)
 		gtk_widget_show(t->spinner);
@@ -5865,6 +5871,11 @@ notify_load_status_cb(WebKitWebView* wvi
 			gtk_label_set_text(GTK_LABEL(t->label), "(untitled)");
 	default:
 		gtk_widget_set_sensitive(GTK_WIDGET(t->stop), FALSE);
+
+		gettimeofday(&t->eod, NULL);
+		timersub(&t->eod, &t->sod, &elapsed);
+		fprintf(stderr, "prefetch %d:  page load time: %ld.%.6ld  ->   %s\n",
+		    dns_prefetch, elapsed.tv_sec, elapsed.tv_usec, uri);
 		break;
 	}
 
@@ -6618,6 +6629,8 @@ stop_cb(GtkWidget *w, struct tab *t)
 void
 setup_webkit(struct tab *t)
 {
+	g_object_set(G_OBJECT(t->settings),
+	    "dns-prefetching", dns_prefetch, (char *)NULL);
 	g_object_set(G_OBJECT(t->settings),
 	    "user-agent", t->user_agent, (char *)NULL);
 	g_object_set(G_OBJECT(t->settings),


More information about the webkit-gtk mailing list