Bug 154148 - Enhance logging
Summary: Enhance logging
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Enhancement
Assignee: Keith Rollin
URL:
Keywords:
Depends on: 154501 154930
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-11 18:34 PST by Keith Rollin
Modified: 2018-11-25 16:56 PST (History)
3 users (show)

See Also:


Attachments
Patch (deleted)
2016-02-16 10:57 PST, Keith Rollin
no flags Details
Patch (deleted)
2016-02-18 12:50 PST, Keith Rollin
no flags Details
Patch (deleted)
2016-02-18 16:01 PST, Keith Rollin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Rollin 2016-02-11 18:34:10 PST
Enhance logging in order to help diagnose in-the-field issues.

cf:
rdar://problem/23836456
rdar://problem/22870338
Comment 1 Keith Rollin 2016-02-16 10:57:02 PST
Created attachment 271438 [details]
Patch
Comment 2 Keith Rollin 2016-02-18 12:50:01 PST
Created attachment 271684 [details]
Patch
Comment 3 WebKit Commit Bot 2016-02-18 12:52:46 PST
Attachment 271684 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/Assertions.h:458:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WTF/wtf/Assertions.h:464:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 2 in 71 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Keith Rollin 2016-02-18 16:01:10 PST
Created attachment 271712 [details]
Patch
Comment 5 WebKit Commit Bot 2016-02-18 16:05:08 PST
Attachment 271712 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/Assertions.h:458:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WTF/wtf/Assertions.h:464:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 2 in 71 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Chris Dumez 2016-02-19 12:06:04 PST
Comment on attachment 271712 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=271712&action=review

Some initial comments. I'll review more deeply later.

> Source/WTF/ChangeLog:12
> +        Always-on logging is implemented in the form of some new macros.

Please don't duplicate the changelog entries. they should refer to specific project changes.

> Source/WTF/wtf/Assertions.cpp:503
> +    ASSERT(timer);

We normally don't take raw pointers in if they are expected to be non-null. This probably should take a WTFTimer& instead.

> Source/WTF/wtf/Assertions.cpp:510
> +bool WTFTimerExceededThreshold(WTFTimer* timer)

We normally don't take raw pointers in if they are expected to be non-null. This probably should take a WTFTimer& instead.

