Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
read-cache.c: reduce branching based on HAVE_THREADS
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sat, 3 Nov 2018 08:48:48 +0000
(09:48 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 5 Nov 2018 04:42:11 +0000
(13:42 +0900)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
62e5ee8
)
diff --git
a/read-cache.c
b/read-cache.c
index 40fc0cb65fd5eac436eab76b1c97a41dc8a35249..00cd416816e7dd291fb8ce7252c919a7228bb7a6 100644
(file)
--- a/
read-cache.c
+++ b/
read-cache.c
@@
-2172,7
+2172,6
@@
int do_read_index(struct index_state *istate, const char *path, int must_exist)
src_offset = sizeof(*hdr);
src_offset = sizeof(*hdr);
- if (HAVE_THREADS) {
nr_threads = git_config_get_index_threads();
/* TODO: does creating more threads than cores help? */
nr_threads = git_config_get_index_threads();
/* TODO: does creating more threads than cores help? */
@@
-2183,6
+2182,9
@@
int do_read_index(struct index_state *istate, const char *path, int must_exist)
nr_threads = cpus;
}
nr_threads = cpus;
}
+ if (!HAVE_THREADS)
+ nr_threads = 1;
+
if (nr_threads > 1) {
extension_offset = read_eoie_extension(mmap, mmap_size);
if (extension_offset) {
if (nr_threads > 1) {
extension_offset = read_eoie_extension(mmap, mmap_size);
if (extension_offset) {
@@
-2210,20
+2212,16
@@
int do_read_index(struct index_state *istate, const char *path, int must_exist)
} else {
src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset);
}
} else {
src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset);
}
- } else {
- src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset);
- }
istate->timestamp.sec = st.st_mtime;
istate->timestamp.nsec = ST_MTIME_NSEC(st);
/* if we created a thread, join it otherwise load the extensions on the primary thread */
istate->timestamp.sec = st.st_mtime;
istate->timestamp.nsec = ST_MTIME_NSEC(st);
/* if we created a thread, join it otherwise load the extensions on the primary thread */
- if (
HAVE_THREADS &&
extension_offset) {
+ if (extension_offset) {
int ret = pthread_join(p.pthread, NULL);
if (ret)
die(_("unable to join load_index_extensions thread: %s"), strerror(ret));
int ret = pthread_join(p.pthread, NULL);
if (ret)
die(_("unable to join load_index_extensions thread: %s"), strerror(ret));
- }
- if (!extension_offset) {
+ } else {
p.src_offset = src_offset;
load_index_extensions(&p);
}
p.src_offset = src_offset;
load_index_extensions(&p);
}
@@
-2745,8
+2743,10
@@
static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
return -1;
if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
return -1;
- if (HAVE_THREADS)
{
+ if (HAVE_THREADS)
nr_threads = git_config_get_index_threads();
nr_threads = git_config_get_index_threads();
+ else
+ nr_threads = 1;
if (nr_threads != 1) {
int ieot_blocks, cpus;
if (nr_threads != 1) {
int ieot_blocks, cpus;
@@
-2777,7
+2777,6
@@
static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
ieot_entries = DIV_ROUND_UP(entries, ieot_blocks);
}
}
ieot_entries = DIV_ROUND_UP(entries, ieot_blocks);
}
}
- }
offset = lseek(newfd, 0, SEEK_CUR);
if (offset < 0) {
offset = lseek(newfd, 0, SEEK_CUR);
if (offset < 0) {
@@
-2861,7
+2860,7
@@
static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
* strip_extensions parameter as we need it when loading the shared
* index.
*/
* strip_extensions parameter as we need it when loading the shared
* index.
*/
- if (
HAVE_THREADS &&
ieot) {
+ if (ieot) {
struct strbuf sb = STRBUF_INIT;
write_ieot_extension(&sb, ieot);
struct strbuf sb = STRBUF_INIT;
write_ieot_extension(&sb, ieot);