romkatv / zsh-defer

Deferred execution of Zsh commands
GNU General Public License v3.0
343 stars 11 forks source link

sched command #10

Closed mnowotnik closed 2 years ago

mnowotnik commented 2 years ago

Why not just use sched command from the zsh/sched module?

romkatv commented 2 years ago

Sure, go ahead.

mnowotnik commented 2 years ago

@romkatv I didn't mean to be rude. I just wanted to know what are the benefits of using this tool over sched :)

romkatv commented 2 years ago

They are different tools.

mnowotnik commented 2 years ago

Screenshot from 2022-06-12 23-23-58

@romkatv They seem pretty similar to me

romkatv commented 2 years ago

Check the docs of both tools.

mnowotnik commented 2 years ago

Sure.

Differences:

Similarities:

Moreover, in the zsh-defer README, it's written:

zsh-defer defers execution of a zsh command until zsh has nothing else to do and is waiting for user input. Its intended purpose is staged zsh startup. It works similarly to Turbo mode in zini

..and the reason Turbo mode works in zinit is that zinit-scheduler is being run periodically by sched

romkatv commented 2 years ago
  • zsh-defer can't print to stdout

This is incorrect.

Similarities:

  • both execute commands when a shell is waiting for a user input

sched can execute commands from precmd or zle, while zsh-defer executes all commands from zle. This makes sched unusable for the primary use case of zsh-defer.

To sum up, sched and zsh-defer are different tools. Their differences are in their respective documentations.

mnowotnik commented 2 years ago

Alright, thanks for clarification regarding precmd. That's what I was missing.

This makes sched unusable for the primary use case of zsh-defer.

Well, it's good enough for zinit to use and I don't feel any delays while using zinit, but of course only a proper benchmark would tell the difference.

romkatv commented 2 years ago

This makes sched unusable for the primary use case of zsh-defer.

Well, it's good enough for zinit to use and I don't feel any delays while using zinit, but of course only a proper benchmark would tell the difference.

zinit turbo mode != shed. zinit turbo mode uses sched but it also uses for loops. Clearly for loop != zinit turbo mode.

mnowotnik commented 2 years ago

Yeah, you're right. Only scheduler runs this way. The part that executes tasks is run as a handler for an fd.

romkatv commented 2 years ago

This might prove useful if you haven't seen it yet: https://github.com/romkatv/zsh-bench#deferred-initialization

mnowotnik commented 2 years ago

That's informative. Thanks!