> Source/WTF/wtf/Assertions.cpp:513
> +    if (timer->m_end < 0.0) {

Seems kind of unexpected that this function (given its name) would update timer->m_end, isn't it?

> Source/WTF/wtf/Assertions.cpp:520
> +bool WTFIsSimpleFormat(const char* format)

Can you document with a comment what a "simple" format is?

> Source/WTF/wtf/Assertions.h:43
> +#if USE(OS_LOG)

The ifdefed includes should come after the regular includes, not in the middle of other includes.

> Source/WTF/wtf/Assertions.h:139
> +typedef struct {

isn't the typedef struct a C thing?

> Source/WTF/wtf/Assertions.h:168
> +WTF_EXPORT_PRIVATE void WTFTimerInit(WTFTimer*, double threshold);

We try to use std:chrono these days instead of double to represent times or durations.

> Source/WebCore/html/parser/HTMLDocumentParser.cpp:252
> +    LOG_ALWAYS_TIMER_START(pumpTimer, 0.100);

this 0.100 is not very readable. This is why we use std::chrono for these things.

Also, for theses things we tend to use scope and local variables with "Scope" in the name. e.g.
{
  LogIfSlowerThan logger("blah blah", 100_ms);
  // ...
}

> Tools/TestWebKitAPI/Tests/WTF/Assertions.cpp:35
> +// <samples> * (<samples> + 1), we end up with 146,325,312 tests. If we were to

This seems like a lot. How long does it take to run all these tests. I am working about the extra testing time on the slower bots and possible timeouts.
Comment 7 Keith Rollin 2016-02-19 12:25:32 PST
(In reply to comment #6)
> Comment on attachment 271712 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=271712&action=review
> 
> Some initial comments. I'll review more deeply later.
> 
> > Source/WTF/ChangeLog:12
> > +        Always-on logging is implemented in the form of some new macros.
> 
> Please don't duplicate the changelog entries. they should refer to specific
> project changes.

OK. I'll rewrite the changelog entries.

> > Source/WTF/wtf/Assertions.cpp:503
> > +    ASSERT(timer);
> 
> We normally don't take raw pointers in if they are expected to be non-null.
> This probably should take a WTFTimer& instead.

There's a comment in Assertions.h saying that the file should be compatible with C. That's why this whole timing facility uses pointers, "typedef struct", and non-member functions. However, as we discussed offline, the utility of the timing functions is questionable, so I'll be taking those out for this check-in.

> > Source/WTF/wtf/Assertions.cpp:510
> > +bool WTFTimerExceededThreshold(WTFTimer* timer)
> 
> We normally don't take raw pointers in if they are expected to be non-null.
> This probably should take a WTFTimer& instead.
> 
> > Source/WTF/wtf/Assertions.cpp:513
> > +    if (timer->m_end < 0.0) {
> 
> Seems kind of unexpected that this function (given its name) would update
> timer->m_end, isn't it?

Taking this out, per above.

> > Source/WTF/wtf/Assertions.cpp:520
> > +bool WTFIsSimpleFormat(const char* format)
> 
> Can you document with a comment what a "simple" format is?

OK.

> > Source/WTF/wtf/Assertions.h:43
> > +#if USE(OS_LOG)
> 
> The ifdefed includes should come after the regular includes, not in the
> middle of other includes.

OK.

> > Source/WTF/wtf/Assertions.h:139
> > +typedef struct {
> 
> isn't the typedef struct a C thing?

Yes, per above. Also, taking out per above.

> > Source/WTF/wtf/Assertions.h:168
> > +WTF_EXPORT_PRIVATE void WTFTimerInit(WTFTimer*, double threshold);
> 
> We try to use std:chrono these days instead of double to represent times or
> durations.

OK. But taking this out, per above.

> > Source/WebCore/html/parser/HTMLDocumentParser.cpp:252
> > +    LOG_ALWAYS_TIMER_START(pumpTimer, 0.100);
> 
> this 0.100 is not very readable. This is why we use std::chrono for these
> things.

OK. But taking this out, per above.

> Also, for theses things we tend to use scope and local variables with
> "Scope" in the name. e.g.
> {
>   LogIfSlowerThan logger("blah blah", 100_ms);
>   // ...
> }

OK. But taking this out, per above.

> > Tools/TestWebKitAPI/Tests/WTF/Assertions.cpp:35
> > +// <samples> * (<samples> + 1), we end up with 146,325,312 tests. If we were to
> 
> This seems like a lot. How long does it take to run all these tests. I am
> working about the extra testing time on the slower bots and possible
> timeouts.

I've toned this down to about 180,000 tests, or about 1% of what it used to be. The tests used to take about 120 second to run, so we should be running in 1-2 seconds now.
Comment 8 Sam Weinig 2016-02-21 19:16:03 PST
Comment on attachment 271712 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=271712&action=review

> Source/WebKit2/NetworkProcess/NetworkProcess.cpp:128
> +#if !LOG_ALWAYS_DISABLED
> +    reportResourceUsage();
> +#endif

It seems like it would be better to have this called by the callers of didReceiveMessage, since there are fewer of those.

> Source/WebKit2/Platform/IPC/Connection.h:102
> +#if !LOG_ALWAYS_DISABLED
> +        void reportResourceUsage();
> +
> +    private:
> +        double m_lastReportTime = 0;
> +        struct rusage m_usage = {{0, 0}, {0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
> +#endif

It seems really odd for this to be on the client.  Client's usually are just used for delegation and notification.  It seems like this should be on the Connection itself and probably abstracted out a bit.  Also, it should be using std::chrono instead of doubles.
Comment 9 Keith Rollin 2016-02-21 21:08:05 PST
Thanks, Sam. I'll look at refactoring.
Comment 10 Lucas Forschler 2016-02-24 16:51:05 PST
The content of attachment 271438 [details] has been deleted by
    Lucas Forschler <lforschler@apple.com>
who provided the following reason:

yes

The token used to delete this attachment was generated at 2016-02-24 16:51:00 PST.
Comment 11 Lucas Forschler 2016-02-24 16:51:22 PST
The content of attachment 271712 [details] has been deleted by
    Lucas Forschler <lforschler@apple.com>
who provided the following reason:

yes

The token used to delete this attachment was generated at 2016-02-24 16:51:20 PST.
Comment 12 Lucas Forschler 2016-02-24 16:51:55 PST
The content of attachment 271684 [details] has been deleted by
    Lucas Forschler <lforschler@apple.com>
who provided the following reason:

yes

The token used to delete this attachment was generated at 2016-02-24 16:51:52 PST.
Comment 13 Keith Rollin 2018-11-25 16:56:27 PST
I don't remember what this was about. I don't have any local work towards this.