-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PerfLog #3974
Add PerfLog #3974
Conversation
src/core/PerfLog.cpp
Outdated
* | ||
*/ | ||
|
||
//#ifdef LMMS_DEBUG_PERFLOG |
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 think LMMS_DEBUG_PERFLOG
guard should be re-enabled here and added into PerfLog.h
. It will fix Windows build, too.
CMakeLists.txt
Outdated
@@ -68,6 +68,7 @@ OPTION(WANT_VST_NOWINE "Include partial VST support (without wine)" OFF) | |||
OPTION(WANT_WINMM "Include WinMM MIDI support" OFF) | |||
OPTION(WANT_QT5 "Build with Qt5" OFF) | |||
OPTION(WANT_DEBUG_FPE "Debug floating point exceptions" OFF) | |||
OPTION(WANT_DEBUG_PERFLOG "Log task performance" ON) |
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.
Should the default value be OFF
, like FPE debugging?
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.
OFF sounds right to me, too.
|
||
#ifndef PERFLOG_H | ||
#define PERFLOG_H | ||
|
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.
So lmmsconfig.h
should be included in this file.
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.
Yup, to be sure. Most files that include this will probably include lmmsconfig.h
too, but who knows where we'll bump into an exception from the rule.
A lot of code is inconsistent with our coding convention, too. |
Note that this PR doesn't make any usage of |
@PhysSong I went for simplicity here. And for the fact that no code is added if the option is not activated. If you want to extend and/or configure it, a singleton would be better. If you want to make it an aspect, this is also possible. Both can be added later, if there is a need (which I don't really foresee for now). OTOH, I may see a need to show cumulated times. And eventually to have it also working on Windows. |
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.
@gi0e5b06 I'm not quite able to relate to the design choices made in writing the PerfLog
class. I find looking up instances of timers in static functions using a QHash
object to be a rather strange way of approaching a problem that object oriented programming already solved for us.
The class could be a lot simpler, and should look something like this instead:
class PerfLog
{
public:
void begin(const QString& name);
void end();
private:
clock_t c;
tms t;
QString name;
};
Alternatively, begin
could become the class's constructor.
It can then be used like so:
PerfLogTimer timer;
timer.begin();
longRunningTask();
time.end();
Also, a better name is probably something like PerfLogTimer
, since an instance of the class is a timer, not a log.
src/core/PerfLog.cpp
Outdated
PerfLog::Entry e; | ||
PerfLog::Entry b = s_running.take(what); | ||
// | task | real | user | syst | ||
qWarning("PERFLOG | %20s | %7.2f | %7.2f | %7.2f", |
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.
Can we use an output format close to the one originally proposed by @softrabbit? It includes labels for better understanding of the output:
Real Time: %.2f, User Time %.2f, System Time %.2f
src/core/PerfLog.cpp
Outdated
PerfLog::Entry::Entry() | ||
{ | ||
c = times(&t); | ||
if (c == -1) { qFatal("PerfLogEntry: init failed"); } |
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 don't think using qFatal
is reasonable here or in line 52. If times
fails, we can't mesaure the time here, but it doesn't mean we need to crash LMMS.
Totally agree. I thought about something similar:
|
|
That sounds speculative to me. Do you have an example use-case to back this statement? I can't think of any situation where this is necessary without a major design flaw being at fault. In #3882, the PR that spawned this class,
Crashing the program is not the only way of making the developer aware of a problem.
Let's worry about space when we actually add more columns. Let's worry about ease of parsing when the need for parsing it arises. For now, humans read these logs, so that's who it should be made readable for. |
I disagree. The code formatting is actually quite clean and it doesn't seem to break any obvious rules. There are some conventions that need to die (such as 4 spaces between functions), but other than that, what's wrong with the formatting? |
... oh I see them now. A few misplaced spaces. The |
Since @gi0e5b06 has no intentions on working together on our PRs, this should be coded by the devs commenting or closed out. @PhysSong made some fixes. @lukas-w I think you're next. If you prefer not to write this feature in this manner, we can also close it out. It should be superseding @softrabbit's #3882 so that should be decided as well. Last, I think at least the basic benchmarks are useful enough to have on all the time. I haven't seen any valid arguments against them and there shouldn't be a severe CPU hit. Optionally we could move the benchmarks to a UI setting and CLI flag, but I don't think this belongs in the build system. Bench marking should be possible without recompilation. |
@tresf I made the suggested changes. I also split the class into We should probably check for redundancies with |
What about Mac? I saw you had this enabled for Linux only. It seems |
# Conflicts: # CMakeLists.txt
Just pushed to the wrong remote. Removed via 7615c86. |
Renamed |
Mistook |
src/lmmsconfig.h.in
Outdated
@@ -26,6 +26,7 @@ | |||
#cmakedefine LMMS_HAVE_SF_COMPLEVEL | |||
|
|||
#cmakedefine LMMS_DEBUG_FPE | |||
#cmakedefine LMMS_DEBUG_PERFLOG |
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.
@lukas-w This line should be removed now, right?
@@ -250,7 +251,6 @@ IF(WANT_SDL AND NOT LMMS_HAVE_SDL2) | |||
IF(NOT SDL_INCLUDE_DIR) | |||
SET(SDL_INCLUDE_DIR "${CMAKE_FIND_ROOT_PATH}/include") | |||
ENDIF() | |||
|
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.
This newline change seems meaningless.
include/PerfLog.h
Outdated
/* | ||
* PerfLog.h - Small performance logger | ||
* | ||
* Copyright (c) 2017 gi0e5b06 |
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.
Is this line enough as copyright information?
When/If this PR is merged, who should get credit? |
@PhysSong Well 6a809a5 was pretty close to a rewrite, there's hardly anything left from the original code by @gi0e5b06. What about just writing Slightly off-topic, but would it be a good idea to license single files as e.g. MIT, while releasing LMMS as a whole as GPL? It could keep potentially re-usable components under a more liberal license, so they can be used by other projects more freely (such as the qt5 x11 embed module, which I moved to its own repository partly for this reason). The only downside I can see is that contributors may not be expect part of their work to be licensed differently when touching those files. |
Important and valuable ones, yes. This guy is a boilerplate class though, common on projects like ours. I don't see it as falling into that category, but yes, offering a more liberal license can always help. If it's bundled, we may want to fly a larger warning/disclaimer, such as through a README.md, etc. |
I guess we can merge this after reverting unnecessary changes and updating copyright statement. Are there any other things left? |
@lukas-w Is this ready for merge? |
@PhysSong Yup 👍 |
As it is now, this PR is quite useless but it is not intrusive and so not harmful to the project. I don't think anyone will use it anyway. As for the copyright, you can not use LMMS Developers because it is not a definite entity. You should credit the contributors, starting with softrabbit (but excluding me, as I don't want to be associated with code of that quality). |
@gi0e5b06 You've consistently refused to help with any contributions (including this PR), so this time the team has actually gone through the trouble of getting some of your code into a merge-able state and integrating it into the project. Your reaction to this being an open devaluation of the work done is an insult to the team. I've taken the liberty of putting an end to your presumptious behaviour here by blocking you from the tracker for now. Feel free to reach out to me or other admins via Discord or E-Mail if you feel like this should be reverted. |
Add `PerfTime` class representing a point in CPU time and `PerfLogTimer`, used for measuring and logging a time period. Used in `ProjectRenderer::run()
Add the perflog implementation as discussed in #3882.
I did not write this code. Instead I've cherry-picked the commit from a rouge branch. @softrabbit can you please decide if this is worth superseding #3882 or not and make recommends, merge, etc?
Edit: Please push directly to this branch with changes!