Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unexpectedly high cpu/gpu use #520

Copy link
Copy link
Open
@n-garc

Description

@n-garc
Issue body actions

Was playing around with your subplots example the other day to get a feel for the library (am very excited about reducing my matplotlib render times), and I ran into an unexpected issue. While the figure was active, and without any mouse or keyboard input, one of my cpu cores was fully loaded, and gpu use was around ~30%. Did a little digging, and over a ~25 second profiling run, it seems like fastplotlib/layouts/_plot_area.py:363(render) is calling the pygfx viewport render function almost 40,000 times. Is this expected/desired behavior? Based on my limited understanding of the current codebase, there is a render loop, which I assume is constantly redrawing the figure. This cpu/gpu use seems problematic to me, especially if the figure isn't being interacted with most of the time. I do not observe this behavior if I use snapshot().

My code, run in jupyterlab (using version 0.2.0):

names = [['subplot']*8]*16
figure_grid = fpl.Figure(shape=(16,8), size=(1000,2000), names=names)
for subplot in figure_grid:
    data = np.random.rand(512, 512)
    subplot.add_image(data, name="rand-img")

pr = cProfile.Profile()
pr.enable()
figure_grid.show()
## wait ~25 seconds before running the next block
pr.disable()
pr.create_stats()
pr.print_stats(sort='tottime')

Top 10 calls by tottime

Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
  1029298    4.403    0.000    5.023    0.000 _helpers.py:304(proxy_func)
      409    2.081    0.005    2.081    0.005 {method 'poll' of 'select.epoll' objects}
 20191744    1.979    0.000    2.226    0.000 _weakrefset.py:63(__iter__)
   526029    1.260    0.000    2.323    0.000 _api.py:101(_new_struct_p)
    39168    1.100    0.000    3.220    0.000 environment.py:402(check_inactive)
    39168    0.745    0.000    1.567    0.000 matrix.py:452(mat_orthographic)
   203812    0.734    0.000    0.734    0.000 {built-in method builtins.dir}
   201508    0.634    0.000    1.054    0.000 structs.py:18(<listcomp>)
    78489    0.628    0.000    5.812    0.000 _api.py:2202(begin_render_pass)
    39168    0.521    0.000   23.825    0.001 renderer.py:392(render)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.