Thread (107 messages) 107 messages, 11 authors, 2018-11-15

Re: [PATCH v5 2/5] read-cache: load cache extensions on a worker thread

From: Duy Nguyen <hidden>
Date: 2018-09-15 10:25:17

On Sat, Sep 15, 2018 at 12:22 PM Duy Nguyen [off-list ref] wrote:
quoted
@@ -1944,6 +1993,26 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
        istate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));
        istate->initialized = 1;

+       p.istate = istate;
+       p.mmap = mmap;
+       p.mmap_size = mmap_size;
+
+#ifndef NO_PTHREADS
+       nr_threads = git_config_get_index_threads();
+       if (!nr_threads)
+               nr_threads = online_cpus();
+
+       if (nr_threads >= 2) {
+               extension_offset = read_eoie_extension(mmap, mmap_size);
+               if (extension_offset) {
One more thing I forgot. If the extension area is small enough, then
we should not need to create a thread to parse extensions in parallel.
We should know roughly how much work we need because we know the total
size of all extensions.
quoted
+                       /* create a thread to load the index extensions */
Pointless comment. It's pretty clear from the pthread_create() below
thanks to good function naming. Please remove.
quoted
+                       p.src_offset = extension_offset;
+                       if (pthread_create(&p.pthread, NULL, load_index_extensions, &p))
+                               die(_("unable to create load_index_extensions_thread"));
+               }
+       }
+#endif
+
        if (istate->version == 4) {
                previous_name = &previous_name_buf;
                mem_pool_init(&istate->ce_mem_pool,
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help