zsh-workers
 help / color / mirror / code / Atom feed
* zcompile bug? zcompile on a single script setting up a chpwd function
@ 2020-10-07  7:48 Doron Behar
  2020-10-07  8:01 ` Roman Perepelitsa
  0 siblings, 1 reply; 6+ messages in thread
From: Doron Behar @ 2020-10-07  7:48 UTC (permalink / raw)
  To: zsh-workers

Hey all.

I have a zsh script I source in my .zshrc. The script is setting up a
function for `chpwd_functions`. Here it is: 

https://github.com/doronbehar/dotfiles/blob/master/.zsh/chpwd/taskwarrior

The function `_chpwd_task_contexts_parser` defined in that file slows
down the shell startup time, and I was looking for a way to improve the
situation. I tried simply zcompiling it, and the `zcompile` command did
generate a .zwc file, but then I get on startup:

	[3] 27780
	/home/doron/.zsh/chpwd/taskwarrior.zwc:1: no such file or directory: ^G^F^E^D^A
	/home/doron/.zsh/chpwd/taskwarrior.zwc:1: permission denied:
	[4] 27781 27782
	[5] 27783
	/home/doron/.zsh/chpwd/taskwarrior.zwc:1: permission denied:
	/home/doron/.zsh/chpwd/taskwarrior.zwc:1: permission denied:
	[6] 27784
	/home/doron/.zsh/chpwd/taskwarrior.zwc:1: permission denied:
	[3]    exit 127
	[4]    exit 126      | A

	[5]  - exit 126    UA0%$A
	[6]  + exit 126
	/home/doron/.zsh/chpwd/taskwarrior.zwc:1: permission denied:
	/home/doron/.zsh/chpwd/taskwarrior.zwc:8: permission denied:
	/home/doron/.zsh/chpwd/taskwarrior.zwc:17: unmatched "

Have I done something wrong?

Doron.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zcompile bug? zcompile on a single script setting up a chpwd function
  2020-10-07  7:48 zcompile bug? zcompile on a single script setting up a chpwd function Doron Behar
@ 2020-10-07  8:01 ` Roman Perepelitsa
  2020-10-07  8:09   ` Doron Behar
  0 siblings, 1 reply; 6+ messages in thread
From: Roman Perepelitsa @ 2020-10-07  8:01 UTC (permalink / raw)
  To: Zsh hackers list

On Wed, Oct 7, 2020 at 9:48 AM Doron Behar <doron.behar@gmail.com> wrote:
>
> The function `_chpwd_task_contexts_parser` defined in that file slows
> down the shell startup time, and I was looking for a way to improve the
> situation. I tried simply zcompiling it

zcompiling doesn't improve execution speed of functions. It can
benefit you only if parsing takes a long time. Given the small size of
file `taskwarrior` (3.5KB), parsing should be almost instantaneous (at
most 1ms), so the speedup from zcompiling won't be noticeable.

> I get on startup:
>
>         [3] 27780
>         /home/doron/.zsh/chpwd/taskwarrior.zwc:1: no such file or directory: ^G^F^E^D^A

Looks like taskwarrior.zwc is corrupted. My practical advice is to
simply remove this file and not waste time on zcompile as it won't
help you anyway. Slow shell startup is likely caused by the slow
execution of _chpwd_set_task_context. You'll need to either avoid
invoking this function or make it run faster.

Roman.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zcompile bug? zcompile on a single script setting up a chpwd function
  2020-10-07  8:01 ` Roman Perepelitsa
@ 2020-10-07  8:09   ` Doron Behar
  2020-10-07  8:12     ` Roman Perepelitsa
  2020-10-07 14:30     ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Doron Behar @ 2020-10-07  8:09 UTC (permalink / raw)
  To: zsh-workers

