Skip to content

Introduce persistent process tree#1349

Closed
251 wants to merge 2 commits intoklee:masterfrom
251:persistent_ptree
Closed

Introduce persistent process tree#1349
251 wants to merge 2 commits intoklee:masterfrom
251:persistent_ptree

Conversation

@251
Copy link
Contributor

@251 251 commented Nov 18, 2020

This PR adds 3 features:

1. "Optional" process tree

Instead of always maintaining the process tree, the tree now will only be created when it is necessary (when random-path is used or -write-ptree is active (see below)). Otherwise a tree stub is used that does nothing (NoopPTree).

2. Introduce persistent process tree with -write-ptree

Going further with #1343 and #1348 this PR actually creates an SQLite database and writes the process tree and its attached information to disk.

3. New tool: klee-ptree

This is a proof-of-concept implementation to show various statistics, e.g. branch information and information about the termination types. It also can be used to dump the tree in .dot format to generate png/svg files. I'd recommend svg as it shows tooltips with state id, asm line, branch type, ....

> klee-ptree branches klee-out-1/ptree.db                                                                                                                                        branch type,count
Alloc,0
Br,55055
Call,0
Exact,0
Free,0
Getval,0
Memop,0
Realloc,0
Switch,27091
IndirectBr,0
...

> klee-ptree terminations klee-out-1/ptree.db                                                                                                                                          
termination type,count
Exit,2230
Interrupted,48352
OutOfMemory,31547
Ptr,4
External,14
...

ptree


Thank you for contributing to KLEE. We are looking forward to reviewing your PR. However, given the small number of active reviewers and our limited time, it might take a while to do so. We aim to get back to each PR within one month, and often do so within one week.

To help expedite the review please ensure the following, by adding an "x" for each completed item:

  • The PR addresses a single issue. In other words, if some parts of a PR could form another independent PR, you should break this PR into multiple smaller PRs.
  • There are no unnecessary commits. For instance, commits that fix issues with a previous commit in this PR are unnecessary and should be removed (you can find documentation on squashing commits here).
  • Larger PRs are divided into a logical sequence of commits.
  • Each commit has a meaningful message documenting what it does.
  • The code is commented. In particular, newly added classes and functions should be documented.
  • The patch is formatted via clang-format (see also git-clang-format for Git integration). Please only format the patch itself and code surrounding the patch, not entire files. Divergences from clang-formatting are only rarely accepted, and only if they clearly improve code readability.
  • Add test cases exercising the code you added or modified. We expect system and/or unit test cases for all non-trivial changes. After you submit your PR, you will be able to see a Codecov report telling you which parts of your patch are not covered by the regression test suite. You will also be able to see if the Travis CI and Cirrus CI tests have passed. If they don't, you should examine the failures and address them before the PR can be reviewed.
  • Spellcheck all messages added to the codebase, all comments, as well as commit messages.

@251 251 force-pushed the persistent_ptree branch from c7a59bc to cfb885c Compare November 18, 2020 21:58
@codecov
Copy link

codecov bot commented Nov 19, 2020

Codecov Report

Merging #1349 (b8c6427) into master (fc83f06) will decrease coverage by 0.44%.
The diff coverage is 56.04%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1349      +/-   ##
==========================================
- Coverage   70.48%   70.04%   -0.44%     
==========================================
  Files         154      161       +7     
  Lines       18870    19312     +442     
  Branches     4424     4610     +186     
==========================================
+ Hits        13301    13528     +227     
- Misses       3654     3752      +98     
- Partials     1915     2032     +117     
Files Coverage Δ
lib/Core/Executor.cpp 76.47% <100.00%> (+0.03%) ⬆️
lib/Core/Executor.h 77.27% <ø> (ø)
lib/Core/Searcher.h 100.00% <ø> (ø)
lib/Core/SpecialFunctionHandler.cpp 73.55% <100.00%> (-0.09%) ⬇️
lib/Core/UserSearcher.cpp 88.67% <100.00%> (+0.67%) ⬆️
tools/klee-ptree/DFSVisitor.h 100.00% <100.00%> (ø)
tools/klee-ptree/Tree.h 100.00% <100.00%> (ø)
tools/klee/main.cpp 64.72% <ø> (ø)
lib/Core/PTree.h 96.15% <96.15%> (-3.85%) ⬇️
lib/Core/Searcher.cpp 78.12% <58.33%> (-0.90%) ⬇️
... and 6 more

@251 251 force-pushed the persistent_ptree branch from cfb885c to 89a3339 Compare November 19, 2020 09:31
@251 251 force-pushed the persistent_ptree branch 5 times, most recently from 92c0753 to 1d4ef17 Compare November 19, 2020 16:24
@251
Copy link
Contributor Author

251 commented Nov 19, 2020

Any ideas what's wrong with the MacOS build?

Copy link
Contributor

@kren1 kren1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this and does clean up termination types nicely

@251 251 marked this pull request as draft December 2, 2020 14:10
@ccadar
Copy link
Contributor

ccadar commented Jun 29, 2022

@251 I believe this PR is now outdated and we can close it? (#1348 was merged)

@251
Copy link
Contributor Author

251 commented Jun 29, 2022

It's currently outdated but I'd update it after the termination stuff is merged (e.g. #1465).

@251 251 force-pushed the persistent_ptree branch 5 times, most recently from 2dee72b to 2ac759d Compare March 31, 2023 22:22
@251 251 marked this pull request as ready for review March 31, 2023 22:23
@251 251 force-pushed the persistent_ptree branch from 2ac759d to 97a3958 Compare March 31, 2023 22:28
@251
Copy link
Contributor Author

251 commented Apr 1, 2023

@ccadar @MartinNowack Ready for review. Slowly we get the puzzle pieces together...

@ccadar
Copy link
Contributor

ccadar commented Apr 1, 2023

Thanks, Frank! An exciting addition, I'll try to take a look soon.

@251 251 changed the title Introduce persistent process tree (requires #1348) Introduce persistent process tree Apr 17, 2023
@251 251 force-pushed the persistent_ptree branch from 97a3958 to 059d25b Compare May 24, 2023 14:25
Copy link
Contributor

@ccadar ccadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a few small comments.

@ccadar
Copy link
Contributor

ccadar commented Jul 8, 2023

@251 I took a look, and left a few small comments. In addition to those, I think it would be really useful to add some documentation to the webpage.

Let's merge this soon, it's a great addition!

@251 251 force-pushed the persistent_ptree branch 3 times, most recently from ce10f31 to d43c1fe Compare July 9, 2023 12:52
@251 251 force-pushed the persistent_ptree branch 2 times, most recently from 8d3959e to dbed3af Compare October 3, 2023 16:23
@251
Copy link
Contributor Author

251 commented Oct 3, 2023

@ccadar Done.

@ccadar ccadar mentioned this pull request Oct 30, 2023
8 tasks
@ccadar
Copy link
Contributor

ccadar commented Nov 23, 2023

@251 thanks again for this useful addition. It looks fine, and it's quite modular, so let's merge it!
But can you first add some documentation to the website? The comments you have at the beginning of this PR and in the commit messages (as well as the example at #951 (comment)) would be enough.

In addition, I would like to take this opportunity to propose renaming PTree to ETree, from "Execution Tree", which is the term that we and others are already using in papers to refer to this tree. Furthermore, we use "process" in the documentation in the UNIX sense, so overloading the term like this is particularly confusing. To be clear: I am proposing this for the user-facing options and documentation (e.g., rename write-ptree to write-etree), but if you want to add a refactoring patch changing PTree to ETree in the code, I'd be happy to accept it, as it would be nice to be consistent. Otherwise, we can do that later.

Copy link
Contributor

@danielschemmel danielschemmel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on the code

@251 251 force-pushed the persistent_ptree branch 2 times, most recently from d821fa3 to 08d82bb Compare November 24, 2023 16:43
251 added 2 commits November 24, 2023 18:12
Introduce three different kinds of process trees:
1. Noop: does nothing (e.g. no allocations for DFS)
2. InMemory: same behaviour as before (e.g. RandomPathSearcher)
3. Persistent: similar to InMemory but writes nodes to ptree.db
     and tracks information such as branch type, termination
     type or source location (asm) in nodes. Enabled with
     -write-ptree

ptree.db files can be analysed/plotted with the new "klee-ptree"
tool.
@251
Copy link
Contributor Author

251 commented Nov 24, 2023

@ccadar

But can you first add some documentation to the website?

klee/klee.github.io#369

Otherwise, we can do that later.

We can do it independently from this PR but it should be consistent everywhere (code, docs, options).

@danielschemmel
Thanks for the comments, I changed the PR accordingly.

@ccadar
Copy link
Contributor

ccadar commented Nov 24, 2023

Thanks for the documentation, @251 . Can you at least just rename the user-facing options (--write-ptree, ptree.db) here? Seems to be the right time to do it, as this is the PR introducing them. Thanks!

@251
Copy link
Contributor Author

251 commented Nov 24, 2023

Seems to be the right time to do it, as this is the PR introducing them.

I think that would be rather confusing as we have no such thing as an "etree". I'd propose to keep it for now, choose a proper name (etree, xtree, extree, ...) and than change it consistently everywhere.

@ccadar
Copy link
Contributor

ccadar commented Nov 24, 2023

So what name do you suggest? I think "execution tree" (with the short form "etree") is the right terminology, as this is what we and others already use in papers. Why introduce users to the concept of ptrees if we will change it anyway? (what we have in the code is a different matter, although I agree we should be consistent and do the rename there too)

@251
Copy link
Contributor Author

251 commented Nov 24, 2023

So what name do you suggest?

xtree/extree/etree

Why introduce users to the concept of ptrees

There is still time to fix it properly before the next release.

@ccadar
Copy link
Contributor

ccadar commented Nov 27, 2023

I still think that the best time to decide on the terminology is when we introduce it. But I understand if you don't want to spend more time on this PR, and I offer to add a commit to this branch with the renaming. Let's decide on a name: I kind of like your suggestion for XTree / xtree, should we go with that? (But I'm also happy with ETree/etree, or anything other short form for "execution tree".)

@danielschemmel
Copy link
Contributor

I would like to suggest just using the full name ExecutionTree with full arguments like -write-execution-tree. There is not that much to gain by saving a few keystrokes.

@251
Copy link
Contributor Author

251 commented Nov 27, 2023

Those are all great suggestions for a follow-up PR.

@ccadar
Copy link
Contributor

ccadar commented Nov 27, 2023

@251 It should be as part of the same PR, but I offered to write that patch.
I think @danielschemmel's suggestion is reasonable, but perhaps I would go with ExecutionTree, --write-exec-tree, and exec_tree.db. Sounds good?

@251
Copy link
Contributor Author

251 commented Nov 27, 2023

Again, I'd do it but not as part of this PR. It makes no sense to blow this already large PR up with some unimportant naming stuff. You cannot just rename a flag and a file, you'd also have to change all the error messages, the command line switches/categories, the code comments in several tools, the documentation... It is completely unrelated and no one cared about naming for 15 years - or even the last 3 years since this PR is open.

@ccadar
Copy link
Contributor

ccadar commented Nov 27, 2023

This is the first time we are introducing this to users; this is why in my opinion the key thing is the user-facing terminology, and this is all I asked for. But I agree having everything in sync is desirable. I also don't think renaming will take that long, but let me give it a try first :)

@MartinNowack
Copy link
Contributor

I would like to break the tie on this. In general I see good arguments from all sides, so thank you for this fruitful discussion.

Here are my two cents on this: The current discussion is around user-facing changes and they should be addressed eventually.

But, this PR is quite old - more than 3 years and we should have managed to merge this one (quite some time) earlier. This PR is quite big as it is. Reviewing it again is quite time consuming. There have been already many change requests for this PR and it has evolved over time.

In general, PRs are changing the development branch of KLEE and it's not part of a release yet. Therefore, I assume that people should be more ok with inconsistencies and breakages in a development branch.

For those reasons and not to postpone further PRs that much longer, I would like to merge this as is.
It has sufficient reviews and was tested multiple times and runs internally.

We can provide a more consistent experience for the end user as a follow-up PR.

What are your thoughts on this?

@MartinNowack
Copy link
Contributor

And I forgot the main important point: it provides some nice features 😄

@ccadar
Copy link
Contributor

ccadar commented Dec 12, 2023

@MartinNowack I agree with this. But since I have actually implemented the change, so I'll just push it shortly, most likely tonight.

@ccadar
Copy link
Contributor

ccadar commented Dec 13, 2023

Extended with the rename in #1674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants