Skip to content

Make Project.WalkTodosOfDir concurrent - #166

Merged
rexim merged 12 commits into
tsoding:masterfrom
aod:concurrent-dir
Feb 3, 2020
Merged

rexim merged 12 commits into
tsoding:masterfrom
aod:concurrent-dir

Conversation

@aod

@aod aod commented Jan 4, 2020 •

Copy link
Copy Markdown
Contributor

Possibly fixes #153

Only snitch purge and snitch report are partly concurrent, the HTTP requests remain sequential. This could be made concurrent as well but maybe not desired.

I've implemented this with a worker pool like pattern. Limiting the amount of files being walked at a given time. Since it will report an error about exceeding the open file descriptors limit on very large projects. I've hardcoded this value for now to the default soft limit on linux. But maybe we should get the value from ulimit and use that instead? (What about other platforms?)

Furthermore I noticed that snitch doesn't ignore non-source-code paths e.g. image paths. I've put a FIXME above the line. Possibly have an option in the config for blacklisting file extensions.

Comment thread project.go Outdated
Comment thread project.go Outdated
Comment thread project.go Outdated
Oktay Dinler added 5 commits January 12, 2020 20:44
Use built-in packages like `sync` and `context` instead.

Remove FIXME for "too many open files" error.
I replaced the workers count (1024) to instead use the
available logical CPUs with `runtime.NumCpu()` for a more reasonable
size.
With this approach that error will never occur.
Benchmarking the list command with both approaches in the
open source `minetest` project using the `time` command, It went
from 7.8s to 4.3s on my machine (Intel i5-8400).
@aod
aod requested a review from rexim January 15, 2020 22:35

@rexim rexim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just make Project.WalkTodosOfDir signature look like this?

func (project Project) WalkTodosOfDir(dirpath string) chan (Todo, error)

The subcommands keep pulling todos from the channel and if they encounter an error they simply close the channel which will indicate the cancellation for the jobs that push into the channel.

Whatever we are doing here right now feels like we are trying to fit a cube into a circle hole. :D

@aod
aod requested a review from rexim January 17, 2020 17:23
@rexim

rexim commented Jan 21, 2020

Copy link
Copy Markdown
Member

@aod I really apologize for being slow on this pull request, just busy with other things. Just wanted to say that I didn't forget about it and will get back to it as soon as I get a chance.

@rexim

rexim commented Feb 3, 2020

Copy link
Copy Markdown
Member

@aod hey! Sorry that it took so long for me to find time to sit down and properly take a look at your Pull Request. I wish the end result was a bit less complex, but I could not find a simpler solution myself. So it looks good to me for now! 👍

Thank you so much for you contribution and patience!

@rexim
rexim merged commit 2ed5d93 into tsoding:master Feb 3, 2020
@aod
aod deleted the concurrent-dir branch February 14, 2020 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snitch doesn't check for issues concurrently

2 participants