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

[Canvas] Perf: save workbook assets separately from lighter weight structures #29594

Merged
merged 2 commits into from
Feb 1, 2019

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Jan 30, 2019

Summary

Closes #28535

@monfera monfera added the Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas label Jan 30, 2019
@monfera monfera self-assigned this Jan 30, 2019
@monfera monfera requested a review from w33ble January 30, 2019 11:35
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-canvas

@monfera
Copy link
Contributor Author

monfera commented Jan 30, 2019

Something leaner or more orthogonal and future-proof could be whipped up (in this PR or later), but I thought it's better to have a checkpoint earlier.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

server.route({
method: 'PUT',
path: `${routePrefixStructures}/{id}`,
config: { payload: { allow: 'application/json', maxBytes: 26214400 } }, // 25MB payload limit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the workpad payload itself needs to have a 25MB limit, just the entire document (and it's mostly made up of the assets). It doesn't matter if we leave this here though, it shouldn't affect anything.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@monfera monfera changed the title [Canvas][WIP] Perf: save workbook assets separately from lighter weight structures [Canvas] Perf: save workbook assets separately from lighter weight structures Jan 31, 2019
const changedWorkpad = workpadChanged(curState, newState);
const changedAssets = assetsChanged(curState, newState);

if (changedWorkpad && changedAssets) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, I can never hit this scenario. Which makes sense, all the state updates are sync and happen in order, and assets and workpads all have their own distinct actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's belts & braces, as the original code could've handled a common update and I shied away from proving it cannot happen. It'll probably be addressed on its own with the route simplification you suggested.

Copy link
Contributor

@w33ble w33ble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

return updateWorkpad(persistedWorkpad.id, persistedWorkpad).catch(notifyError);
} else if (changedAssets) {
// if the assets changed, save it to elasticsearch
const persistedWorkpad = getFullWorkpadPersisted(getState());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This is fine, but you could have just used getAssets from selectors/assets, which is how the workpad selector populates that value anyway.

import { getId } from '../../public/lib/get_id';

export function workpad(server) {
//const config = server.config();
const { errors: esErrors } = server.plugins.elasticsearch.getCluster('data');
const routePrefix = API_ROUTE_WORKPAD;
const routePrefixAssets = API_ROUTE_WORKPAD_ASSETS;
const routePrefixStructures = API_ROUTE_WORKPAD_STRUCTURES;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't know if you explored this at all, but doing some kind of detection in a single route would be nice. Having 3 different routes to update a workpad (just the workpad, just the assets, or both) is easy, but seems like overkill. I'm fine leaving it this way though, just wanted to express that opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created separate issue #29930 to address this and by extension, most of your other feedback items.

@w33ble w33ble added the v7.0.0 label Feb 1, 2019
@monfera
Copy link
Contributor Author

monfera commented Feb 1, 2019

Thanks Joe! Merging it now, looking into the suggestions for a follow-up PR.

@monfera monfera merged commit d91809d into master Feb 1, 2019
monfera added a commit to monfera/kibana that referenced this pull request Feb 1, 2019
…ructures (elastic#29594)

* Perf: save workbook assets separately from lighter weight structures

* Chore: simplification
monfera added a commit that referenced this pull request Feb 1, 2019
…ructures (#29594) (#29855)

* Perf: save workbook assets separately from lighter weight structures

* Chore: simplification
@monfera monfera deleted the split-asset-persist branch February 1, 2019 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v6.7.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants