Ignore:
Timestamp:
Oct 4, 2014, 12:18:38 PM (11 years ago)
Author:
Brian Burg
Message:

Web Inspector: timelines should not count time elapsed while paused in the debugger
https://bugs.webkit.org/show_bug.cgi?id=136351

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Now that we have a stopwatch to provide pause-aware timing data, we can remove the
profiler's handling of debugger pause/continue callbacks. The timeline agent accounts
for debugger pauses by pausing and resuming the stopwatch.

  • API/JSProfilerPrivate.cpp:

(JSStartProfiling): Use a fresh stopwatch when profiling from the JSC API.

  • inspector/ScriptDebugServer.cpp:

(Inspector::ScriptDebugServer::handlePause):

  • profiler/LegacyProfiler.cpp:

(JSC::LegacyProfiler::profiler): Use nullptr.
(JSC::LegacyProfiler::startProfiling): Hand off a stopwatch to the profile generator.
(JSC::LegacyProfiler::stopProfiling): Use nullptr.
(JSC::LegacyProfiler::didPause): Deleted.
(JSC::LegacyProfiler::didContinue): Deleted.

  • profiler/LegacyProfiler.h:
  • profiler/ProfileGenerator.cpp: Remove debugger pause/continue callbacks and the

timestamp member that was used to track time elapsed by the debugger. Just use the
stopwatch's elapsed times to generate start/elapsed times for function calls.
(JSC::ProfileGenerator::create):
(JSC::ProfileGenerator::ProfileGenerator):
(JSC::ProfileGenerator::beginCallEntry):
(JSC::ProfileGenerator::endCallEntry):
(JSC::ProfileGenerator::didPause): Deleted.
(JSC::ProfileGenerator::didContinue): Deleted.

  • profiler/ProfileGenerator.h:

Source/WebCore:

To avoid counting time elapsed while the debugger is paused, timeline records should
keep track of time elapsed since the start of timeline capturing, rather than wall clock
timestamps. We can easily compute elapsed time by sharing Stopwatch instance among
all timeline record-generating code. The stopwatch is paused while the debugger is paused,
so subsequent time measurements will not include time elapsed while the debugger is paused.

Agents use the shared stopwatch to generate timestamps if the timeline agent is active
(i.e., a timeline recording is being captured). If not, use a zero timestamp since the timing data is only revealed through the Timeline interface.

This refactoring is safe because start and end times are only used to graph records; the
timestamp's actual value is irrelevant and is not displayed in the user interface. Date
timestamps are still included with network-related records as part of their header data.

No new tests, because we cannot reliably test timing changes induced by debugger pauses.
It is possible for records to accrue time before the debugger pauses or after it resumes.

  • inspector/InspectorCSSAgent.cpp: Remove unused include.
  • inspector/InspectorPageAgent.cpp: Use timestamps from the shared stopwatch.

(WebCore::InspectorPageAgent::timestamp):
(WebCore::InspectorPageAgent::domContentEventFired):
(WebCore::InspectorPageAgent::loadEventFired):

  • inspector/InspectorPageAgent.h:
  • inspector/InspectorResourceAgent.cpp: Use timestamps from the shared stopwatch.

(WebCore::InspectorResourceAgent::timestamp):
(WebCore::InspectorResourceAgent::willSendRequest):
(WebCore::InspectorResourceAgent::didReceiveResponse):
(WebCore::InspectorResourceAgent::didReceiveData):
(WebCore::InspectorResourceAgent::didFinishLoading):
(WebCore::InspectorResourceAgent::didFailLoading):
(WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache):
(WebCore::InspectorResourceAgent::willSendWebSocketHandshakeRequest):
(WebCore::InspectorResourceAgent::didReceiveWebSocketHandshakeResponse):
(WebCore::InspectorResourceAgent::didCloseWebSocket):
(WebCore::InspectorResourceAgent::didReceiveWebSocketFrame):
(WebCore::InspectorResourceAgent::didSendWebSocketFrame):
(WebCore::InspectorResourceAgent::didReceiveWebSocketFrameError):

  • inspector/InspectorResourceAgent.h:
  • inspector/InspectorTimelineAgent.cpp: Add calls to reset, start, and stop the stopwatch.

(WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
(WebCore::InspectorTimelineAgent::internalStart):
(WebCore::InspectorTimelineAgent::internalStop):
(WebCore::startProfiling):
(WebCore::InspectorTimelineAgent::startFromConsole):
(WebCore::InspectorTimelineAgent::willCallFunction):
(WebCore::InspectorTimelineAgent::willEvaluateScript):
(WebCore::InspectorTimelineAgent::didPause):
(WebCore::InspectorTimelineAgent::didContinue):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::timestamp):
(WebCore::TimelineTimeConverter::reset): Deleted.

  • inspector/InspectorTimelineAgent.h: Make timestamp() public, and remove old timepieces.

(WebCore::TimelineTimeConverter::TimelineTimeConverter): Deleted.
(WebCore::TimelineTimeConverter::fromMonotonicallyIncreasingTime): Deleted.
(WebCore::InspectorTimelineAgent::timeConverter): Deleted.

  • inspector/TimelineRecordFactory.cpp:

Source/WebInspectorUI:

Don't update the timeline's current time when the debugger is paused.

Start and end times for timeline records are now in seconds elapsed since timeline
recording started, rather than milliseconds since the epoch. Add a workaround to
preserve compatibility with old backends.

  • UserInterface/Controllers/TimelineManager.js:

(WebInspector.TimelineManager.prototype.capturingStarted):
(WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
(WebInspector.TimelineManager.prototype.eventRecorded):

  • UserInterface/Views/TimelineContentView.js:

(WebInspector.TimelineContentView.prototype._debuggerPaused):
(WebInspector.TimelineContentView.prototype._debuggerResumed):

Source/WTF:

  • WTF.vcxproj/WTF.vcxproj:
  • WTF.vcxproj/WTF.vcxproj.filters:
  • WTF.xcodeproj/project.pbxproj:
  • wtf/CMakeLists.txt:
  • wtf/Stopwatch.h: Added. This implements a refcounted monotonic stopwatch.

(WTF::Stopwatch::reset):
(WTF::Stopwatch::start):
(WTF::Stopwatch::stop):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h

    r174095 r174319  
    3333#include <wtf/PassRefPtr.h>
    3434#include <wtf/RefPtr.h>
     35#include <wtf/Stopwatch.h>
    3536#include <wtf/Vector.h>
    3637
    3738namespace JSC {
    3839
    39 class DebuggerCallFrame;
    4040class ExecState;
    41 class VM;
    4241class JSGlobalObject;
    4342class JSObject;
     
    4948    WTF_MAKE_FAST_ALLOCATED;
    5049public:
    51     JS_EXPORT_PRIVATE static LegacyProfiler* profiler(); 
     50    JS_EXPORT_PRIVATE static LegacyProfiler* profiler();
    5251    static CallIdentifier createCallIdentifier(ExecState*, JSValue, const WTF::String& sourceURL, unsigned defaultLineNumber, unsigned defaultColumnNumber);
    5352
    54     JS_EXPORT_PRIVATE void startProfiling(ExecState*, const WTF::String& title);
     53    JS_EXPORT_PRIVATE void startProfiling(ExecState*, const WTF::String& title, PassRefPtr<Stopwatch>);
    5554    JS_EXPORT_PRIVATE PassRefPtr<Profile> stopProfiling(ExecState*, const WTF::String& title);
    5655    void stopProfiling(JSGlobalObject*);
     
    6766    void exceptionUnwind(ExecState* handlerCallFrame);
    6867
    69     void didPause(PassRefPtr<DebuggerCallFrame>);
    70     void didContinue(PassRefPtr<DebuggerCallFrame>);
    71 
    7268    const Vector<RefPtr<ProfileGenerator>>& currentProfiles() { return m_currentProfiles; };
    7369
Note: See TracChangeset for help on using the changeset viewer.