Remove the "delay writing to avoid runtime penalty of racy-git avoidance"
The work-around should not be needed. Even if it turns out we would want it later, git will remember the patch for us ;-). Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Aug 15, 2006 at 21:40 UTC
0fc82cff12a887c1e0e7e69937dbd8a82843c081
1 file changed
+1
-52
read-cache.c
+1
-52
@@ -959,9 +959,7 @@ int write_cache(int newfd, struct cache_entry **cache, int entries)
959
{
960
SHA_CTX c;
961
struct cache_header hdr;
962
- int i, removed, recent;
963
- struct stat st;
964
- time_t now;
962
+ int i, removed;
963
964
for (i = removed = 0; i < entries; i++)
965
if (!cache[i]->ce_mode)
@@ -999,54 +997,5 @@ int write_cache(int newfd, struct cache_entry **cache, int entries)
997
return -1;
998
}
999
}
1002
-
1003
- /*
1004
- * To prevent later ce_match_stat() from always falling into
1005
- * check_fs(), if we have too many entries that can trigger
1006
- * racily clean check, we are better off delaying the return.
1007
- * We arbitrarily say if more than 20 paths or 25% of total
1008
- * paths are very new, we delay the return until the index
1009
- * file gets a new timestamp.
1010
- *
1011
- * NOTE! NOTE! NOTE!
1012
- *
1013
- * This assumes that nobody is touching the working tree while
1014
- * we are updating the index.
1015
- */
1016
-
1017
- /* Make sure that the new index file has st_mtime
1018
- * that is current enough -- ce_write() batches the data
1019
- * so it might not have written anything yet.
1020
- */
1021
- ce_write_flush(&c, newfd);
1022
-
1023
- now = fstat(newfd, &st) ? 0 : st.st_mtime;
1024
- if (now) {
1025
- recent = 0;
1026
- for (i = 0; i < entries; i++) {
1027
- struct cache_entry *ce = cache[i];
1028
- time_t entry_time = (time_t) ntohl(ce->ce_mtime.sec);
1029
- if (!ce->ce_mode)
1030
- continue;
1031
- if (now && now <= entry_time)
1032
- recent++;
1033
- }
1034
- if (20 < recent && entries <= recent * 4) {
1035
-#if 0
1036
- fprintf(stderr, "entries %d\n", entries);
1037
- fprintf(stderr, "recent %d\n", recent);
1038
- fprintf(stderr, "now %lu\n", now);
1039
-#endif
1040
- while (!fstat(newfd, &st) && st.st_mtime <= now) {
1041
- off_t where = lseek(newfd, 0, SEEK_CUR);
1042
- sleep(1);
1043
- if ((where == (off_t) -1) ||
1044
- (write(newfd, "", 1) != 1) ||
1045
- (lseek(newfd, -1, SEEK_CUR) != where) ||
1046
- ftruncate(newfd, where))
1047
- break;
1048
- }
1049
- }
1050
- }
1000
return ce_flush(&c, newfd);
1001
}