Bokeh plot slow in Firefox, fast in Chrome

I’m rendering a 4000 point spectrum using bokeh.

plot = line(x, y,
color="#0000FF",
tools=“pan,wheel_zoom,box_zoom,reset,resize”,
title=title,
title_text_font_size=“10pt”,
plot_width=600, plot_height=300,)
script,div = components(plot, CDN)

then deliver XML(script) into a web2py template.

I’m not using the server, the html template includes these lines:

It works, but is slow in Firefox and IE. In Chrome it is fast.
In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
In Chrome the same operation takes 1 (one) second.

What am I doing wrong?

I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.
len(script) is 160794.

···

On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:

I’m rendering a 4000 point spectrum using bokeh.

plot = line(x, y,
color=“#0000FF”,
tools=“pan,wheel_zoom,box_zoom,reset,resize”,
title=title,
title_text_font_size=“10pt”,
plot_width=600, plot_height=300,)
script,div = components(plot, CDN)

then deliver XML(script) into a web2py template.

I’m not using the server, the html template includes these lines:

It works, but is slow in Firefox and IE. In Chrome it is fast.
In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
In Chrome the same operation takes 1 (one) second.

What am I doing wrong?

Using MPLD3, the spectrum renders in Firefox in 3 seconds.

···

On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer wrote:

I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.
len(script) is 160794.

On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:

I’m rendering a 4000 point spectrum using bokeh.

plot = line(x, y,
color=“#0000FF”,
tools=“pan,wheel_zoom,box_zoom,reset,resize”,
title=title,
title_text_font_size=“10pt”,
plot_width=600, plot_height=300,)
script,div = components(plot, CDN)

then deliver XML(script) into a web2py template.

I’m not using the server, the html template includes these lines:

It works, but is slow in Firefox and IE. In Chrome it is fast.
In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
In Chrome the same operation takes 1 (one) second.

What am I doing wrong?

Hi,

I've pushed the color_scatter.py example up to tens of thousands of points and it is has never taken anywhere near that long. Can you provide a complete minimal example to reproduce the problem, along with more information about platform, browser versions, etc? If you are familiar with browser development tools, a screenshot of the profiler of the affected browsers after running your code would also be very useful.

Than

···

On Sep 22, 2014, at 12:57 PM, HR Gartenbauer <[email protected]> wrote:

Using MPLD3, the spectrum renders in Firefox in 3 seconds.

On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer wrote:
I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.
len(script) is 160794.

On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:

I'm rendering a 4000 point spectrum using bokeh.

  plot = line(x, y,
      color="#0000FF",
      tools="pan,wheel_zoom,box_zoom,reset,resize",
      title=title,
      title_text_font_size="10pt",
      plot_width=600, plot_height=300,)
  script,div = components(plot, CDN)
  # then deliver XML(script) into a web2py template.

I'm not using the server, the html template includes these lines:
<script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>
<link rel="stylesheet" href="{{=URL('static','css/bokeh-0.6.0.min.css')}}" type="text/css" />

It works, but is slow in Firefox and IE. In Chrome it is fast.
In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
In Chrome the same operation takes 1 (one) second.

What am I doing wrong?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/db889510-65f8-42a0-af8c-aabc5580d4a5%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Right, I know I’m doing something wrong.
I’ve attached a screenshot of the Firefox profile.
Does anything jump out at you>
Thanks for your help.

···

On Monday, September 22, 2014 1:19:32 PM UTC-5, Bryan Van de ven wrote:

Hi,

I’ve pushed the color_scatter.py example up to tens of thousands of points and it is has never taken anywhere near that long. Can you provide a complete minimal example to reproduce the problem, along with more information about platform, browser versions, etc? If you are familiar with browser development tools, a screenshot of the profiler of the affected browsers after running your code would also be very useful.

Than

On Sep 22, 2014, at 12:57 PM, HR Gartenbauer [email protected] wrote:

Using MPLD3, the spectrum renders in Firefox in 3 seconds.

On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer wrote:

I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.

len(script) is 160794.

On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:

I’m rendering a 4000 point spectrum using bokeh.

plot = line(x, y,
color=“#0000FF”,
tools=“pan,wheel_zoom,box_zoom,reset,resize”,
title=title,

  title_text_font_size="10pt",
  plot_width=600, plot_height=300,)

