zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] use .zwc files with identical timestamps
@ 2018-02-14  6:11 Martijn Dekker
  2018-03-05  1:54 ` Martijn Dekker
  0 siblings, 1 reply; 3+ messages in thread
From: Martijn Dekker @ 2018-02-14  6:11 UTC (permalink / raw)
  To: Zsh hackers list

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

I have been experimenting with zcompile to speed up loading sourced
library scripts. I found that .zwc files are not used if their timestamp
is identical to that of the source file. This can occur, for example, if
an installer script installs a script file and zcompiles it immediately
after. The granularity of file system timestamps, at least on my system,
is not sufficient to register a difference.

I think it should be a safe enough assumption that they correspond if
the timestamps are identical. The attached patch allows zsh to use .zwc
files if their timestamp is greater than, or identical to the source
file's timestamp.

- M.

[-- Attachment #2: zcompile-timestamps.patch --]
[-- Type: text/plain, Size: 1108 bytes --]

diff --git a/Src/parse.c b/Src/parse.c
index 6af2550..47e5a24 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -3677,15 +3677,15 @@ try_dump_file(char *path, char *name, char *file, int *ksh, int test_only)
      * function. */
     queue_signals();
     if (!rd &&
-	(rc || std.st_mtime > stc.st_mtime) &&
-	(rn || std.st_mtime > stn.st_mtime) &&
+	(rc || std.st_mtime >= stc.st_mtime) &&
+	(rn || std.st_mtime >= stn.st_mtime) &&
 	(prog = check_dump_file(dig, &std, name, ksh, test_only))) {
 	unqueue_signals();
 	return prog;
     }
     /* No digest file. Now look for the per-function compiled file. */
     if (!rc &&
-	(rn || stc.st_mtime > stn.st_mtime) &&
+	(rn || stc.st_mtime >= stn.st_mtime) &&
 	(prog = check_dump_file(wc, &stc, name, ksh, test_only))) {
 	unqueue_signals();
 	return prog;
@@ -3724,7 +3724,7 @@ try_source_file(char *file)
     rn = stat(file, &stn);
 
     queue_signals();
-    if (!rc && (rn || stc.st_mtime > stn.st_mtime) &&
+    if (!rc && (rn || stc.st_mtime >= stn.st_mtime) &&
 	(prog = check_dump_file(wc, &stc, tail, NULL, 0))) {
 	unqueue_signals();
 	return prog;

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

end of thread, other threads:[~2018-03-05  9:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14  6:11 [PATCH] use .zwc files with identical timestamps Martijn Dekker
2018-03-05  1:54 ` Martijn Dekker
2018-03-05  9:32   ` Peter Stephenson

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).