Title: Potential performance improvements? · Issue #1842 · plotly/plotly.py · GitHub
Open Graph Title: Potential performance improvements? · Issue #1842 · plotly/plotly.py
X Title: Potential performance improvements? · Issue #1842 · plotly/plotly.py
Description: I have profiled a simple heatmap here: profile_code.py from werkzeug.contrib.profiler import ProfilerMiddleware from app import server server.config['PROFILE'] = True server.wsgi_app = ProfilerMiddleware(server.wsgi_app, restrictions=[30...
Open Graph Description: I have profiled a simple heatmap here: profile_code.py from werkzeug.contrib.profiler import ProfilerMiddleware from app import server server.config['PROFILE'] = True server.wsgi_app = ProfilerMidd...
X Description: I have profiled a simple heatmap here: profile_code.py from werkzeug.contrib.profiler import ProfilerMiddleware from app import server server.config['PROFILE'] = True server.wsgi_app = Prof...
Opengraph URL: https://github.com/plotly/plotly.py/issues/1842
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Potential performance improvements?","articleBody":"I have profiled a simple heatmap here:\r\n\r\n**profile_code.py**\r\n```python\r\nfrom werkzeug.contrib.profiler import ProfilerMiddleware\r\nfrom app import server\r\n\r\nserver.config['PROFILE'] = True\r\nserver.wsgi_app = ProfilerMiddleware(server.wsgi_app, restrictions=[30])\r\nserver.run(debug = True)\r\n```\r\n\r\n**app.py**\r\n```python\r\nimport numpy as np\r\n\r\nimport dash\r\nimport dash_core_components as dcc\r\nimport dash_html_components as html\r\nimport plotly.graph_objects as go\r\n\r\nimport flask\r\n\r\n# Heatmap\r\nZ = np.random.rand(1000,1000)\r\n\r\nserver = flask.Flask(__name__)\r\napp = dash.Dash(__name__, server=server)\r\n\r\napp.layout = html.Div(children=[\r\n dcc.Graph(\r\n id='example-graph',\r\n figure=dict(\r\n\t\t\tdata=[go.Heatmap(\r\n\t\t\t\tz=Z\r\n\t\t\t)],\r\n\t\t\tlayout=dict()\r\n\t\t)\r\n )\r\n])\r\n```\r\n\r\nResult (Python 3.7 Windows):\r\n```\r\n 1068 function calls (1060 primitive calls) in 4.032 seconds\r\n\r\n Ordered by: cumulative time\r\n List reduced from 243 to 30 due to restriction \u003c30>\r\n\r\n ncalls tottime percall cumtime percall filename:lineno(function)\r\n 1 0.000 0.000 4.032 4.032 C:\\Python37-32\\lib\\site-packages\\werkzeug\\contrib\\profiler.py:95(runapp)\r\n 1 0.000 0.000 4.032 4.032 C:\\Python37-32\\lib\\site-packages\\flask\\app.py:2262(wsgi_app)\r\n 1 0.000 0.000 4.032 4.032 C:\\Python37-32\\lib\\site-packages\\flask\\app.py:1801(full_dispatch_request)\r\n 1 0.000 0.000 2.473 2.473 C:\\Python37-32\\lib\\site-packages\\flask\\app.py:1779(dispatch_request)\r\n 1 0.002 0.002 2.472 2.472 C:\\Python37-32\\lib\\site-packages\\dash\\dash.py:467(serve_layout)\r\n 2/1 0.013 0.006 2.462 2.462 C:\\Python37-32\\lib\\json\\__init__.py:183(dumps)\r\n 1 0.002 0.002 2.451 2.451 C:\\Python37-32\\lib\\site-packages\\_plotly_utils\\utils.py:35(encode)\r\n 2 0.000 0.000 1.995 0.998 C:\\Python37-32\\lib\\json\\encoder.py:182(encode)\r\n 2 1.856 0.928 1.980 0.990 C:\\Python37-32\\lib\\json\\encoder.py:204(iterencode)\r\n 1 0.000 0.000 1.559 1.559 C:\\Python37-32\\lib\\site-packages\\flask\\app.py:1818(finalize_request)\r\n 1 0.000 0.000 1.559 1.559 C:\\Python37-32\\lib\\site-packages\\flask\\app.py:2091(process_response)\r\n 1 0.000 0.000 1.559 1.559 C:\\Python37-32\\lib\\site-packages\\flask_compress.py:78(after_request)\r\n 1 0.000 0.000 1.557 1.557 C:\\Python37-32\\lib\\site-packages\\flask_compress.py:113(compress)\r\n 1 0.001 0.001 1.553 1.553 C:\\Python37-32\\lib\\gzip.py:247(write)\r\n 1 1.535 1.535 1.535 1.535 {method 'compress' of 'zlib.Compress' objects}\r\n 1 0.000 0.000 0.452 0.452 C:\\Python37-32\\lib\\json\\__init__.py:299(loads)\r\n 1 0.000 0.000 0.452 0.452 C:\\Python37-32\\lib\\json\\decoder.py:332(decode)\r\n 1 0.452 0.452 0.452 0.452 C:\\Python37-32\\lib\\json\\decoder.py:343(raw_decode)\r\n 4 0.000 0.000 0.124 0.031 C:\\Python37-32\\lib\\site-packages\\_plotly_utils\\utils.py:66(default)\r\n 1 0.000 0.000 0.093 0.093 C:\\Python37-32\\lib\\site-packages\\_plotly_utils\\utils.py:123(encode_as_list)\r\n 1 0.093 0.093 0.093 0.093 {method 'tolist' of 'numpy.ndarray' objects}\r\n 1 0.000 0.000 0.017 0.017 C:\\Python37-32\\lib\\site-packages\\_plotly_utils\\utils.py:131(encode_as_sage)\r\n 3 0.000 0.000 0.017 0.006 C:\\Python37-32\\lib\\site-packages\\_plotly_utils\\optional_imports.py:15(get_module)\r\n 1 0.000 0.000 0.016 0.016 C:\\Python37-32\\lib\\importlib\\__init__.py:109(import_module)\r\n 2/1 0.000 0.000 0.016 0.016 \u003cfrozen importlib._bootstrap>:994(_gcd_import)\r\n 2/1 0.000 0.000 0.016 0.016 \u003cfrozen importlib._bootstrap>:978(_find_and_load)\r\n 2/1 0.000 0.000 0.016 0.016 \u003cfrozen importlib._bootstrap>:948(_find_and_load_unlocked)\r\n 1 0.000 0.000 0.016 0.016 \u003cfrozen importlib._bootstrap>:211(_call_with_frames_removed)\r\n 1 0.000 0.000 0.016 0.016 \u003cfrozen importlib._bootstrap>:882(_find_spec)\r\n 1 0.000 0.000 0.016 0.016 \u003cfrozen importlib._bootstrap_external>:1272(find_spec)\r\n```\r\n\r\nResult with Phython 2.7 linux are almost identical\r\n\r\nLooking through the profiling it looks like the main causes is creating the JSON, with\r\n`C:\\Python37-32\\lib\\site-packages\\_plotly_utils\\utils.py` taking 2.45s out of a total of 4s.\r\nI know that orjson (only Python 3) can be faster than Python's default JSON. Would you expect that changing to orjson would improve performance / be possible to implement?\r\n\r\nThanks for any insight.","author":{"url":"https://github.com/pfbuxton","@type":"Person","name":"pfbuxton"},"datePublished":"2019-10-22T14:43:58Z","url":"https://github.com/plotly/plotly.py/issues/1842"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:08f6e083-1bed-61f6-e818-35ae37a4ac87 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF68:280A2E:4F0D9B:678756:6B017769 |
| html-safe-nonce | 03aad11af7def99771669af351b3bf24313e1fb1b63d327e81de22cc36f812d1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjY4OjI4MEEyRTo0RjBEOUI6Njc4NzU2OjZCMDE3NzY5IiwidmlzaXRvcl9pZCI6IjgzMTA3MjcwMjQ4MDk0NDExMjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2c5b4cf43d5af90190d8012ad85c36e733897146b9d155f8df0bf2452e2444f9 |
| hovercard-subject-tag | issue:510706165 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.py/1842/issue_layout |
| twitter:image | https://opengraph.githubassets.com/01b9d8dce746d24ceb9e08153c4cefe3d0f7dc668a3cce66fe892674f60672a9/plotly/plotly.py/issues/1842 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/01b9d8dce746d24ceb9e08153c4cefe3d0f7dc668a3cce66fe892674f60672a9/plotly/plotly.py/issues/1842 |
| og:image:alt | I have profiled a simple heatmap here: profile_code.py from werkzeug.contrib.profiler import ProfilerMiddleware from app import server server.config['PROFILE'] = True server.wsgi_app = ProfilerMidd... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pfbuxton |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579099 |
| octolytics-dimension-repository_nwo | plotly/plotly.py |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579099 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.py |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width