script,div = components(plot, CDN)

then deliver XML(script) into a web2py template.

I’m not using the server, the html template includes these lines:

It works, but is slow in Firefox and IE. In Chrome it is fast.

In Firefox it is 25 seconds to generate the plot, with a similar time in IE.

In Chrome the same operation takes 1 (one) second.

What am I doing wrong?


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/db889510-65f8-42a0-af8c-aabc5580d4a5%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I'm not sure you're doing anything wrong, you may have uncovered some bug that is only triggered under certain circumstances. Nothing that profile jumps out at me, unfortunately. If you are up for checking a few more things, here are some information points that would be useful:

* does the problem happen with output_file/show instead of components?
* does the problem happen with an equally sized batch of random data?

Bryan

···

On Sep 22, 2014, at 1:49 PM, HR Gartenbauer <[email protected]> wrote:

Right, I know I'm doing something wrong.
I've attached a screenshot of the Firefox profile.
Does anything jump out at you>
Thanks for your help.

On Monday, September 22, 2014 1:19:32 PM UTC-5, Bryan Van de ven wrote:
Hi,

I've pushed the color_scatter.py example up to tens of thousands of points and it is has never taken anywhere near that long. Can you provide a complete minimal example to reproduce the problem, along with more information about platform, browser versions, etc? If you are familiar with browser development tools, a screenshot of the profiler of the affected browsers after running your code would also be very useful.

Than

On Sep 22, 2014, at 12:57 PM, HR Gartenbauer <[email protected]> wrote:

>
> Using MPLD3, the spectrum renders in Firefox in 3 seconds.
>
> On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer wrote:
> I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.
> len(script) is 160794.
>
>
> On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:
>
> I'm rendering a 4000 point spectrum using bokeh.
>
> plot = line(x, y,
> color="#0000FF",
> tools="pan,wheel_zoom,box_zoom,reset,resize",
> title=title,
> title_text_font_size="10pt",
> plot_width=600, plot_height=300,)
> script,div = components(plot, CDN)
> # then deliver XML(script) into a web2py template.
>
> I'm not using the server, the html template includes these lines:
> <script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>
> <link rel="stylesheet" href="{{=URL('static','css/bokeh-0.6.0.min.css')}}" type="text/css" />
>
> It works, but is slow in Firefox and IE. In Chrome it is fast.
> In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
> In Chrome the same operation takes 1 (one) second.
>
> What am I doing wrong?
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/db889510-65f8-42a0-af8c-aabc5580d4a5%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0ba73cd9-9ecb-4d14-aa29-2e71e0ecb356%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
<bokey_Profile.jpg>

In building a minimal example, I learned that the slowness has nothing to do with rendering the embedded plot.

A bare-bones web2py template, named bokeh_test.html:

{{extend ‘layout.html’}}

{{=form}}

and the corresponding web2py controller (note that it does nothing when the plot button is clicked, I have not yet added the code to generate the bokeh plot):

def bokeh_test():
from gluon.sqlhtml import form_factory
from exceptions import Exception
form=form_factory( submit_button=T(‘Plot’),)
d = {}
d[‘form’]=form
if form.accepts(request.vars,session):
try:
pass
except Exception as e:
response.flash = str(e)
elif form.errors:
response.flash = ‘form has errors’
return d

Just the initial load of this page takes 25 seconds in Firefox and IE.

The page is loaded instantaneously if this line is taken out:

It is just as slow if I change it to:

If I create a minimal html page, upload it to the internet and launch it from there, it loads instantly:

Bokeh js Load

Hello Bokeh

Does this new information provide a clue?

···

On Monday, September 22, 2014 1:55:12 PM UTC-5, Bryan Van de ven wrote:

I’m not sure you’re doing anything wrong, you may have uncovered some bug that is only triggered under certain circumstances. Nothing that profile jumps out at me, unfortunately. If you are up for checking a few more things, here are some information points that would be useful:

  • does the problem happen with output_file/show instead of components?

  • does the problem happen with an equally sized batch of random data?

Bryan

On Sep 22, 2014, at 1:49 PM, HR Gartenbauer [email protected] wrote:

Right, I know I’m doing something wrong.

I’ve attached a screenshot of the Firefox profile.
Does anything jump out at you>

Thanks for your help.

On Monday, September 22, 2014 1:19:32 PM UTC-5, Bryan Van de ven wrote:

Hi,

I’ve pushed the color_scatter.py example up to tens of thousands of points and it is has never taken anywhere near that long. Can you provide a complete minimal example to reproduce the problem, along with more information about platform, browser versions, etc? If you are familiar with browser development tools, a screenshot of the profiler of the affected browsers after running your code would also be very useful.

Than

On Sep 22, 2014, at 12:57 PM, HR Gartenbauer [email protected] wrote:

Using MPLD3, the spectrum renders in Firefox in 3 seconds.

On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer wrote:
I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.
len(script) is 160794.

On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:

I’m rendering a 4000 point spectrum using bokeh.

plot = line(x, y,
color=“#0000FF”,
tools=“pan,wheel_zoom,box_zoom,reset,resize”,
title=title,
title_text_font_size=“10pt”,
plot_width=600, plot_height=300,)
script,div = components(plot, CDN)

then deliver XML(script) into a web2py template.

I’m not using the server, the html template includes these lines:

It works, but is slow in Firefox and IE. In Chrome it is fast.
In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
In Chrome the same operation takes 1 (one) second.

What am I doing wrong?


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/db889510-65f8-42a0-af8c-aabc5580d4a5%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0ba73cd9-9ecb-4d14-aa29-2e71e0ecb356%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

<bokey_Profile.jpg>

Hi HR,

I’m no expert in web2py nor the internal machinations of Bokeh, but at a cursory glance based on your problem definition I would say that the issue probably lies in how web2py maps URL paths for your application/controller and/or static files:

http://web2py.com/books/default/chapter/29/04/the-core#URL

Especially:

<<<

For the reasons mentioned above, you should always use the URL function to generate URLs of static files for your applications. Static files are stored in the application’s static subfolder (that’s where they go when uploaded using the administrative interface). web2py provides a virtual ‘static’ controller whose job is to retrieve files from the static subfolder, determine their content-type, and stream the file to the client. The following example generates the URL for the static file “image.png”:

I have encountered problems with static files related to using Bokeh with Flask, and it ended up being how I had Flask static file directories configured in my application. Note that Bokeh has it’s own idea about static file directories, which you MUST tell it about when using a container framework like Flask or web2py. The only reason I can think of something rendering x10 faster on Chrome is maybe you have something in the cache already from a previous test?

Hope that helps, and good luck!

  • Rob
···

On Sep 22, 2014, at 12:43 PM, HR Gartenbauer [email protected] wrote:

In building a minimal example, I learned that the slowness has nothing to do with rendering the embedded plot.

A bare-bones web2py template, named bokeh_test.html:

{{extend ‘layout.html’}}

{{=form}}

and the corresponding web2py controller (note that it does nothing when the plot button is clicked, I have not yet added the code to generate the bokeh plot):

def bokeh_test():
from gluon.sqlhtml import form_factory
from exceptions import Exception
form=form_factory( submit_button=T(‘Plot’),)
d = {}
d[‘form’]=form
if form.accepts(request.vars,session):
try:
pass
except Exception as e:
response.flash = str(e)
elif form.errors:
response.flash = ‘form has errors’
return d

Just the initial load of this page takes 25 seconds in Firefox and IE.

The page is loaded instantaneously if this line is taken out:

It is just as slow if I change it to:

If I create a minimal html page, upload it to the internet and launch it from there, it loads instantly:

Bokeh js Load

Hello Bokeh

Does this new information provide a clue?

On Monday, September 22, 2014 1:55:12 PM UTC-5, Bryan Van de ven wrote:

I’m not sure you’re doing anything wrong, you may have uncovered some bug that is only triggered under certain circumstances. Nothing that profile jumps out at me, unfortunately. If you are up for checking a few more things, here are some information points that would be useful:

  • does the problem happen with output_file/show instead of components?

  • does the problem happen with an equally sized batch of random data?

Bryan

On Sep 22, 2014, at 1:49 PM, HR Gartenbauer [email protected] wrote:

Right, I know I’m doing something wrong.

I’ve attached a screenshot of the Firefox profile.
Does anything jump out at you>

Thanks for your help.

On Monday, September 22, 2014 1:19:32 PM UTC-5, Bryan Van de ven wrote:

Hi,

I’ve pushed the color_scatter.py example up to tens of thousands of points and it is has never taken anywhere near that long. Can you provide a complete minimal example to reproduce the problem, along with more information about platform, browser versions, etc? If you are familiar with browser development tools, a screenshot of the profiler of the affected browsers after running your code would also be very useful.

Than

On Sep 22, 2014, at 12:57 PM, HR Gartenbauer [email protected] wrote:

Using MPLD3, the spectrum renders in Firefox in 3 seconds.

On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer wrote:
I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.
len(script) is 160794.

On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:

I’m rendering a 4000 point spectrum using bokeh.

plot = line(x, y,
color=“#0000FF”,
tools=“pan,wheel_zoom,box_zoom,reset,resize”,
title=title,
title_text_font_size=“10pt”,
plot_width=600, plot_height=300,)
script,div = components(plot, CDN)

then deliver XML(script) into a web2py template.

I’m not using the server, the html template includes these lines:

It works, but is slow in Firefox and IE. In Chrome it is fast.
In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
In Chrome the same operation takes 1 (one) second.

What am I doing wrong?

As an aside, Robert if you have an ideas or input about how to improve integration with frameworks like this, I would very such like to hear them! We've done a fairly simple thing from our perspective but I scan believe there are things that might be simpler for users.

Thanks,

Bryan

···

On Sep 22, 2014, at 7:48 PM, robertlnewman <[email protected]> wrote:

I have encountered problems with static files related to using Bokeh with Flask, and it ended up being how I had Flask static file directories configured in my application. Note that Bokeh has it's own idea about static file directories, which you MUST tell it about when using a container framework like Flask or web2py. The only reason I can think of something rendering x10 faster on Chrome is maybe you have something in the cache already from a previous test?

I'm having a similar issue when using Firefox too. Here is a snippet of code:

  figure(tools = 'box_zoom,pan,previewsave,reset,select,wheel_zoom')

  plot = line(times, values, legend=title)

  script, div = components(plot, CDN)

I am using django as the web framework and I don't know exactly the
size of the times and values list, but they are probably huge
(~hundreds of thousands)

The plot is renderer correctly in Chrome and hangs in Firefox.

Best regards,

···

2014-09-23 3:04 GMT+02:00 Bryan Van de Ven <[email protected]>:

On Sep 22, 2014, at 7:48 PM, robertlnewman <[email protected]> wrote:

I have encountered problems with static files related to using Bokeh with Flask, and it ended up being how I had Flask static file directories configured in my application. Note that Bokeh has it's own idea about static file directories, which you MUST tell it about when using a container framework like Flask or web2py. The only reason I can think of something rendering x10 faster on Chrome is maybe you have something in the cache already from a previous test?

As an aside, Robert if you have an ideas or input about how to improve integration with frameworks like this, I would very such like to hear them! We've done a fairly simple thing from our perspective but I scan believe there are things that might be simpler for users.

Thanks,

Bryan

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CE9F4A40-D0D2-477F-919B-686F4AFEFB75%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

If you are in the realm of hundreds of thousands of points, it's probably worth a look into doing server side downsampling or abstract rendering. Assuming you are scattering circles, say, with a non-zero radius, hundreds of thousands of points quickly translates into millions of pixels (i.e., all of your pixels).

That said, it seems like maybe there is some issue with loading bokeh.js that has nothing to with the size of the data. I would definitely like to understand this better, if only to be able to give proper guidance/best practices for embedding.

Unfortuantely, I am not very familiar with django or web2py, if it is possible to make minimal complete examples in a GH repo or gist that would go a long way towards investigating it.

Bryan

···

On Sep 23, 2014, at 2:45 AM, Iñigo Martínez <[email protected]> wrote:

I'm having a similar issue when using Firefox too. Here is a snippet of code:

figure(tools = 'box_zoom,pan,previewsave,reset,select,wheel_zoom')

plot = line(times, values, legend=title)

script, div = components(plot, CDN)

