Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More than 10x slowdown with 1.0.0rc0. #231

Open
s-banach opened this issue Nov 27, 2024 · 5 comments
Open

More than 10x slowdown with 1.0.0rc0. #231

s-banach opened this issue Nov 27, 2024 · 5 comments
Assignees
Labels
active use-support Support related to usage

Comments

@s-banach
Copy link

Simple test script:

from time import perf_counter

import plotly.express as px

fig = px.scatter(x=[1, 2, 3], y=[1, 2, 3])

start = perf_counter()
for _ in range(10):
    fig.to_image(format="svg", engine="kaleido")
end = perf_counter()
print(f"{end - start:.02f}")

Time with 0.1.0.post1: 0.95 seconds
Time with 1.0.0rc0: 10.78 seconds

@s-banach
Copy link
Author

s-banach commented Nov 27, 2024

I'm assuming it does something like open a new copy of chrome for each image.
In that case, please include guidance on how to make a persistent instance of chrome to generate multiple images.
Even better, a pool of chrome instances that can be used to render a list of figures in parallel.

@ayjayt
Copy link
Collaborator

ayjayt commented Nov 28, 2024

Yeah, that's the issue. I want to upgrade the API soon and deprecate this one.

@s-banach, are you comfortable using asyncio for the speedup?

@ayjayt ayjayt self-assigned this Nov 28, 2024
@ayjayt ayjayt added use-support Support related to usage active labels Nov 28, 2024
@s-banach
Copy link
Author

Yes!

@ayjayt
Copy link
Collaborator

ayjayt commented Nov 28, 2024

Alright, give me an hour or two and I"ll write and test a quickstart- it should make its way in to the README as well....

@ayjayt
Copy link
Collaborator

ayjayt commented Nov 29, 2024

Hey, @s-banach, some news:

Basically the v1.0.0rc0 is the old API for backwards comparability with the new engine-> not great.
kaleido2 will be new api + new engine, I'm going to do it this weekend.

That said, I pushed a branch (https://github.com/plotly/Kaleido/tree/andrew/factor_for_faster) which allows you to run code like this:

  from choreographer import 
  import kaleido
  async with Browser() as browser:
    spec = scope.make_spec(fig, format="png") # serializes figure
    binary = await kaleido.to_image_w_browser(spec, browser)
    # something to write the binary to a file, async better

I used a blocking image write but still got 2.5X - it only uses one browser.

You can also wait for kaleido2 if you don't want to use a branch and this and it'll have a nice API, it's going to be a weekend sprint.

Sorry for the delay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
active use-support Support related to usage
Projects
None yet
Development

No branches or pull requests

2 participants