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

Fix piping to Helix on macOS #5468

Merged
merged 2 commits into from
Jul 13, 2023
Merged

Conversation

yyogo
Copy link
Contributor

@yyogo yyogo commented Jan 9, 2023

Crossterm will soon merge crossterm-rs/crossterm#735 which will let it use /dev/tty on macOS. This will fix #2111 and allow piping to Helix on macOS.

Fixes #6734

@kirawi kirawi added A-helix-term Area: Helix term improvements upstream S-waiting-on-pr Status: This is waiting on another PR to be merged first labels Jan 9, 2023
@kirawi kirawi added S-waiting-on-review Status: Awaiting review from a maintainer. and removed S-waiting-on-pr Status: This is waiting on another PR to be merged first labels Jan 15, 2023
@kirawi
Copy link
Member

kirawi commented Jan 15, 2023

Waiting on a crossterm release with the meged PR.

@yyogo yyogo marked this pull request as ready for review January 29, 2023 08:08
@yyogo yyogo changed the title Fix piping to Helix on macOS (pending Crossterm update) Fix piping to Helix on macOS - bump crossterm version to 0.26 Jan 29, 2023
@archseer
Copy link
Member

What are the performance implications here? I figured the mio one is probably better optimized

@yyogo
Copy link
Contributor Author

yyogo commented Jan 31, 2023

What are the performance implications here? I figured the mio one is probably better optimized

Fwiw, I haven't noticed any performance differences in Helix or other projects using crossterm when testing manually.

I did mean to do a comparative benchmark for the crossterm PR, but gave up since I couldn't figure out how to do that without emulating the controlling terminal. If there are any existing benchmarks for helix, or if you know of a similar suite in another project, I could try to run it and report what I find.

@archseer
Copy link
Member

archseer commented Feb 7, 2023

A flame graph before/after the change would be useful. As a really simple test you could try opening a 10MB text file and scrolling from top to bottom. Measuring the flame graph there + time taken would be at least one data point

@danriedl
Copy link

What is left to merge this PR? The test you mentioned @archseer ?

@David-Else
Copy link
Contributor

David-Else commented Feb 19, 2023

@danriedl I think there is talk of using a git dependency as a temporary measure for some essential fixes before 0.26.1 #4939

@the-mikedavis
Copy link
Member

I scrolled through Moby Dick with touchpad scrolling as fast as possible with this and master at 1a87d14

The flamegraphs look pretty similar and they both took around 35s. Master:

master

This PR:

5468

@pascalkuthe
Copy link
Member

pascalkuthe commented Feb 21, 2023

Actually crossterm does look like its taking up a bit more space in that flamegraph although not by a huge amount. Probably doesn't matter much in practice.

Couldn't we just turn this feature on for macos and keep it off for other platforms? Platform specific feature are possible with cargo I think. On macos the extra functionality is definitly worth whatever small performance regression this might cause and on other platforms nothing would change then

@archseer
Copy link
Member

The one by this PR actually looks shorter though? There's some mentions about enabling this feature and dropping mio so it might not make sense to have it conditionally enabled in the long run

@yyogo
Copy link
Contributor Author

yyogo commented Feb 21, 2023

@the-mikedavis sorry I couldn't get to this so far, thank you for taking the time. Please see crossterm-rs/crossterm#755 - I think we should hold off on this pr until it is fixed (I'm working on it).

@the-mikedavis
Copy link
Member

Looks like there's a new crossterm 0.26.1 release with your fix 🚀 https://github.com/crossterm-rs/crossterm/releases/tag/0.26.1

@pascalkuthe
Copy link
Member

The one by this PR actually looks shorter though? There's some mentions about enabling this feature and dropping mio so it might not make sense to have it conditionally enabled in the long run

Hmm yeah I saw the same difference but switched the two plots up by accident. This seems very surprising to me tough. mio is really well optimized (and we depend on it anyway trough tokio). If I understood the Pr that integrates tis into crossterm right there is some trickery going on to create a waker. I would have assumed that caused overhead. Just out of curiosity. On which operating system was that flamegraph recorded @the-mikedavis?

