Opened 10 years ago

Closed 10 years ago

#664 closed bug (fixed)

Heap profiler can report hundredths of a second as "3.100" (not "4.000")

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Profiling Version: 6.4
Keywords: Cc:
Operating System: Windows Architecture: x86
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

When running "program +RTS -p -hc", I occasionally have problems with hp2ps because of "samples out of sequence". This appears to be caused by erroneous reporting of hundredths of a second in the program.hp file. An example:

BEGIN_SAMPLE 13.90
(158)/mainMain.CAF      24
(163)/replace/output/mainM...   600036
(156)GC 12
(169)/pairsMain.CAF     276
(159)/output/mainMain.CAF       84
(168)/replaceIubsMain.CAF       96
(88)GHC.Handle.CAF      140
(170)/replace/replaceIubsM...   632392
END_SAMPLE 13.90
'''BEGIN_SAMPLE 13.100'''
(158)/mainMain.CAF      24
(163)/replace/output/mainM...   600036
(156)GC 12
(169)/pairsMain.CAF     276
(159)/output/mainMain.CAF       84
(168)/replaceIubsMain.CAF       96
(88)GHC.Handle.CAF      140
(170)/replace/replaceIubsM...   633052
'''END_SAMPLE 13.100'''
BEGIN_SAMPLE 14.09
(158)/mainMain.CAF      24
(163)/replace/output/mainM...   600036
(156)GC 12
(169)/pairsMain.CAF     276
(159)/output/mainMain.CAF       84
(168)/replaceIubsMain.CAF       96
(88)GHC.Handle.CAF      140
(170)/replace/replaceIubsM...   633880
END_SAMPLE 14.09

In the above example, 14 seconds is reported as 13.100 seconds.

Change History (3)

comment:1 Changed 10 years ago by guest

  • Architecture changed from Unknown to x86
  • Operating System changed from Unknown to Windows

comment:2 Changed 10 years ago by guest

The problem looks to be in ghc/rts/ProfHeap.c in :

static void
printSample(rtsBool beginSample, StgDouble sampleValue)
{
    StgDouble fractionalPart, integralPart;
    fractionalPart = modf(sampleValue, &integralPart);
    fprintf(hp_file, "%s %d.%02d\n",
            (beginSample ? "BEGIN_SAMPLE" : "END_SAMPLE"),
            (int)integralPart, (int)(fractionalPart * 100 + 0.5));
}

Specifically, (int)(fractionalPart * 100 + 0.5). If fractionalPart is >= 0.995, then (int)(fractionalPart * 100 + 0.5) will be equal to 100 and "x.100" will be printed inj the "program.hp" file.

Perhaps (int)(fractionalPart * 100 + 0.5) should just be (int)(fractionalPart * 100).

comment:3 Changed 10 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

Fixed as suggested, thanks.

Note: See TracTickets for help on using tickets.