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

Allow global headless setting #8037

Merged
merged 2 commits into from Dec 1, 2016
Merged

Allow global headless setting #8037

merged 2 commits into from Dec 1, 2016

Conversation

mitar
Copy link
Contributor

@mitar mitar commented Nov 10, 2016

This is a followup to #7814. There are simply many reasons why would various commands be run inside CI and other automatic environments. Spinner is not needed there. Instead of adding --headless arguments to various commands, let's have a global environment variable and this is it.

BTW, this also seems to improve speed of whole Meteor tool experience. I would even say that probably this should be the default. No need for a spinner at all. It slows down things too much.

@stubailo
Copy link
Contributor

this also seems to improve speed of whole Meteor tool experience

Any way we can confirm this? Would be big news if true.

@mitar
Copy link
Contributor Author

mitar commented Nov 10, 2016

Any way we can confirm this? Would be big news if true.

Sadly I could not run this against my bigger project from checkout because my project uses newer version of Blaze and I could not convince Meteor from checkout to use that version of Blaze. So I was unable to measure on a large codebase to have significant results.

@veered
Copy link
Contributor

veered commented Nov 10, 2016

I've experienced this in the Qualia application as well (with progress updates from the build tool in general, not just specifically the spinner), although it's a little difficult to reproduce. The fundamental issue is that Node's logging statements are synchronous and the progress updates sends many thousands of messages to the console. So if the log buffer gets filled up everything slows to a crawwwwwwllllllll. I've tried commenting out the logging and it definitely speeds things up.

Here is a representative sample from a CPU profile of our application during the initial portion of the build tool where it is printing out a bunch of stuff:

image

This CPU profile is from Meteor 1.3, not Meteor 1.4, but I don't see why that would've changed this problem. On this reload, it spent 1.9s (of the first 3 seconds of a reload) in writeUtf8String! Note that this behavior does not occur on the first reload, but seems to worsen with time.

@abernix
Copy link
Contributor

abernix commented Nov 15, 2016

While performance is important and ultimately, yes, this could be disabled, I disagree that there is "No need for a spinner at all". I feel that losing the spinner for the whole of the meteor-tool would be a loss for the user-experience of the tool. It seems preferable to explore another option for this.

As @veered mentioned above, the blocking nature of process.stdout when attached to a TTY is likely to blame. I'm not sure if it would work, but perhaps something like what stdout-stream does would be relevant?

Also, I haven't looked at the console code but if the spinner was moved to the beginning of the line, maybe the amount of output could be substantially reduced since it would be possible to overwrite only the spinner portion instead of the whole message (i.e. fewer bytes).

@mitar
Copy link
Contributor Author

mitar commented Nov 15, 2016

I feel that losing the spinner for the whole of the meteor-tool would be a loss for the user-experience of the tool.

Really? Now that things are running so fast, I think there is always some message quickly flickering between my eyes.

Anyway, let's merge this. And then others can measure performance and also we can later on decide if to remove/change spinner at all.

@abernix
Copy link
Contributor

abernix commented Nov 15, 2016

Really? Now that things are running so fast, I think there is always some message quickly flickering between my eyes.

I prefer that all technology show its user that it is doing something versus nothing at all. :)

But yes, if it just sat there saying Building local package, Building for web.browser, Scanning ..., etc. I feel like that would be less ideal than showing that it's actually chewing on something.

Anyway, let's merge this

Agree, the above convo/profile should be broken into a separate issue for discussion.

@@ -309,7 +309,7 @@ var ProgressDisplayFull = function (console) {
self._progressBarRenderer = new ProgressBarRenderer(PROGRESS_BAR_FORMAT, options);
self._progressBarRenderer.start = new Date();

self._headless = false;
self._headless = !!(process.env.METEOR_HEADLESS && process.env.METEOR_HEADLESS != '0');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the != '0' necessary? If so, it should probably use JSON.parse in the same manner as METEOR_ALLOW_SUPERUSER, but really, why not just have it work like most other env variables where if it's set in the environment, it's true otherwise, false: !!(process.env.METEOR_HEADLESS)

Either way, it should use strict equality !== not !=.

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 reused the same approach from this same file: https://github.com/mitar/meteor/blob/3ee60f57e57b56b56b36e8c8cdbdbb79c9b55e25/tools/console/console.js#L74

I wanted to be consistent inside a file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate the consistency, but I was just about to link to the same METEOR_ALLOW_SUPERUSER example that @abernix mentioned above, because I think it's important to support e.g. METEOR_HEADLESS=false.

@@ -309,7 +309,7 @@ var ProgressDisplayFull = function (console) {
self._progressBarRenderer = new ProgressBarRenderer(PROGRESS_BAR_FORMAT, options);
self._progressBarRenderer.start = new Date();

self._headless = false;
self._headless = !!(process.env.METEOR_HEADLESS && process.env.METEOR_HEADLESS != '0');
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate the consistency, but I was just about to link to the same METEOR_ALLOW_SUPERUSER example that @abernix mentioned above, because I think it's important to support e.g. METEOR_HEADLESS=false.

@mitar
Copy link
Contributor Author

mitar commented Nov 30, 2016

Updated.

@benjamn benjamn merged commit e804c00 into meteor:devel Dec 1, 2016
benjamn added a commit that referenced this pull request Dec 6, 2016
This should also fix a bug where Console.isHeadless() was returning false
in tests.

Follow-up to #8037.
@mitar
Copy link
Contributor Author

mitar commented Feb 17, 2017

@veered: Have you recently measures how quick is building time if you disable output now?

@veered
Copy link
Contributor

veered commented Feb 17, 2017

I haven't upgraded our version of Meteor yet; I'll let you know when I do & maybe post a profile

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

5 participants