From d87572053a15474a577dcf5714187fbdb4cfec0d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 2 Mar 2016 16:26:36 +0100 Subject: QmlProfiler: Send events in smaller batches This enables more parallel data processing and limits the memory usage. Benchmarks with the "planets" example from canvas3d show that this change reduces the time between the profiling being stopped and the last events arriving in the profiling client by about 50%. Change-Id: Iea16f9e2ae3adf584ec4a3c7fc766eaa21740f98 Reviewed-by: Simon Hausmann --- .../qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp | 2 +- .../qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp | 15 +++++++++------ .../qmltooling/qmldbg_profiler/qv4profileradapter.cpp | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/plugins/qmltooling/qmldbg_profiler') diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp index e89d87e76b..872dcbe718 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp @@ -107,7 +107,7 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData *d, QList &messages) { while (next != data.length()) { - if (data[next].time > until) + if (data[next].time > until || messages.length() > s_numMessagesPerBatch) return data[next].time; qQmlProfilerDataToByteArrays(&(data[next++]), messages); } diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index fc2ba1e094..9e1c8af3e6 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -342,12 +342,15 @@ void QQmlProfilerServiceImpl::sendMessages() while (!m_startTimes.empty()) { QQmlAbstractProfilerAdapter *first = m_startTimes.begin().value(); m_startTimes.erase(m_startTimes.begin()); - if (!m_startTimes.empty()) { - qint64 next = first->sendMessages(m_startTimes.begin().key(), messages); - if (next != -1) - m_startTimes.insert(next, first); - } else { - first->sendMessages(std::numeric_limits::max(), messages); + qint64 next = first->sendMessages(m_startTimes.isEmpty() ? + std::numeric_limits::max() : + m_startTimes.begin().key(), messages); + if (next != -1) + m_startTimes.insert(next, first); + + if (messages.length() >= QQmlAbstractProfilerAdapter::s_numMessagesPerBatch) { + emit messagesToClient(name(), messages); + messages.clear(); } } diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp index ffacc58817..e91f7fbf51 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp @@ -105,7 +105,7 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList &message while (!m_stack.isEmpty() && (m_functionCallPos == m_functionCallData.length() || m_stack.top() <= m_functionCallData[m_functionCallPos].start)) { - if (m_stack.top() > until) + if (m_stack.top() > until || messages.length() > s_numMessagesPerBatch) return finalizeMessages(until, messages, m_stack.top()); appendMemoryEvents(m_stack.top(), messages); @@ -117,7 +117,7 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList &message (m_stack.empty() || m_functionCallData[m_functionCallPos].start < m_stack.top())) { const QV4::Profiling::FunctionCallProperties &props = m_functionCallData[m_functionCallPos]; - if (props.start > until) + if (props.start > until || messages.length() > s_numMessagesPerBatch) return finalizeMessages(until, messages, props.start); appendMemoryEvents(props.start, messages); -- cgit v1.2.3