[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 32-bit profiling counts?
From: |
Andrew J. Schorr |
Subject: |
Re: 32-bit profiling counts? |
Date: |
Sat, 6 Jun 2020 11:35:28 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
On Fri, Jun 05, 2020 at 03:44:10PM +0000, Peter Lindgren wrote:
> I've been profiling a very long-running gawk program, and after some time the
> counts of the innermost loops roll over to negative numbers. I wonder whether
> the profile counts are 32-bit signed integers? Could you confirm this? And
> what do you think about changing them to 64-bit integers?
>
> This isn't my original program, but one designed just to show this issue:
>
>
>
> # gawk profile, created Fri Jun 5 09:17:14 2020
>
>
> # BEGIN rule(s)
>
>
> BEGIN {
> 1 two31plus1 = (1024 * 1024 * 1024 * 2) + 1
> 1 status = 1024 * 1024 * 128
> -2147483647 for (x = 1; x <= two31plus1; x++) {
> -2147483647 if (! (x % status)) { # 16
> 16 print "Status: " x
> }
> }
> }
What platform are you running on? From my inspection of the code, it looks like
the counts are stored in an integer of type "long". In awk.h, I think the
relevant item is `exec_count', which is defined as `d.dl', and d.dl is a long.
On my CentOS Linux x86_64 system, that's a 64-bit signed integer, and here's
what I see when I run this program:
bash-4.2$ cat /tmp/profile.awk
BEGIN {
two31plus1 = 2^31+1
status = 2^27
for (x = 1; x <= two31plus1; x++) {
if (! (x % status)) {
print "Status: " x
}
}
}
bash-4.2$ gawk --profile=myprof.out -f /tmp/profile.awk
Status: 134217728
Status: 268435456
Status: 402653184
Status: 536870912
Status: 671088640
Status: 805306368
Status: 939524096
Status: 1073741824
Status: 1207959552
Status: 1342177280
Status: 1476395008
Status: 1610612736
Status: 1744830464
Status: 1879048192
Status: 2013265920
Status: 2147483648
bash-4.2$ cat myprof.out
# gawk profile, created Sat Jun 6 11:23:18 2020
# BEGIN rule(s)
BEGIN {
1 two31plus1 = (1024 * 1024 * 1024 * 2) + 1
1 status = 1024 * 1024 * 128
2147483649 for (x = 1; x <= two31plus1; x++) {
2147483649 if (! (x % status)) { # 16
16 print "Status: " x
}
}
}
Regards,
Andy
- 32-bit profiling counts?, Peter Lindgren, 2020/06/05
- Re: 32-bit profiling counts?,
Andrew J. Schorr <=
- Re: 32-bit profiling counts?, Wolfgang Laun, 2020/06/06
- Re: 32-bit profiling counts?, Andrew J. Schorr, 2020/06/06
- Re: 32-bit profiling counts?, arnold, 2020/06/07
- Re: 32-bit profiling counts?, Wolfgang Laun, 2020/06/07
- Re: 32-bit profiling counts?, Andrew J. Schorr, 2020/06/07
- Re: 32-bit profiling counts?, arnold, 2020/06/08
- Re: 32-bit profiling counts?, Andrew J. Schorr, 2020/06/08
- Re: 32-bit profiling counts?, arnold, 2020/06/09
- Re: 32-bit profiling counts?, Andrew J. Schorr, 2020/06/10