-
Notifications
You must be signed in to change notification settings - Fork 28
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
cli: Add new history command #1667
Conversation
src/runtime/database.cpp
Outdated
@@ -396,6 +398,7 @@ std::string Database::open(bool wait, bool memory, bool tty) { | |||
const char *sql_tag_job = "insert into tags(job_id, uri, content) values(?, ?, ?)"; | |||
const char *sql_get_tags = "select job_id, uri, content from tags where job_id=?"; | |||
const char *sql_get_all_tags = "select job_id, uri, content from tags"; | |||
const char *sql_get_runs_table = "select run_id, time, cmdline from runs order by time ASC"; |
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 could have gotten sqlite to process the time to appropriate datetime format like SELECT strftime('%Y-%m-%d %H:%M:%S', time / 1000000000, 'unixepoch')
, but decided to just default to the Time
Library
Line 55 in b468938
struct Time { |
tools/wake/main.cpp
Outdated
const auto runs = db.get_runs(); | ||
for (const auto run : runs) | ||
{ | ||
std::cout << run.time.as_string() << " " << run.cmdline << std::endl; |
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.
Decided to just output the string via std::cout
, but I could have used the Describe
library instead like we do with query_jobs :
Line 371 in b468938
void describe(const std::vector<JobReflection> &jobs, DescribePolicy policy, const Database &db) { |
JobReflection
but now a RunReflection
as well (could make a TableReflection
parent class that describe takes in for polymorphism). Would that type of change be of benefit and needed now?
Where else do we print timestamps? I'm not sure we need the fancier formatting you mentioned but was thinking we could just drop the subsecond precision. Most wake invocations take longer than a second so I don't think we would lose any meaningful precision. |
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.
+0.75 for dropping the subseconds. Even for jobs which do take less than a second, that's still not affecting that statistic directly (which is helpful to have), it's just saying when the job was launched, and I don't see much reason for that to matter. The big caveat I have is that subsecond resolution should still be visible when the --timeline
is zoomed in far enough (I think that's how it can be interacted with, right? Shows how little I use that feature.) -- if dropping the resolution at the struct level means the timeline gets quantized to seconds, or to a lesser degree if the JSON is affected in the same way, then we'd want to be a lot more hesitant about it.
src/runtime/database.cpp
Outdated
@@ -1584,6 +1589,25 @@ std::vector<JobTag> Database::get_tags() { | |||
return out; | |||
} | |||
|
|||
static std::vector<RunReflection> get_all_runs(const Database *db, sqlite3_stmt *query) { |
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.
... but here you're using that pattern already ...
(Side note, this seems to be the only implementation here which uses a separate static
function rather than having it all in the Database::
method.)
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.
Sounds good, yeah removed the static function ( I was just following the get_file_dependencies pattern:
Line 1626 in 4d62b1d
return get_all_file_dependencies(this, imp->get_file_dependency); |
int id; | ||
Time time; | ||
std::string cmdline; | ||
RunReflection() = default; |
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.
Do we need this constructor?
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.
We dont necessarily need it, but I used the constructor so its clearly understood what exactly I am querying:
https://github.com/sifive/wake/pull/1667/files#diff-ce97135c77b7c227bcd205cb4d3449133611307c21539f37b8c422bde9780252R1591-R1593
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 thats fair. It we don't have any style convention here thats fine.
@@ -639,7 +652,7 @@ int main(int argc, char **argv) { | |||
} | |||
|
|||
if (is_db_inspection) { | |||
inspect_database(clo, db, wake_cwd); |
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 argument was just dead code already?
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.
Yeah it was already dead code
I dont see --timeline really interacting with the --script command or calling |
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.
Some small spelling nits but otherwise LGTM.
int id; | ||
Time time; | ||
std::string cmdline; | ||
RunReflection() = default; |
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 thats fair. It we don't have any style convention here thats fine.
@@ -268,6 +279,7 @@ void print_help(const char *argv0) { | |||
<< " --last -l See --last-used" << std::endl | |||
<< " --last-used Capture all jobs used by last build. Regardless of cache" << std::endl | |||
<< " --last-executed Capture all jobs executed by the last build. Skips cache" << std::endl | |||
<< " --history Report the cmndline history of all wake commands recorded" << std::endl |
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.
<< " --history Report the cmndline history of all wake commands recorded" << std::endl | |
<< " --history Report the command-line history of all wake commands" << std::endl |
To match the spelling for --in
We don't need to specify "recorded" in the same way we don't specify that for things like "--list-outputs"
Added new
wake --history
command