I am using django as the web framework and I don't know exactly the
size of the times and values list, but they are probably huge
(~hundreds of thousands)

The plot is renderer correctly in Chrome and hangs in Firefox.

Best regards,

2014-09-23 3:04 GMT+02:00 Bryan Van de Ven <[email protected]>:

On Sep 22, 2014, at 7:48 PM, robertlnewman <[email protected]> wrote:

I have encountered problems with static files related to using Bokeh with Flask, and it ended up being how I had Flask static file directories configured in my application. Note that Bokeh has it's own idea about static file directories, which you MUST tell it about when using a container framework like Flask or web2py. The only reason I can think of something rendering x10 faster on Chrome is maybe you have something in the cache already from a previous test?

As an aside, Robert if you have an ideas or input about how to improve integration with frameworks like this, I would very such like to hear them! We've done a fairly simple thing from our perspective but I scan believe there are things that might be simpler for users.

Thanks,

Bryan

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CE9F4A40-D0D2-477F-919B-686F4AFEFB75%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAKub0h71SXFbbkbPx4PNx06b9vFaHpkr8P0VmgsZwnSbsufgZA%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Iñigo,

Is there any reason why you need to plot that many points? Your browser window is only so many pixels wide..... :slight_smile:

I totally agree with Bryan - unless there is a very very strong reason not to (i.e. it's fundamental to what you want your plot to show), you should downsample your data or do abstract rendering. The Pandas module (http://pandas.pydata.org/\) is excellent for data munging, and highly recommended for applications like this. I use it for binning 100,000s of data points from a Postgres DB (via SQLAlchemy and Flask) into something manageable so the Bokeh plots render much much faster. Pandas is quite mature now, with good docs and lots of online examples.

I hope that helps and good luck!
- Rob

···

On Sep 23, 2014, at 5:29 AM, Bryan Van de Ven <[email protected]> wrote:

If you are in the realm of hundreds of thousands of points, it's probably worth a look into doing server side downsampling or abstract rendering. Assuming you are scattering circles, say, with a non-zero radius, hundreds of thousands of points quickly translates into millions of pixels (i.e., all of your pixels).

That said, it seems like maybe there is some issue with loading bokeh.js that has nothing to with the size of the data. I would definitely like to understand this better, if only to be able to give proper guidance/best practices for embedding.

Unfortuantely, I am not very familiar with django or web2py, if it is possible to make minimal complete examples in a GH repo or gist that would go a long way towards investigating it.

Bryan

On Sep 23, 2014, at 2:45 AM, Iñigo Martínez <[email protected]> wrote:

I'm having a similar issue when using Firefox too. Here is a snippet of code:

figure(tools = 'box_zoom,pan,previewsave,reset,select,wheel_zoom')

plot = line(times, values, legend=title)

script, div = components(plot, CDN)

I am using django as the web framework and I don't know exactly the
size of the times and values list, but they are probably huge
(~hundreds of thousands)

The plot is renderer correctly in Chrome and hangs in Firefox.

Best regards,

2014-09-23 3:04 GMT+02:00 Bryan Van de Ven <[email protected]>:

On Sep 22, 2014, at 7:48 PM, robertlnewman <[email protected]> wrote:

I have encountered problems with static files related to using Bokeh with Flask, and it ended up being how I had Flask static file directories configured in my application. Note that Bokeh has it's own idea about static file directories, which you MUST tell it about when using a container framework like Flask or web2py. The only reason I can think of something rendering x10 faster on Chrome is maybe you have something in the cache already from a previous test?

As an aside, Robert if you have an ideas or input about how to improve integration with frameworks like this, I would very such like to hear them! We've done a fairly simple thing from our perspective but I scan believe there are things that might be simpler for users.

Thanks,

Bryan

Hi Bryan,

I use Django and Flask extensively, but I wouldn't consider myself an expert in how to integrate either of these two with Bokeh. As an educated guess, and using Django (which I am much more familiar with), I would find a way to add the Bokeh plot vars to the Django Context* (or RequestContext**, which is a subclass of Context) object, and make these automagically available in the Django Template*** object. Probably writing some middleware**** (django-bokeh anyone?!?)

James Bennett (a Django code contributor) has a old, but useful, blog post on this:
http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/

If I had more time available (yeah, right!) I would love to help you with this, but right now I am buried in multiple dev projects, much like you all I am sure....

We can take this discussion further offline if you wish - just holler - and I can try to carve out some time to work on this project.

Thanks!
- Rob

* https://docs.djangoproject.com/en/1.7/ref/templates/api/#django.template.Context
** https://docs.djangoproject.com/en/1.7/ref/templates/api/#django.template.RequestContext
*** https://docs.djangoproject.com/en/1.7/ref/templates/api/#django.template.Template
**** Middleware | Django documentation | Django

···

On Sep 22, 2014, at 6:04 PM, Bryan Van de Ven <[email protected]> wrote:

On Sep 22, 2014, at 7:48 PM, robertlnewman <[email protected]> wrote:

I have encountered problems with static files related to using Bokeh with Flask, and it ended up being how I had Flask static file directories configured in my application. Note that Bokeh has it's own idea about static file directories, which you MUST tell it about when using a container framework like Flask or web2py. The only reason I can think of something rendering x10 faster on Chrome is maybe you have something in the cache already from a previous test?

As an aside, Robert if you have an ideas or input about how to improve integration with frameworks like this, I would very such like to hear them! We've done a fairly simple thing from our perspective but I scan believe there are things that might be simpler for users.

Thanks,

Bryan

Rob,

I’m not an expert either.

I am using the web2py URL function, as listed in an earlier post:

Wouldn’t the fact that it is fast on Chrome indicate that the problem isn’t due to web2py or its routing?

You wrote:

“”"

Bokeh has it’s own idea about static file directories, which you MUST tell it about when using a container framework

“”"

how do I tell bokeh about static file directories?

Thanks,

HR

···

On Monday, September 22, 2014 6:48:41 PM UTC-5, Rob Newman wrote:

Hi HR,

I’m no expert in web2py nor the internal machinations of Bokeh, but at a cursory glance based on your problem definition I would say that the issue probably lies in how web2py maps URL paths for your application/controller and/or static files:

http://web2py.com/books/default/chapter/29/04/the-core#URL

Especially:

<<<

For the reasons mentioned above, you should always use the URL function to generate URLs of static files for your applications. Static files are stored in the application’s static subfolder (that’s where they go when uploaded using the administrative interface). web2py provides a virtual ‘static’ controller whose job is to retrieve files from the static subfolder, determine their content-type, and stream the file to the client. The following example generates the URL for the static file “image.png”:

I have encountered problems with static files related to using Bokeh with Flask, and it ended up being how I had Flask static file directories configured in my application. Note that Bokeh has it’s own idea about static file directories, which you MUST tell it about when using a container framework like Flask or web2py. The only reason I can think of something rendering x10 faster on Chrome is maybe you have something in the cache already from a previous test?

Hope that helps, and good luck!

  • Rob

On Sep 22, 2014, at 12:43 PM, HR Gartenbauer [email protected] wrote:

I’m not sure you’re doing anything wrong, you may have uncovered some bug that is only triggered under certain circumstances. Nothing that profile jumps out at me, unfortunately. If you are up for checking a few more things, here are some information points that would be useful:

  • does the problem happen with output_file/show instead of components?

  • does the problem happen with an equally sized batch of random data?

Bryan

On Sep 22, 2014, at 1:49 PM, HR Gartenbauer [email protected] wrote:

Right, I know I’m doing something wrong.

I’ve attached a screenshot of the Firefox profile.
Does anything jump out at you>

Thanks for your help.

On Monday, September 22, 2014 1:19:32 PM UTC-5, Bryan Van de ven wrote:

Hi,

I’ve pushed the color_scatter.py example up to tens of thousands of points and it is has never taken anywhere near that long. Can you provide a complete minimal example to reproduce the problem, along with more information about platform, browser versions, etc? If you are familiar with browser development tools, a screenshot of the profiler of the affected browsers after running your code would also be very useful.

Than

On Sep 22, 2014, at 12:57 PM, HR Gartenbauer [email protected] wrote:

Using MPLD3, the spectrum renders in Firefox in 3 seconds.

On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer wrote:
I should add that it is not the call to line() that is slow, it is the rendering of the plot in the browser that is slow.
len(script) is 160794.

On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer wrote:

I’m rendering a 4000 point spectrum using bokeh.

plot = line(x, y,
color=“#0000FF”,
tools=“pan,wheel_zoom,box_zoom,reset,resize”,
title=title,
title_text_font_size=“10pt”,
plot_width=600, plot_height=300,)
script,div = components(plot, CDN)

then deliver XML(script) into a web2py template.

I’m not using the server, the html template includes these lines:

It works, but is slow in Firefox and IE. In Chrome it is fast.
In Firefox it is 25 seconds to generate the plot, with a similar time in IE.
In Chrome the same operation takes 1 (one) second.

What am I doing wrong?
In building a minimal example, I learned that the slowness has nothing to do with rendering the embedded plot.

A bare-bones web2py template, named bokeh_test.html:

{{extend ‘layout.html’}}

{{=form}}

and the corresponding web2py controller (note that it does nothing when the plot button is clicked, I have not yet added the code to generate the bokeh plot):

def bokeh_test():
from gluon.sqlhtml import form_factory
from exceptions import Exception
form=form_factory( submit_button=T(‘Plot’),)
d = {}
d[‘form’]=form
if form.accepts(request.vars,session):
try:
pass
except Exception as e:
response.flash = str(e)
elif form.errors:
response.flash = ‘form has errors’
return d

Just the initial load of this page takes 25 seconds in Firefox and IE.

The page is loaded instantaneously if this line is taken out:

It is just as slow if I change it to:

If I create a minimal html page, upload it to the internet and launch it from there, it loads instantly:

Bokeh js Load

Hello Bokeh

Does this new information provide a clue?

On Monday, September 22, 2014 1:55:12 PM UTC-5, Bryan Van de ven wrote:

Yes, I was thinking on downsampling the signal, but at the moment, as
the first tests I was drawing raw data. I was looking at scipy
decimate.

I will give it another try.

Thank you :slight_smile:

···

2014-09-24 4:22 GMT+02:00 HR Gartenbauer <[email protected]>:

Rob,

I'm not an expert either.
I am using the web2py URL function, as listed in an earlier post:

<link rel="stylesheet" href="{{=URL('static','css/bokeh-0.6.0.min.css')}}"
type="text/css" />
<script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>

Wouldn't the fact that it is fast on Chrome indicate that the problem isn't
due to web2py or its routing?

You wrote:
"""
Bokeh has it's own idea about static file directories, which you MUST tell
it about when using a container framework
"""
how do I tell bokeh about static file directories?

Thanks,
HR

On Monday, September 22, 2014 6:48:41 PM UTC-5, Rob Newman wrote:

Hi HR,

I'm no expert in web2py nor the internal machinations of Bokeh, but at a
cursory glance based on your problem definition I would say that the issue
probably lies in how web2py maps URL paths for your application/controller
and/or static files:

web2py - The core

Especially:

<<<
For the reasons mentioned above, you should always use the URL function to
generate URLs of static files for your applications. Static files are stored
in the application's static subfolder (that's where they go when uploaded
using the administrative interface). web2py provides a virtual 'static'
controller whose job is to retrieve files from the static subfolder,
determine their content-type, and stream the file to the client. The
following example generates the URL for the static file "image.png":
>>>

I have encountered problems with static files related to using Bokeh with
Flask, and it ended up being how I had Flask static file directories
configured in my application. Note that Bokeh has it's own idea about static
file directories, which you MUST tell it about when using a container
framework like Flask or web2py. The only reason I can think of something
rendering x10 faster on Chrome is maybe you have something in the cache
already from a previous test?

Hope that helps, and good luck!
- Rob

On Sep 22, 2014, at 12:43 PM, HR Gartenbauer <[email protected]> wrote:

In building a minimal example, I learned that the slowness has nothing to
do with rendering the embedded plot.

A bare-bones web2py template, named bokeh_test.html:

{{extend 'layout.html'}}
<link rel="stylesheet" href="{{=URL('static','css/bokeh-0.6.0.min.css')}}"
type="text/css" />
<script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>
{{=form}}

and the corresponding web2py controller (note that it does nothing when
the plot button is clicked, I have not yet added the code to generate the
bokeh plot):

def bokeh_test():
    from gluon.sqlhtml import form_factory
    from exceptions import Exception
    form=form_factory( submit_button=T('Plot'),)
    d = {}
    d['form']=form
    if form.accepts(request.vars,session):
        try:
          pass
        except Exception as e:
          response.flash = str(e)
    elif form.errors:
      response.flash = 'form has errors'
    return d

