Re: [dev] [st] [PATCH] Fixed wrong nanosecond factor 10E6.

2014-06-26 Thread Silvan Jegen
On Thu, Jun 26, 2014 at 4:30 AM, Ivan Delalande col...@ycc.fr wrote:
 Commit 5edeec1 introduced a wrong factor for nanosecond computation, the 
 correct
 value is 1E6. Time and timeout values are 10 times less than they should be 
 and
 this cause high CPU usage.

 Reported by pyroh on IRC. Thanks!

Nice!

I can confirm that this patch makes a big difference on the VM I use
at work. Even typing in st is slow without this patch applied.


Cheers,

Silvan

 ---
  st.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

 diff --git a/st.c b/st.c
 index 17142a4..f9c9f7a 100644
 --- a/st.c
 +++ b/st.c
 @@ -76,7 +76,7 @@ char *argv0;
  #define LIMIT(x, a, b)(x) = (x)  (a) ? (a) : (x)  (b) ? (b) : (x)
  #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != 
 (b).bg)
  #define IS_SET(flag) ((term.mode  (flag)) != 0)
 -#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + 
 (t1.tv_nsec-t2.tv_nsec)/10E6)
 +#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + 
 (t1.tv_nsec-t2.tv_nsec)/1E6)
  #define CEIL(x) (((x) != (int) (x)) ? (x) + 1 : (x))
  #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) = ~(bit)))

 @@ -3753,7 +3753,7 @@ run(void) {

 clock_gettime(CLOCK_MONOTONIC, now);
 drawtimeout.tv_sec = 0;
 -   drawtimeout.tv_nsec = (1000/xfps) * 10E6;
 +   drawtimeout.tv_nsec = (1000/xfps) * 1E6;
 tv = drawtimeout;

 dodraw = 0;
 @@ -3790,7 +3790,7 @@ run(void) {
  blinktimeout) {
 drawtimeout.tv_nsec = 1000;
 } else {
 -   drawtimeout.tv_nsec = (10E6 * 
 \
 +   drawtimeout.tv_nsec = (1E6 * \
 (blinktimeout - \
 TIMEDIFF(now,
 lastblink)));
 --
 2.0.0


 --
 Ivan Colona Delalande




Re: [dev] [st] [PATCH] Fixed wrong nanosecond factor 10E6.

2014-06-26 Thread Roberto E. Vargas Caballero
 Commit 5edeec1 introduced a wrong factor for nanosecond computation, the 
 correct
 value is 1E6. Time and timeout values are 10 times less than they should be 
 and
 this cause high CPU usage.

Applied!!!, thanks.

-- 
Roberto E. Vargas Caballero



Re: [dev] [st] [PATCH] Fixed wrong nanosecond factor 10E6.

2014-06-26 Thread FRIGN
On Thu, 26 Jun 2014 09:14:11 +0200
Silvan Jegen s.je...@gmail.com wrote:

 Nice!
 
 I can confirm that this patch makes a big difference on the VM I use
 at work. Even typing in st is slow without this patch applied.

Sorry for not noticing this! I assumed (10E6 == 10^6). I'm sure this
won't happen again ;)

Cheers

FRIGN

-- 
FRIGN d...@frign.de



Re: [dev] [st] [PATCH] Fixed wrong nanosecond factor 10E6.

2014-06-26 Thread Silvan Jegen
On Thu, Jun 26, 2014 at 12:49 PM, FRIGN d...@frign.de wrote:
 On Thu, 26 Jun 2014 09:14:11 +0200
 Silvan Jegen s.je...@gmail.com wrote:

 Nice!

 I can confirm that this patch makes a big difference on the VM I use
 at work. Even typing in st is slow without this patch applied.

 Sorry for not noticing this! I assumed (10E6 == 10^6). I'm sure this
 won't happen again ;)

That's ok, bugs happen (and I did not see it when the patch was sent either).

I only noticed when I tested the patch that fixed the issue (because I
was running a version without the problematic commit. Otherwise I
would have complained about the change in speed ASAP :-) ).



Re: [dev] [st] [PATCH] Fixed wrong nanosecond factor 10E6.

2014-06-26 Thread FRIGN
On Thu, 26 Jun 2014 12:58:34 +0200
Silvan Jegen s.je...@gmail.com wrote:

 That's ok, bugs happen (and I did not see it when the patch was sent either).
 
 I only noticed when I tested the patch that fixed the issue (because I
 was running a version without the problematic commit. Otherwise I
 would have complained about the change in speed ASAP :-) ).

Well, it's tempting to write 10E6 instead of 1E6.
Being a mathematician, it's almost an idiom for me to write it like
that. But instead, it acts more like a base 10 bitshift with all
implications.

Cheers

FRIGN

-- 
FRIGN d...@frign.de