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

Speed up Pane.clone with 50% #5848

Merged
merged 7 commits into from
Nov 15, 2023
Merged

Conversation

MarcSkovMadsen
Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen commented Nov 11, 2023

Pane.clone did the same look up three times which was costly.

This changes to one lookup and also makes the code more readable.

Measurement 1

Running pytest on below code shows ~3% speed up consistently.

import panel as pn
item = pn.pane.Markdown("Hello World")

def test_html_clone():
    for i in range(20000):
        item.clone()

The reason why I found this is that I can see in apps .clone loops over self.param.values().items(). And loops over self.param.values().items() takes up +5% of the time of loading apps in my tests. My hypothesis is that that one could be improved significantly.

Copy link

codecov bot commented Nov 11, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (4bfe371) 84.02% compared to head (dac33af) 84.03%.
Report is 3 commits behind head on main.

Files Patch % Lines
panel/util/parameters.py 92.53% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5848      +/-   ##
==========================================
+ Coverage   84.02%   84.03%   +0.01%     
==========================================
  Files         290      291       +1     
  Lines       42420    42479      +59     
==========================================
+ Hits        35643    35698      +55     
- Misses       6777     6781       +4     
Flag Coverage Δ
ui-tests 40.87% <45.34%> (-0.02%) ⬇️
unitexamples-tests 72.43% <93.02%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ahuang11
Copy link
Contributor

Wow super excited for all the speed gains you're discovering!

@philippjfr
Copy link
Member

I've done this a few times now so most low hanging fruit are likely gone but after param 2.0 some performance characteristics have likely changed. We should really add a basic asv based performance profiling suite, even if it only covers a small number of test cases initially.

panel/viewable.py Outdated Show resolved Hide resolved
@philippjfr philippjfr force-pushed the enhancement/speed-up-pane-clone branch from 109eacf to f6e03c8 Compare November 15, 2023 12:13
@philippjfr philippjfr merged commit dc62eb7 into main Nov 15, 2023
11 of 13 checks passed
@philippjfr philippjfr deleted the enhancement/speed-up-pane-clone branch November 15, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants