android / android-studio-poet

Large Android projects generator
Apache License 2.0
702 stars 85 forks source link

Use coroutines to create modules in parallel #26

Closed srmurguia closed 6 years ago

NikitaKozlov commented 6 years ago

Are you sure that it is faster? You still have only one hard drive, and that is a bottle neck I belive

NikitaKozlov commented 6 years ago

Don't understand me wrong, I don't have anything against this PR. Just was curious if you did some measurements. I'll try to do them now.

srmurguia commented 6 years ago

I am doing that right now, just for curiosity :p

On Fri, Nov 10, 2017 at 12:13 PM Nikita Kozlov notifications@github.com wrote:

Don't understand me wrong, I don't have anything against this PR. Just was curious if you did some measurements. I'll try to do them now.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/borisf/java-generator/pull/26#issuecomment-343574329, or mute the thread https://github.com/notifications/unsubscribe-auth/AcLuTeCiHuxTo1mEZGROEe5qBU3b1sgvks5s1K5TgaJpZM4QaAVZ .

srmurguia commented 6 years ago

You are right, the bottleneck is the drive, but it hides some of the IO latency. On my machine, creating a project with the default settings and 2000 modules takes 19022ms in parallel and 92965ms without coroutines (my machine has a SSD, probably on spinning disk it will not be such an improvement)

srmurguia commented 6 years ago

Actually, probably it will a better improvement on spinning disks, I am not sure.

NikitaKozlov commented 6 years ago

2000 modules? My mac almost died trying to achieve this without coroutines. With coroutines it did much better job, but still more then 1 min.

NikitaKozlov commented 6 years ago

On spinning disks it might be slower, because we are not writing one big stream of bytes, rather a lot of small files. But I'm not sure as well.

srmurguia commented 6 years ago

Yes, probably with lots of methods, to make files big enough. I am not near to one to test.

Also, I tried coroutines on a single thread (using a newSingleThreadContextand) it did not improve, it seems that one single thread cannot use all disk bandwidth. All this conclusions are dependent on hardware anyway, but I think we can assume that it is better to use them.

borisf commented 6 years ago

Thanks all merging