Title: [214336] trunk/Source/_javascript_Core
- Revision
- 214336
- Author
- [email protected]
- Date
- 2017-03-23 22:31:51 -0700 (Thu, 23 Mar 2017)
Log Message
[JSC] Use WeakRandom for SamplingProfiler interval fluctuation
https://bugs.webkit.org/show_bug.cgi?id=170045
Reviewed by Mark Lam.
It is unnecessary to use cryptographicallyRandomNumber for SamplingProfiler
interval fluctuation. Use WeakRandom instead.
* runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::SamplingProfiler):
(JSC::SamplingProfiler::timerLoop):
* runtime/SamplingProfiler.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (214335 => 214336)
--- trunk/Source/_javascript_Core/ChangeLog 2017-03-24 05:14:13 UTC (rev 214335)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-03-24 05:31:51 UTC (rev 214336)
@@ -1,3 +1,18 @@
+2017-03-23 Yusuke Suzuki <[email protected]>
+
+ [JSC] Use WeakRandom for SamplingProfiler interval fluctuation
+ https://bugs.webkit.org/show_bug.cgi?id=170045
+
+ Reviewed by Mark Lam.
+
+ It is unnecessary to use cryptographicallyRandomNumber for SamplingProfiler
+ interval fluctuation. Use WeakRandom instead.
+
+ * runtime/SamplingProfiler.cpp:
+ (JSC::SamplingProfiler::SamplingProfiler):
+ (JSC::SamplingProfiler::timerLoop):
+ * runtime/SamplingProfiler.h:
+
2017-03-23 Mark Lam <[email protected]>
Array.prototype.splice behaves incorrectly when the VM is "having a bad time".
Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp (214335 => 214336)
--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp 2017-03-24 05:14:13 UTC (rev 214335)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp 2017-03-24 05:31:51 UTC (rev 214336)
@@ -47,7 +47,6 @@
#include "StrongInlines.h"
#include "VM.h"
#include <wtf/HashSet.h>
-#include <wtf/RandomNumber.h>
#include <wtf/RefPtr.h>
#include <wtf/text/StringBuilder.h>
@@ -277,6 +276,7 @@
SamplingProfiler::SamplingProfiler(VM& vm, RefPtr<Stopwatch>&& stopwatch)
: m_vm(vm)
+ , m_weakRandom()
, m_stopwatch(WTFMove(stopwatch))
, m_timingInterval(std::chrono::microseconds(Options::sampleInterval()))
, m_threadIdentifier(0)
@@ -328,7 +328,7 @@
// fluctuation here. The main idea is to prevent our timer from being in sync
// with some system process such as a scheduled context switch.
// http://plv.colorado.edu/papers/mytkowicz-pldi10.pdf
- double randomSignedNumber = (randomNumber() * 2.0) - 1.0; // A random number between [-1, 1).
+ double randomSignedNumber = (m_weakRandom.get() * 2.0) - 1.0; // A random number between [-1, 1).
std::chrono::microseconds randomFluctuation = std::chrono::microseconds(static_cast<uint64_t>(randomSignedNumber * static_cast<double>(m_timingInterval.count()) * 0.20l));
std::this_thread::sleep_for(m_timingInterval - std::min(m_timingInterval, stackTraceProcessingTime) + randomFluctuation);
}
Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.h (214335 => 214336)
--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.h 2017-03-24 05:14:13 UTC (rev 214335)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.h 2017-03-24 05:31:51 UTC (rev 214336)
@@ -35,6 +35,7 @@
#include <wtf/Lock.h>
#include <wtf/Stopwatch.h>
#include <wtf/Vector.h>
+#include <wtf/WeakRandom.h>
namespace JSC {
@@ -190,6 +191,7 @@
void takeSample(const AbstractLocker&, std::chrono::microseconds& stackTraceProcessingTime);
VM& m_vm;
+ WeakRandom m_weakRandom;
RefPtr<Stopwatch> m_stopwatch;
Vector<StackTrace> m_stackTraces;
Vector<UnprocessedStackTrace> m_unprocessedStackTraces;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes