vuapo-eth / isf-jclient

java console client for the IOTA Spam Fund (http://iotaspam.com)
MIT License
17 stars 5 forks source link

[Feature Request] Resource Limit #6

Closed svenger87 closed 6 years ago

svenger87 commented 6 years ago

An option in config.ini to limit CPU use would be nice. When i run 2 threads on my Windows machine the OS freezes constantly.

laubblaeser commented 6 years ago

How many cores does your Windows machine have?

svenger87 commented 6 years ago

4 cores 4 threads

vuapo-eth commented 6 years ago

right now all spam threads are using maximum priority, we will add an option to change that in the next release, thank you for the request!

laubblaeser commented 6 years ago

I experience similar problems on my Windows machine, using 4 out of 6 cores. A reduction of thread usage would be nice.

laubblaeser commented 6 years ago

Just did some 30 minutes of testing. Using 4 out of 6 cores I can spam about 13.5 txs/min. Using only 1 core I can still spam ~12 txs/min. Using only one core does not slow down the pc at all, everything above that causes a slowdown. I suggest everyone only uses one core for spamming until this issue is resolved because the difference is negligible.

vuapo-eth commented 6 years ago

v1.0.3 now supports configurating the thread priority (minimum/normal/maximum priority)

gjeee commented 6 years ago

somehow if i configure 1 thread with minimum priority, this jar still consumes >95% CPU most of the time. i do not understand why. my machine has 2 cores/4 processors. so 1.0.3 does not solve it for me....

vuapo-eth commented 6 years ago

that's interesting. i suspect that the iota.lib.java library has its own thread management. we are going to do some research on that.

gjeee commented 6 years ago

You are most definitely right: the doc of the iota.lib.java library says:

Threading

It should be noted that most API calls are done synchronously. What this means is that you have to call the API from a background or worker thread, not from the main or UI thread!

gjeee commented 6 years ago

I checked your code. I think i found the exact cause: your NodeManager class interacts with the IOTA API. So this should run on a separate thread (as suggested in its doc). However in the main thread you create a NodeManager instance which is passed in the constructor of the first SpamThread you launch. Thus although you launch separate threads, the first SpamThread sends its spam with a NodeManager which was created on the main thread. So this explains the freezing.

vuapo-eth commented 6 years ago

@gjeee The SpamThread instances are seperate threads calling methods in the NodeManager class - it doesn't matter in which Thread the NodeManager object was created, but rather from which one its methods are called.

vuapo-eth commented 6 years ago

Fixed in v1.0.4