From 82e802e8dc7a2b18e1375f6a9e52e6ce9db689b0 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 18 Oct 2017 18:12:23 -0400 Subject: [PATCH 1/7] first pass at pruning the queue --- src/actions/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/actions/index.js b/src/actions/index.js index 510124e..e97a101 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -406,8 +406,18 @@ export function notifyObservers(payload) { thisRequestIndex, postRequestQueue ); + // We don't need to store any requests before this one + const requestUid = postRequestQueue[thisRequestIndex].uid; + const prunedQueue = updatedQueue.filter( + (queueItem, index) => { + return ( + queueItem.uid !== requestUid || + index >= thisRequestIndex + ); + } + ); - dispatch(setRequestQueue(updatedQueue)); + dispatch(setRequestQueue(prunedQueue)); } const isRejected = () => { @@ -415,6 +425,12 @@ export function notifyObservers(payload) { propEq('controllerId', newRequestQueue[i].controllerId), getState().requestQueue ); + /* + * Note that if the latest request is still `loading` + * or even if the latest request failed, + * we still reject this response in favor of waiting + * for the latest request to finish. + */ const rejected = latestRequestIndex > getThisRequestIndex(); return rejected; } From bafced2ccf50626e42f9fd099e046a211935d26f Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 18 Oct 2017 18:15:45 -0400 Subject: [PATCH 2/7] ignore requests that were already pruned --- src/actions/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/actions/index.js b/src/actions/index.js index e97a101..f035c42 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -397,6 +397,10 @@ export function notifyObservers(payload) { const updateRequestQueue = rejected => { const postRequestQueue = getState().requestQueue const thisRequestIndex = getThisRequestIndex(); + if (thisRequestIndex === -1) { + // It was already pruned away + return; + } const updatedQueue = adjust( merge(__, { status: res.status, From db6819595662a0d4f7829776e55bf3adf55f4887 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 18 Oct 2017 18:30:59 -0400 Subject: [PATCH 3/7] wrong queue comparison for pruning --- src/actions/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index f035c42..5f384c8 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -411,11 +411,12 @@ export function notifyObservers(payload) { postRequestQueue ); // We don't need to store any requests before this one - const requestUid = postRequestQueue[thisRequestIndex].uid; + const thisControllerId = postRequestQueue[ + thisRequestIndex].controllerId; const prunedQueue = updatedQueue.filter( (queueItem, index) => { return ( - queueItem.uid !== requestUid || + queueItem.controllerId !== thisControllerId || index >= thisRequestIndex ); } From 158e8cd174c57916ccbaa462669314b2815806c2 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 18 Oct 2017 18:33:33 -0400 Subject: [PATCH 4/7] 0.12.0rc1 --- dash_renderer/__init__.py | 3 ++- dash_renderer/version.py | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dash_renderer/__init__.py b/dash_renderer/__init__.py index d9005d0..742e1c0 100644 --- a/dash_renderer/__init__.py +++ b/dash_renderer/__init__.py @@ -7,7 +7,8 @@ # command in the dash_html_components package which printed out: # `dash_html_components.__init__: module references __file__` # TODO - Understand this better -from .version import __version__ +# from .version import __version__ +__version__ = '0.12.0-rc1' __file__ # Dash renderer's dependencies get loaded in a special order by the server: diff --git a/dash_renderer/version.py b/dash_renderer/version.py index f323a57..8083dce 100644 --- a/dash_renderer/version.py +++ b/dash_renderer/version.py @@ -1 +1 @@ -__version__ = '0.11.0' +__version__ = '0.12.0rc1' diff --git a/package.json b/package.json index 437f816..562f341 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dash-renderer", - "version": "0.11.0", + "version": "0.12.0-rc1", "description": "render dash components in react", "main": "src/index.js", "scripts": { From 5bf2861cb811bdddace8f906ca7ec1985e3250e5 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 18 Oct 2017 18:42:52 -0400 Subject: [PATCH 5/7] v0.12.0-rc2 --- dash_renderer/__init__.py | 2 +- dash_renderer/version.py | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dash_renderer/__init__.py b/dash_renderer/__init__.py index 742e1c0..7ca5936 100644 --- a/dash_renderer/__init__.py +++ b/dash_renderer/__init__.py @@ -8,7 +8,7 @@ # `dash_html_components.__init__: module references __file__` # TODO - Understand this better # from .version import __version__ -__version__ = '0.12.0-rc1' +__version__ = '0.12.0-rc2' __file__ # Dash renderer's dependencies get loaded in a special order by the server: diff --git a/dash_renderer/version.py b/dash_renderer/version.py index 8083dce..a4f749e 100644 --- a/dash_renderer/version.py +++ b/dash_renderer/version.py @@ -1 +1 @@ -__version__ = '0.12.0rc1' +__version__ = '0.12.0rc2' diff --git a/package.json b/package.json index 562f341..37c5175 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dash-renderer", - "version": "0.12.0-rc1", + "version": "0.12.0-rc2", "description": "render dash components in react", "main": "src/index.js", "scripts": { From b37d44466eb5b39b5aba0171d4e7c8d8011c866e Mon Sep 17 00:00:00 2001 From: chriddyp Date: Thu, 19 Oct 2017 18:34:17 -0400 Subject: [PATCH 6/7] fix request queue tests --- tests/test_render.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_render.py b/tests/test_render.py index 9303c36..fc6fb7d 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -462,7 +462,8 @@ def update_output(value): ) self.request_queue_assertions( - expected_length=call_count.value, check_rejected=False) + expected_length=1, + check_rejected=False) assert_clean_console(self) @@ -1535,5 +1536,4 @@ def update_output(n_clicks): 'return window.store.getState().requestQueue' ) self.assertFalse(request_queue[0]['rejected']) - self.assertTrue(request_queue[1]['rejected']) - self.assertFalse(request_queue[2]['rejected']) + self.assertEqual(len(request_queue), 1) From 53d669d689f748ea7ec2e6ddadea95a97a76e10d Mon Sep 17 00:00:00 2001 From: chriddyp Date: Thu, 19 Oct 2017 19:10:50 -0400 Subject: [PATCH 7/7] v0.11.1 --- CHANGELOG.md | 4 ++++ dash_renderer/__init__.py | 2 +- dash_renderer/version.py | 2 +- package.json | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 257b66a..ebdf41c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.11.1] - 2017-10-19 +### Fixed +- :snail: :racehorse: Fixed a performance issue. In 0.11.0 we introduced an internal request queue to fix some bugs. This request queue was boundless and in certain cases it could become really large and slow down the app. Now, we remove old requests from this queue when they are no longer needed, keeping its size under control. Originally reported in https://github.com/plotly/dash-renderer/issues/27 + ## [0.11.0] - 2017-09-28 ### Fixed - 🐞 Previously, old requests could override new requests if their response was longer than the new one. diff --git a/dash_renderer/__init__.py b/dash_renderer/__init__.py index 7ca5936..084d634 100644 --- a/dash_renderer/__init__.py +++ b/dash_renderer/__init__.py @@ -8,7 +8,7 @@ # `dash_html_components.__init__: module references __file__` # TODO - Understand this better # from .version import __version__ -__version__ = '0.12.0-rc2' +__version__ = '0.11.1' __file__ # Dash renderer's dependencies get loaded in a special order by the server: diff --git a/dash_renderer/version.py b/dash_renderer/version.py index a4f749e..ae4865c 100644 --- a/dash_renderer/version.py +++ b/dash_renderer/version.py @@ -1 +1 @@ -__version__ = '0.12.0rc2' +__version__ = '0.11.1' diff --git a/package.json b/package.json index 37c5175..2c46bcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dash-renderer", - "version": "0.12.0-rc2", + "version": "0.11.1", "description": "render dash components in react", "main": "src/index.js", "scripts": {