-
Notifications
You must be signed in to change notification settings - Fork 7
Improve debug log #43
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #43 +/- ##
==========================================
- Coverage 81.92% 80.80% -1.12%
==========================================
Files 7 7
Lines 603 693 +90
==========================================
+ Hits 494 560 +66
- Misses 109 133 +24
Continue to review full report at Codecov.
|
7c02655
to
4ff8682
Compare
alloc.c
Outdated
"applying properties...", | ||
(void *)layer, plane->id); | ||
if (!plane_apply(plane, layer, result->req, &compatible)) { | ||
return false; | ||
} | ||
if (!compatible) { | ||
liftoff_log(LIFTOFF_DEBUG, | ||
"Layer %p -> plane %"PRIu32": " | ||
" Layer %p -> plane %"PRIu32": " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: alignment is broken here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tabs are killing me sometimes. I am using QtCreator and most of the time it seems to work fine after I configured it to use tabs. But sometimes the alignment breaks for unknown reasons. I can't find this alignment problem anymore in the current revision.
alloc.c
Outdated
@@ -425,7 +425,7 @@ bool output_choose_layers(struct liftoff_output *output, | |||
} | |||
if (compatible) { | |||
liftoff_log(LIFTOFF_DEBUG, | |||
"Layer %p -> plane %"PRIu32": success", | |||
" Layer %p -> plane %"PRIu32": success", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
alloc.c
Outdated
liftoff_list_for_each(plane, &device->planes, link) { | ||
if (plane->layer == NULL) { | ||
liftoff_log(LIFTOFF_DEBUG, | ||
"Disabling plane %"PRIu32, plane->id); | ||
liftoff_log_cnt(LIFTOFF_DEBUG, " %"PRIu32, plane->id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I'm on the fence about this, I'm not a fan of adding a new log API, especially given that some log APIs aren't able to control whether newlines are added to the output or not. For instance this is the case of wlroots' log system.
if (log_has(LIFTOFF_DEBUG)) {
char *buf = calloc(1, 11 * liftoff_list_length(&device->planes) + 1);
size_t n = 0;
liftoff_list_for_each(plane, &device->planes, link) {
if (plane->layer == NULL) {
int ret = snprintf(&buf[n], 12, " %"PRIu32, plane->id);
if (ret < 0) {
break;
}
n += ret - 1;
}
}
liftoff_log(LIFTOFF_DEBUG, "Disabling planes:%s", buf);
free(buf);
}
… // Proceed disabling the planes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a buffer though whenever a line is not meant to be output directly is super complicated though. :(
Is there not a more stream-like way to do that?
What could be an alternative is to have in the log.c file a single buffer that fills with liftoff_log_cnt and is reallocated when it becomes full. Finally it is prepended whenever liftoff_log is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have uploaded a new patch where per-device log buffers are created for continuous debug messages. It's a bit more involved for what it's doing in the end but that way all memory management for debugging is in a single log function.
I have added the change as a new commit in the end but if you are ok with the solution I can also replace this earlier commit with it.
plane.c
Outdated
@@ -30,6 +30,37 @@ static int guess_plane_zpos_from_type(struct liftoff_device *device, | |||
return 0; | |||
} | |||
|
|||
static void log_plane(struct liftoff_plane *plane) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Maybe we can ask users to run drm_info if we need this kind of information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point though for rapid development at least short term it makes sense to keep it in. It gives a good overview of only the relevant parts of the system without the need for other tools.
It also logs the zpos value that is not always a drm property.
On the other side I have just added a commit that logs the current state of all relevant planes on apply on an output. So you get an overview there as well.
So I'm fine either way.
output.c
Outdated
@@ -63,7 +66,15 @@ void output_log_layers(struct liftoff_output *output) { | |||
return; | |||
} | |||
|
|||
liftoff_log(LIFTOFF_DEBUG, "Layers on CRTC %"PRIu32":", output->crtc_id); | |||
liftoff_log(LIFTOFF_DEBUG, "\n== Apply request for output %"PRIu32" ==", output->crtc_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to add \n
chars in logging output, because some loggers might add a prefix (with the current time for instance) and this would break it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense. But then I would try to expand the API as in communicating when a line should be kind of a "header". Otherwise the output is really difficult to read with all the layer and plane information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See latest commit 6c1d2a1 with a proposal for such an API.
alloc.c
Outdated
@@ -571,6 +571,58 @@ static void log_reuse(struct liftoff_output *output) | |||
output->alloc_reuse++; | |||
} | |||
|
|||
static void log_plane_type_change(uint32_t base, uint32_t cmp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of this commit. When a lot of planes are present most will have the "overlay" type. IMHO plane IDs should be enough (and drm_info can help if more info is needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should just in general remove logging the planes being reset. It does not really give useful information besides a single output line with the ids of all planes on the system.
EDIT: ok it's a little bit more involved: it's all planes that are available for associating with a layer and are compatible with the output. I have to recheck that my latest commit does log all these correctly and then the information in the single line with is superfluous.
EDIT2: ok, it's even more involved. it's obviously not only planes compatible with the output. It is planes that were not associated with any layer at the start of apply or planes that had been but are compatible with the output.
On the whole this looks good, thanks for working on this! |
6c1d2a1
to
7908175
Compare
I've merged the following commits with minor edits:
|
Thanks, can I get some feedback on why the other commits weren't merged? |
I rebased the remaining commits in this branch: https://github.com/emersion/libliftoff/tree/subdiff-log The commits are untouched (ie. as close as possible to your version, just edited to make them build) and unreviewed. Feel free to check that I haven't messed anything up and start working again from there. As a general note, in the future it would make it easier for reviewers if commits are self-contained and only do one thing. I understand I've given feedback so you need to change things, but a clean history is important (see https://gitlab.freedesktop.org/wayland/weston/-/blob/master/CONTRIBUTING.md). For instance in this PR a commit adds To fix that, Added an explicit section about contributing in the README: 950e100 Now some more specific comments about the remaining unmerged patches (https://github.com/emersion/libliftoff/compare/subdiff-log):
What do you think? |
Thought about this again and what I need is a way to separate one burst of information from another one (i.e. per frame). In the default log I just use an additional empty line. Could we not just do that: print out an empty line?
Yea, as said I'm fine either way with the layer <-> plane logs in place. I will remove it.
Yea, that's nice. I will try it out.
On apply it currently prints all properties of output-compatible planes (in a condensed form for non-active ones). I found this to be quite helpful when debugging the changes or non-changes of layers. I would recommend this over only printing the type even though it takes more space. |
This won't look good when interleaved with the compositor and/or other libraries' debug logs. The compositor can print whatever it wants between frames so that'd be a better place to do it I think. This would allow for e.g.:
Wouldn't that just be the properties of the layers? |
On apply log the type of planes in the final assignment for a direct overview of the result.
Logigng the list of planes being disabled at the beginning of an apply does not really give useful information. Planes are disabled (and by that become in theory ready for layer-assignment) if they do not have a layer associated at the moment or if they are compatible with the output. That is uninteresting since in this list the subset of planes that are compatible with the output stay constant. And while the subset of planes being reset not compatible with the output might vary from apply to apply it is also of less interest since by definition they are not compatible with what the apply is about.
This adds a buffer struct and some utility functions for continously logging into a small buffer. In the end the buffer is flushed as a single line to the specified log channel.
It is helpful for debugging to know in which state the available planes on an output are when a layout is applied that leads to a change. For that log all planes that are compatible with the output. Currently disabled planes have multiple properties logged per line to keep the log short.
I have added some remaining commits. Not tested yet though.
They are the properties of the previous layer association if there was one. The problem is if you have for example the same layer association applied for a long time or a singular plane not associated for a long time and other debug output comes in between it is difficult to find in the log what the previous values were. |
I tested it now and it works fine:
|
liftoff_log(LIFTOFF_DEBUG, " Layer %p -> plane %"PRIu32, | ||
(void *)layer, plane->id); | ||
j++; | ||
liftoff_log(LIFTOFF_DEBUG, " [%zu] Layer %p -> plane %"PRIu32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the j
counter provide any useful information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just indexes the assignments. The question is if in the log at the end we should not compare j>0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah, printing a message when no assignments are established seems like a good idea.
The last commit still sounds too involved. I don't want to maintain a KMS pretty-printer. The compositor can easily dump this information if it really wants to. Otherwise the remaining commits look good. |
Working on gamescope's usage of libliftoff I need to get good debug logs without too much output at once.
For that repetition of unchanging output is minimized and the format of important output is improved.
Example of the output of one call to
liftoff_output_apply
after this PR has been merged: