<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>172800</bug_id>
          
          <creation_ts>2017-06-01 03:35:31 -0700</creation_ts>
          <short_desc>[JSC][MIPS] SamplingProfiler::timerLoop() sleeps for 4000+ seconds</short_desc>
          <delta_ts>2017-06-01 10:42:28 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>Other</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Guillaume Emont">guijemont</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>buildbot</cc>
    
    <cc>commit-queue</cc>
    
    <cc>guijemont</cc>
    
    <cc>joepeck</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>saam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1314567</commentid>
    <comment_count>0</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-06-01 03:35:31 -0700</bug_when>
    <thetext>When running stress/sampling-profiler-basic.js, the value of randomFluctuation in SamplingProfiler::timerLoop() can get pretty large, meaning the sampling profiler does not sample much. This causes a bunch of sampling-profiler tests in stress/ to fail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314568</commentid>
    <comment_count>1</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-06-01 03:36:11 -0700</bug_when>
    <thetext>It looks like changing the cast from uint64_t to int64_t solves the issue, but I&apos;m not sure it is the correct approach.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314643</commentid>
    <comment_count>2</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-06-01 09:24:35 -0700</bug_when>
    <thetext>(In reply to Guillaume Emont from comment #1)
&gt; It looks like changing the cast from uint64_t to int64_t solves the issue,
&gt; but I&apos;m not sure it is the correct approach.

Interesting!

uint64_t to int64_t where? Also, what do you mean by &quot;pretty large&quot;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314658</commentid>
    <comment_count>3</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-06-01 09:52:51 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #2)
&gt; (In reply to Guillaume Emont from comment #1)
&gt; &gt; It looks like changing the cast from uint64_t to int64_t solves the issue,
&gt; &gt; but I&apos;m not sure it is the correct approach.
&gt; 
&gt; Interesting!
&gt; 
&gt; uint64_t to int64_t where? Also, what do you mean by &quot;pretty large&quot;?

Sorry, I could have been more precise. I mean to change:
          std::chrono::microseconds randomFluctuation = std::chrono::microseconds(static_cast&lt;uint64_t&gt;(randomSignedNumber * static_cast&lt;double&gt;(m_timingInterval.count()) * 0.20l));

into:</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314664</commentid>
    <comment_count>4</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-06-01 09:54:37 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #2)
&gt; (In reply to Guillaume Emont from comment #1)
&gt; &gt; It looks like changing the cast from uint64_t to int64_t solves the issue,
&gt; &gt; but I&apos;m not sure it is the correct approach.
&gt; 
&gt; Interesting!
&gt; 
&gt; uint64_t to int64_t where? Also, what do you mean by &quot;pretty large&quot;?

Sorry, I could have been more precise. I meant to change:
          std::chrono::microseconds randomFluctuation = std::chrono::microseconds(static_cast&lt;uint64_t&gt;(randomSignedNumber * static_cast&lt;double&gt;(m_timingInterval.count()) * 0.20l));

into:

          std::chrono::microseconds randomFluctuation = std::chrono::microseconds(static_cast&lt;int64_t&gt;(randomSignedNumber * static_cast&lt;double&gt;(m_timingInterval.count()) * 0.20l));

Alternatively, we could put an abs() inside the static_cast&lt;uint64_t&gt;(), depending on what the original intent is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314669</commentid>
    <comment_count>5</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-06-01 10:00:51 -0700</bug_when>
    <thetext>And by pretty large, I mean that sleep afterwards was of more than 4000 seconds (so I guess the value was somewhere close to 2^32?). If that matters, I can run a new debugging session to see the exact number I get.
My guess is that the static_cast from a negative double to an uint64_t is undefined, at least it looks like my compiler (gcc 6.2.0 targeting mipsel) treats it as such.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314670</commentid>
    <comment_count>6</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-06-01 10:01:26 -0700</bug_when>
    <thetext>Yup, the code in ToT clearly looks wrong. We&apos;re looking for a +- random range, but we clearly cast to unsigned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314672</commentid>
    <comment_count>7</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-06-01 10:02:59 -0700</bug_when>
    <thetext>Your proposed change looks right to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314675</commentid>
    <comment_count>8</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-06-01 10:05:15 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #7)
&gt; Your proposed change looks right to me.

Ok, patch upcoming!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314679</commentid>
    <comment_count>9</comment_count>
      <attachid>311715</attachid>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2017-06-01 10:14:10 -0700</bug_when>
    <thetext>Created attachment 311715
Patch

Patch fixing the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314680</commentid>
    <comment_count>10</comment_count>
      <attachid>311715</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-06-01 10:15:06 -0700</bug_when>
    <thetext>Comment on attachment 311715
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314704</commentid>
    <comment_count>11</comment_count>
      <attachid>311715</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-06-01 10:42:26 -0700</bug_when>
    <thetext>Comment on attachment 311715
Patch

Clearing flags on attachment: 311715

Committed r217663: &lt;http://trac.webkit.org/changeset/217663&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314705</commentid>
    <comment_count>12</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-06-01 10:42:28 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>311715</attachid>
            <date>2017-06-01 10:14:10 -0700</date>
            <delta_ts>2017-06-01 10:42:26 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-172800-20170601121410.patch</filename>
            <type>text/plain</type>
            <size>2107</size>
            <attacher name="Guillaume Emont">guijemont</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjE3NjUwCmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCBi
MDU3ZDA3MWQ5YzU5MjdlNDc2YzRmZjdiNWU3NTQzMmYxMTFiNTFmLi4zYzk0MmQ5YmJjMDI4ZGE2
OWFiYjI5ZTlkYTgzMGFiMzAzYWIxZGQ0IDEw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