@the-mikedavis
Copy link
Member

the-mikedavis commented Feb 26, 2023

That was a macOS laptop. I'll take some linux ones too for comparison.


Ok here's Linux on 1a87d14 scrolling through Moby Dick by holding C-f (trackpad scrolling is working differently between macOS and Linux so I recorded all of these by holding C-f instead):

master

Linux on this PR:

5468

MacOS on 1a87d14:

master

MacOS on this PR:

5468

@pascalkuthe
Copy link
Member

Thanks for the benchmarks! Interesting how different linux and mac are. Is it possible you switched the flamegraphs up in your earlier comment? It looks like this PR is a slight performance regression on both macos on linux from the new flamegraphs you posted. The new macos benchmarks look similar to your earlier benchmark but swapped and now looks roughly what I would have gussed.

It doesn't seem like crossterm will switch away from mio immedietly, the followup PR (crossterm-rs/crossterm#743) still has everything behind a flag (and doesn't drop mio from the dependencies either). I think for now keeping it behind a cfg would make sense as its a performance regression and needs one extra dependency. It doesn't matter much either way tough.

@the-mikedavis
Copy link
Member

Ah yeah, they weren't recorded very scientifically either, just swipe scrolling 😅. I don't have the original files around so I can't be sure

@heliostatic
Copy link
Contributor

I'm running into this crash on a Mac with crossterm 0.26.1 (so with @yyogo 's crossterm patch). How do I properly configure my build of helix to use tty? Right now I'm crashing trying to use fzf to find an execute helix, e.g. fzf --bind 'enter:become(hx {})'

@pascalkuthe
Copy link
Member

I'm running into this crash on a Mac with crossterm 0.26.1 (so with @yyogo 's crossterm patch). How do I properly configure my build of helix to use tty? Right now I'm crashing trying to use fzf to find an execute helix, e.g. fzf --bind 'enter:become(hx {})'

this PR wasn't merged yet. Crossterm doesn't use dev-tty unless you explicitly set a feature flag

@pascalkuthe pascalkuthe added this to the next milestone Mar 31, 2023
@the-mikedavis
Copy link
Member

(Pushed a merge commit since I made a bunch of conflicts in #4939 😅)

@diegs
Copy link
Contributor

diegs commented Apr 18, 2023

@the-mikedavis as you pointed out crossterm 0.26.1 was released a few months ago with the crash fix. What are the remaining decision criteria for switching to the dev-tty feature, at least on MacOS? Are the performance implications too concerning? Thanks!

@yyogo yyogo changed the title Fix piping to Helix on macOS - bump crossterm version to 0.26 Fix piping to Helix on macOS Jun 13, 2023
@yyogo
Copy link
Contributor Author

yyogo commented Jun 13, 2023

We could also enable the feature only on macos, I would think the usability improvement is worth the slight performance regression. (actually I'm not sure if cargo lets you do this: rust-lang/cargo#1197) edit: turns out it is possible

This fixes piping to Helix on macos.
Also remove the error message preventing this usage.
@yyogo
Copy link
Contributor Author

yyogo commented Jul 12, 2023

Closing this in favor of #7607.

@yyogo yyogo closed this Jul 12, 2023
@yyogo yyogo reopened this Jul 12, 2023
helix-term/Cargo.toml Outdated Show resolved Hide resolved
@archseer archseer merged commit 0e0501c into helix-editor:master Jul 13, 2023
@yyogo yyogo deleted the fix-macos-tty branch July 13, 2023 11:48
evanrichter pushed a commit to evanrichter/helix that referenced this pull request Jul 19, 2023
mtoohey31 pushed a commit to mtoohey31/helix that referenced this pull request Jun 2, 2024
smortime pushed a commit to smortime/helix that referenced this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
9 participants