Just the initial load of this page takes 25 seconds in Firefox and IE.

The page is loaded instantaneously if this line is taken out:
<script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>

It is just as slow if I change it to:
<script type="text/javascript"
src="http://cdn.pydata.org/bokeh-0.6.0.min.js&quot;&gt;&lt;/script&gt;

If I create a minimal html page, upload it to the internet and launch it
from there, it loads instantly:

  <html>
  <head>
  <title>Bokeh js Load</title>
  <link rel="stylesheet" href="http://cdn.pydata.org/bokeh-0.6.0.min.css&quot;
type="text/css" />
  <script type="text/javascript"
src="http://cdn.pydata.org/bokeh-0.6.0.min.js&quot;&gt;&lt;/script&gt;
  <body>
  <p>
  Hello Bokeh
  </p>
  </body>
  </html>

Does this new information provide a clue?

On Monday, September 22, 2014 1:55:12 PM UTC-5, Bryan Van de ven wrote:

I'm not sure you're doing anything wrong, you may have uncovered some bug
that is only triggered under certain circumstances. Nothing that profile
jumps out at me, unfortunately. If you are up for checking a few more
things, here are some information points that would be useful:

* does the problem happen with output_file/show instead of components?
* does the problem happen with an equally sized batch of random data?

Bryan

On Sep 22, 2014, at 1:49 PM, HR Gartenbauer <[email protected]> wrote:

>
> Right, I know I'm doing something wrong.
> I've attached a screenshot of the Firefox profile.
> Does anything jump out at you>
> Thanks for your help.
>
>
> On Monday, September 22, 2014 1:19:32 PM UTC-5, Bryan Van de ven wrote:
> Hi,
>
> I've pushed the color_scatter.py example up to tens of thousands of
> points and it is has never taken anywhere near that long. Can you provide a
> complete minimal example to reproduce the problem, along with more
> information about platform, browser versions, etc? If you are familiar with
> browser development tools, a screenshot of the profiler of the affected
> browsers after running your code would also be very useful.
>
> Than
>
> On Sep 22, 2014, at 12:57 PM, HR Gartenbauer <[email protected]> >>> > wrote:
>
> >
> > Using MPLD3, the spectrum renders in Firefox in 3 seconds.
> >
> > On Monday, September 22, 2014 12:44:44 PM UTC-5, HR Gartenbauer >>> > > wrote:
> > I should add that it is not the call to line() that is slow, it is
> > the rendering of the plot in the browser that is slow.
> > len(script) is 160794.
> >
> >
> > On Monday, September 22, 2014 12:37:46 PM UTC-5, HR Gartenbauer >>> > > wrote:
> >
> > I'm rendering a 4000 point spectrum using bokeh.
> >
> > plot = line(x, y,
> > color="#0000FF",
> > tools="pan,wheel_zoom,box_zoom,reset,resize",
> > title=title,
> > title_text_font_size="10pt",
> > plot_width=600, plot_height=300,)
> > script,div = components(plot, CDN)
> > # then deliver XML(script) into a web2py template.
> >
> > I'm not using the server, the html template includes these lines:
> > <script src="{{=URL('static','js/bokeh-0.6.0.min.js')}}"></script>
> > <link rel="stylesheet"
> > href="{{=URL('static','css/bokeh-0.6.0.min.css')}}" type="text/css" />
> >
> > It works, but is slow in Firefox and IE. In Chrome it is fast.
> > In Firefox it is 25 seconds to generate the plot, with a similar time
> > in IE.
> > In Chrome the same operation takes 1 (one) second.
> >
> > What am I doing wrong?

--
You received this message because you are subscribed to the Google Groups
"Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/9f7a3cce-9b6e-4a9d-ba80-432033e19a58%40continuum.io\.

For more options, visit https://groups.google.com/a/continuum.io/d/optout\.