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

Optimize calendar performance and fix bugs #93

Merged
merged 18 commits into from
Oct 17, 2023

Conversation

georgegevoian
Copy link
Contributor

No description provided.

@netlify
Copy link

netlify bot commented Sep 29, 2023

Deploy Preview for boisterous-sunburst-a5c941 ready!

Name Link
🔨 Latest commit 5d16477
🔍 Latest deploy log https://app.netlify.com/sites/boisterous-sunburst-a5c941/deploys/652e9b2aec8f4c0008e8c121
😎 Deploy Preview https://deploy-preview-93--boisterous-sunburst-a5c941.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@georgegevoian georgegevoian changed the title Optimize calendar performance and fix bugs Optimize calendar performance and fix bugs (WIP) Sep 29, 2023
@georgegevoian georgegevoian force-pushed the calendar-performance-optimizations branch from bb009f3 to ff78779 Compare October 2, 2023 01:17
@georgegevoian georgegevoian changed the title Optimize calendar performance and fix bugs (WIP) Optimize calendar performance and fix bugs Oct 2, 2023
@paulfitz paulfitz self-requested a review October 6, 2023 12:19
calendar/page.js Outdated Show resolved Hide resolved
calendar/page.js Show resolved Hide resolved
test/calendar.ts Outdated Show resolved Hide resolved
calendar/page.js Outdated Show resolved Hide resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just syncing the Node version with the main Grist app here.

@@ -12,26 +12,22 @@
"test": "docker image inspect gristlabs/grist --format 'gristlabs/grist image present' && NODE_PATH=_build SELENIUM_BROWSER=chrome mocha -g \"${GREP_TESTS}\" _build/test/*.js",
"test:ci": "MOCHA_WEBDRIVER_HEADLESS=1 npm run test",
"pretest": "docker pull gristlabs/grist && tsc --build && node ./buildtools/publish.js http://localhost:9998",
"grist": "docker run -t -i --rm --name grist-dev --network=host -e PORT=8484 -e GRIST_SINGLE_ORG=preview -e GRIST_WIDGET_LIST_URL=http://localhost:8585/manifest.json gristlabs/grist"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing --network=host here and elsewhere because it's unsupported on macOS.

Copy link
Member

Choose a reason for hiding this comment

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

What is this supposed to do? I don't see any exposed port to connect to? Also what is host-gateway used for?

Once I figure out how this is supposed to be used, I'd like to double check it, since in the past host.docker.internal worked differently on macs vs linux (hopefully that's all fixed long ago, but I'd like to double check)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point - I'm looking now and this script looks unused. May be ok to remove?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I added it, so that it is easy to just build widgets and test them manually. Fine with removing it, or just leaving it as it is for linux users :).
(as this uses host network, docker container is just available on localhost:8484, there is no network isolation, so no ports forwarding)

@@ -12,26 +12,22 @@
"test": "docker image inspect gristlabs/grist --format 'gristlabs/grist image present' && NODE_PATH=_build SELENIUM_BROWSER=chrome mocha -g \"${GREP_TESTS}\" _build/test/*.js",
"test:ci": "MOCHA_WEBDRIVER_HEADLESS=1 npm run test",
"pretest": "docker pull gristlabs/grist && tsc --build && node ./buildtools/publish.js http://localhost:9998",
"grist": "docker run -t -i --rm --name grist-dev --network=host -e PORT=8484 -e GRIST_SINGLE_ORG=preview -e GRIST_WIDGET_LIST_URL=http://localhost:8585/manifest.json gristlabs/grist"
Copy link
Member

Choose a reason for hiding this comment

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

What is this supposed to do? I don't see any exposed port to connect to? Also what is host-gateway used for?

Once I figure out how this is supposed to be used, I'd like to double check it, since in the past host.docker.internal worked differently on macs vs linux (hopefully that's all fixed long ago, but I'd like to double check)

@@ -63,10 +63,10 @@ export class GristTestServer {
await this.stop();
const {gristContainerName, gristImage, gristPort, contentPort} = serverSettings;
const cmd = `docker run -d --rm --name ${gristContainerName}` +
` --network="host"` +
' --add-host=host.docker.internal:host-gateway' +
Copy link
Member

Choose a reason for hiding this comment

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

What role does host-gateway play?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have a Linux machine to test with (though I will go ahead and remove the flag and re-run the CI to check), but I believe this is required for host.docker.internal to work on Linux.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think about checking the OS before building the docker command, and only applying these changes if it's not Linux? If I understand the situation right on Windows, it has the same limitation as macOS.

@@ -117,7 +117,8 @@ export class GristTestServer {

public get assetUrl() {
const {contentPort} = serverSettings;
return `http://localhost:${contentPort}`;
// localhost doesn't work on Node 18 (see https://github.com/node-fetch/node-fetch/issues/1624)
Copy link
Member

Choose a reason for hiding this comment

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

That's a bit scary. I see it is ipv6 related - node-fetch/node-fetch#1624 (comment)

Does this have any consequences for the move to node 18 in Grist? I feel like there's a lot of dependence on localhost in test machinery?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we make any outbound requests to localhost from Node, and the failures I've seen since the upgrade feel more symptomatic of general flakiness.

I see one option is to do dns.setDefaultResultOrder('ipv4first') to go back to the pre-17 behavior.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder about grist-core, grist-omnibus, maybe grist-electron. Grist does make some internal API calls, and APP_HOME_URL could easily end up being based on localhost. When docker is involved, localhost would have been a different host, but I feel like I remember some stuff in grist-omnibus working around this.

Anyway, that's all separate to optimizing calendar performance :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I suspect that all may still be working. Even in this file, the fetch to localhost works fine for the Grist instance running in Docker - it's just live-server that is having the ipv6 problem. We should take a closer look after.

@georgegevoian georgegevoian force-pushed the calendar-performance-optimizations branch from 16fcaba to 1874713 Compare October 12, 2023 16:33
Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

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

Read about the host-gateway thing and I see what it does on newer docker 👍

@georgegevoian georgegevoian merged commit 96f3aa6 into master Oct 17, 2023
2 checks passed
@georgegevoian georgegevoian deleted the calendar-performance-optimizations branch October 17, 2023 14:41
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.

3 participants