Changeset 245336 in webkit


Ignore:
Timestamp:
May 15, 2019, 11:53:45 AM (7 years ago)
Author:
Simon Fraser
Message:

Make LOG_WITH_STREAM more efficient
https://bugs.webkit.org/show_bug.cgi?id=197905

Reviewed by Alex Christensen.
Source/WebCore:

No longer need to conditionalize ClipRects logging on the channel being enabled
since LOG_WITH_STREAM fix the performance problem.

Convert some RenderLayerCompositor logging to use LOG_WITH_STREAM.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::calculateClipRects const):
(WebCore::clipRectsLogEnabled): Deleted.

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):

Source/WebCore/PAL:

Make the LOG_WITH_STREAM macro check that the log channel is enabled before
building the stream.

  • pal/LogMacros.h:

Source/WTF:

Add a streamable Repeat() class that can be used to output a series of characters.
This is useful for indenting output.

  • wtf/text/TextStream.h:

(WTF::TextStream::repeat::repeat):
(WTF::TextStream::operator<<):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r245325 r245336  
     12019-05-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make LOG_WITH_STREAM more efficient
     4        https://bugs.webkit.org/show_bug.cgi?id=197905
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add a streamable repeat() class that can be used to output a series of characters.
     9        This is useful for indenting output.
     10
     11        * wtf/text/TextStream.h:
     12        (WTF::TextStream::repeat::repeat):
     13        (WTF::TextStream::operator<<):
     14
    1152019-05-15  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
    216
  • trunk/Source/WTF/wtf/text/TextStream.h

    r225220 r245336  
    103103    }
    104104
     105    struct Repeat {
     106        Repeat(unsigned inWidth, char inCharacter)
     107            : width(inWidth), character(inCharacter)
     108        { }
     109        unsigned width { 0 };
     110        char character { ' ' };
     111    };
     112
     113    TextStream& operator<<(const Repeat& repeated)
     114    {
     115        for (unsigned i = 0; i < repeated.width; ++i)
     116            m_text.append(repeated.character);
     117
     118        return *this;
     119    }
     120
    105121    class IndentScope {
    106122    public:
  • trunk/Source/WebCore/ChangeLog

    r245335 r245336  
    2323        (WebCore::MockRealtimeMediaSourceCenter::mockRealtimeMediaSourceCenterEnabled):
    2424        * platform/mock/MockRealtimeMediaSourceCenter.h:
     25
     262019-05-15  Simon Fraser  <simon.fraser@apple.com>
     27
     28        Make LOG_WITH_STREAM more efficient
     29        https://bugs.webkit.org/show_bug.cgi?id=197905
     30
     31        Reviewed by Alex Christensen.
     32
     33        No longer need to conditionalize ClipRects logging on the channel being enabled
     34        since LOG_WITH_STREAM fix the performance problem.
     35
     36        Convert some RenderLayerCompositor logging to use LOG_WITH_STREAM.
     37
     38        * rendering/RenderLayer.cpp:
     39        (WebCore::RenderLayer::calculateClipRects const):
     40        (WebCore::clipRectsLogEnabled): Deleted.
     41        * rendering/RenderLayerCompositor.cpp:
     42        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
     43        (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
    2544
    26452019-05-15  Simon Fraser  <simon.fraser@apple.com>
  • trunk/Source/WebCore/PAL/ChangeLog

    r245183 r245336  
     12019-05-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make LOG_WITH_STREAM more efficient
     4        https://bugs.webkit.org/show_bug.cgi?id=197905
     5
     6        Reviewed by Alex Christensen.
     7       
     8        Make the LOG_WITH_STREAM macro check that the log channel is enabled before
     9        building the stream.
     10
     11        * pal/LogMacros.h:
     12
    1132019-05-10  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebCore/PAL/pal/LogMacros.h

    r223206 r245336  
    3333
    3434#define LOG_WITH_STREAM(channel, commands) do { \
    35         WTF::TextStream stream(WTF::TextStream::LineMode::SingleLine); \
    36         commands; \
    37         WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), "%s", stream.release().utf8().data()); \
     35        if (JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel).state == WTFLogChannelState::On) { \
     36            WTF::TextStream stream(WTF::TextStream::LineMode::SingleLine); \
     37            commands; \
     38            WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), "%s", stream.release().utf8().data()); \
     39        } \
    3840    } while (0)
    3941
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r245317 r245336  
    281281}
    282282
    283 static bool clipRectsLogEnabled()
    284 {
    285     return LogClipRects.state == WTFLogChannelState::On;
    286 }
    287283#endif
    288284
     
    56305626    }
    56315627
    5632 #if !LOG_DISABLED
    5633     if (clipRectsLogEnabled())
    5634         LOG_WITH_STREAM(ClipRects, stream << "RenderLayer " << this << " calculateClipRects " << clipRects);
    5635 #endif
     5628    LOG_WITH_STREAM(ClipRects, stream << "RenderLayer " << this << " calculateClipRects " << clipRects);
    56365629}
    56375630
     
    56795672        backgroundClipRect.moveBy(view.frameView().scrollPositionForFixedPosition());
    56805673
    5681 #if !LOG_DISABLED
    5682     if (clipRectsLogEnabled())
    5683         LOG_WITH_STREAM(ClipRects, stream << "RenderLayer " << this << " backgroundClipRect with context " << clipRectsContext << " returning " << backgroundClipRect);
    5684 #endif
     5674    LOG_WITH_STREAM(ClipRects, stream << "RenderLayer " << this << " backgroundClipRect with context " << clipRectsContext << " returning " << backgroundClipRect);
    56855675    return backgroundClipRect;
    56865676}
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r245326 r245336  
    139139        childState.hasNotIsolatedCompositedBlendingDescendants = false; // FIXME: should this only be reset for stacking contexts?
    140140#endif
    141 #if ENABLE(TREE_DEBUGGING)
     141#if !LOG_DISABLED
    142142        childState.depth = depth + 1;
    143143#endif
     
    168168    bool hasNotIsolatedCompositedBlendingDescendants { false };
    169169#endif
    170 #if ENABLE(TREE_DEBUGGING)
    171     int depth { 0 };
     170#if !LOG_DISABLED
     171    unsigned depth { 0 };
    172172#endif
    173173};
     
    831831    }
    832832
    833 #if ENABLE(TREE_DEBUGGING)
    834     LOG(Compositing, "%*p %s computeCompositingRequirements (backing provider candidate %p)", 12 + compositingState.depth * 2, &layer, layer.isNormalFlowOnly() ? "n" : "s", backingSharingState.backingProviderCandidate());
    835 #endif
     833    LOG_WITH_STREAM(Compositing, stream << TextStream::Repeat(compositingState.depth * 2, ' ') << &layer << (layer.isNormalFlowOnly() ? " n" : " s") << " computeCompositingRequirements (backing provider candidate " << backingSharingState.backingProviderCandidate() << ")");
    836834
    837835    // FIXME: maybe we can avoid updating all remaining layers in paint order.
     
    10611059    }
    10621060
    1063 #if ENABLE(TREE_DEBUGGING)
    1064     LOG(Compositing, "%*p computeCompositingRequirements - willBeComposited %d (backing provider candidate %p)", 12 + compositingState.depth * 2, &layer, willBeComposited, backingSharingState.backingProviderCandidate());
    1065 #endif
    1066 
    10671061    layer.clearCompositingRequirementsTraversalState();
    1068    
    10691062    overlapMap.geometryMap().popMappingsToAncestor(ancestorLayer);
     1063
     1064    LOG_WITH_STREAM(Compositing, stream << TextStream::Repeat(compositingState.depth * 2, ' ') << &layer << " computeCompositingRequirements - willBeComposited " << willBeComposited << " (backing provider candidate " << backingSharingState.backingProviderCandidate() << ")");
    10701065}
    10711066
     
    10771072    ASSERT(!layer.needsCompositingRequirementsTraversal());
    10781073
    1079 #if ENABLE(TREE_DEBUGGING)
    1080     LOG(Compositing, "%*p traverseUnchangedSubtree", 12 + compositingState.depth * 2, &layer);
    1081 #endif
     1074    LOG_WITH_STREAM(Compositing, stream << TextStream::Repeat(compositingState.depth * 2, ' ') << &layer << (layer.isNormalFlowOnly() ? " n" : " s") << " traverseUnchangedSubtree");
    10821075
    10831076    layer.updateDescendantDependentFlags();
Note: See TracChangeset for help on using the changeset viewer.