On Wed, Oct 07, 2020 at 10:01:24AM +0200, Roman Perepelitsa wrote:
> On Wed, Oct 7, 2020 at 9:48 AM Doron Behar <doron.behar@gmail.com> wrote:
> >
> > The function `_chpwd_task_contexts_parser` defined in that file slows
> > down the shell startup time, and I was looking for a way to improve the
> > situation. I tried simply zcompiling it
> 
> zcompiling doesn't improve execution speed of functions. It can
> benefit you only if parsing takes a long time. Given the small size of
> file `taskwarrior` (3.5KB), parsing should be almost instantaneous (at
> most 1ms), so the speedup from zcompiling won't be noticeable.
> 
> > I get on startup:
> >
> >         [3] 27780
> >         /home/doron/.zsh/chpwd/taskwarrior.zwc:1: no such file or directory: ^G^F^E^D^A
> 
> Looks like taskwarrior.zwc is corrupted. My practical advice is to
> simply remove this file and not waste time on zcompile as it won't
> help you anyway. Slow shell startup is likely caused by the slow
> execution of _chpwd_set_task_context. You'll need to either avoid
> invoking this function or make it run faster.

The point is that I have done nothing that could corrupt the zwc file -
it's how zcompile generated it.

I won't use it though, listening to your advice, and think how to
improve it's execution.

Thanks, Doron.

> 
> Roman.
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zcompile bug? zcompile on a single script setting up a chpwd function
  2020-10-07  8:09   ` Doron Behar
@ 2020-10-07  8:12     ` Roman Perepelitsa
  2020-10-07  8:18       ` Doron Behar
  2020-10-07 14:30     ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Roman Perepelitsa @ 2020-10-07  8:12 UTC (permalink / raw)
  To: Zsh hackers list

On Wed, Oct 7, 2020 at 10:09 AM Doron Behar <doron.behar@gmail.com> wrote:
>
> The point is that I have done nothing that could corrupt the zwc file -
> it's how zcompile generated it.

Is it possible that you are executing `source taskwarrior.zwc` instead
of `source taskwarrior`? You should always use the latter regardless
of whether taskwarrior.zwc exists. When executing `source
taskwarrior`, zsh automatically checks whether taskwarrior.zwc exists
and is fresh enough.

Roman.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zcompile bug? zcompile on a single script setting up a chpwd function
  2020-10-07  8:12     ` Roman Perepelitsa
@ 2020-10-07  8:18       ` Doron Behar
  0 siblings, 0 replies; 6+ messages in thread
From: Doron Behar @ 2020-10-07  8:18 UTC (permalink / raw)
  To: zsh-workers

On Wed, Oct 07, 2020 at 10:12:46AM +0200, Roman Perepelitsa wrote:
> On Wed, Oct 7, 2020 at 10:09 AM Doron Behar <doron.behar@gmail.com> wrote:
> >
> > The point is that I have done nothing that could corrupt the zwc file -
> > it's how zcompile generated it.
> 
> Is it possible that you are executing `source taskwarrior.zwc` instead
> of `source taskwarrior`? You should always use the latter regardless
> of whether taskwarrior.zwc exists. When executing `source
> taskwarrior`, zsh automatically checks whether taskwarrior.zwc exists
> and is fresh enough.

Yes I read the docs. I `source taskwarrior`, not sourcing `.zwc`.

Doron.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zcompile bug? zcompile on a single script setting up a chpwd function
  2020-10-07  8:09   ` Doron Behar
  2020-10-07  8:12     ` Roman Perepelitsa
@ 2020-10-07 14:30     ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2020-10-07 14:30 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

On Wed, Oct 7, 2020 at 1:10 AM Doron Behar <doron.behar@gmail.com> wrote:

>
> The point is that I have done nothing that could corrupt the zwc file -
> it's how zcompile generated it.
>

Two possibilities occur to me:
1. There is a maximum size of objects that can be zcompile'd, because it
has internal pointers for loop and function entry points that are stored in
a limited number of bytes.
2. You're running zcompile on one version of zsh and attempting to source
the file on another.

[-- Attachment #2: Type: text/html, Size: 824 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-07 14:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07  7:48 zcompile bug? zcompile on a single script setting up a chpwd function Doron Behar
2020-10-07  8:01 ` Roman Perepelitsa
2020-10-07  8:09   ` Doron Behar
2020-10-07  8:12     ` Roman Perepelitsa
2020-10-07  8:18       ` Doron Behar
2020-10-07 14:30     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).