Skip to content
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

Prototype web view of Tracer service information #43174

Merged
merged 6 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FWCore/Services/plugins/Tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ Tracer::Tracer(ParameterSet const& iPS, ActivityRegistry& iRegistry)
dumpEventSetupInfo_(iPS.getUntrackedParameter<bool>("dumpEventSetupInfo")) {
tracer::setupFile(iPS.getUntrackedParameter<std::string>("fileName"), iRegistry);

if (not iPS.getUntrackedParameter<bool>("useMessageLogger"))
return;
for (std::string& label : iPS.getUntrackedParameter<std::vector<std::string>>("dumpContextForLabels"))
dumpContextForLabels_.insert(std::move(label));

Expand Down Expand Up @@ -480,6 +482,8 @@ void Tracer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
->setComment(
"Prints info 3 times when an event setup cache is filled, before the lock, after the lock, and after "
"filling");
desc.addUntracked<bool>("useMessageLogger", true)
->setComment("If true, information is sent via the MessageLogger. Only use false if `fileName` is used.");
desc.addUntracked<std::string>("fileName", "")
->setComment("If fileName is given, write a compact representation of tracer info to the file.");
descriptions.add("Tracer", desc);
Expand Down
24 changes: 22 additions & 2 deletions FWCore/Services/plugins/tracer_setupFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace {
globalBeginRun = 5,
accessInputProcessBlock = 7,
beginProcessBlock = 8,
openFile = 9,
beginStream = 10,
beginJob = 11,
esSync = 12,
Expand Down Expand Up @@ -352,7 +353,6 @@ namespace edm::service::tracer {
auto const t = duration_cast<duration_t>(now() - beginTime).count();
sourceCtr.endConstruction = t;
});
//iRegistry.watchPreModuleDestruction([&moduleLabels](auto& md) { moduleLabels[md.id()] = ""; });

auto recordIndices = std::make_shared<std::vector<std::type_index>>();
iRegistry.watchEventSetupConfiguration(
Expand Down Expand Up @@ -417,6 +417,9 @@ namespace edm::service::tracer {
}
};
{
std::sort(moduleCtrDtrPtr->begin(), moduleCtrDtrPtr->end(), [](auto const& l, auto const& r) {
return l.beginConstruction < r.beginConstruction;
});
int id = 0;
for (auto const& ctr : *moduleCtrDtrPtr) {
if (ctr.beginConstruction != 0) {
Expand All @@ -432,6 +435,9 @@ namespace edm::service::tracer {
++id;
}
id = 0;
std::sort(moduleCtrDtrPtr->begin(), moduleCtrDtrPtr->end(), [](auto const& l, auto const& r) {
return l.beginDestruction < r.beginDestruction;
});
for (auto const& dtr : *moduleCtrDtrPtr) {
if (dtr.beginDestruction != 0) {
handleSource(dtr.beginDestruction);
Expand Down Expand Up @@ -598,6 +604,18 @@ namespace edm::service::tracer {
});
}
{
iRegistry.watchPreOpenFile([logFile, beginTime](std::string const&) {
auto const t = duration_cast<duration_t>(now() - beginTime).count();
auto msg = assembleMessage<Step::preSourceTransition>(
static_cast<std::underlying_type_t<Phase>>(Phase::openFile), 0, t);
logFile->write(std::move(msg));
});
iRegistry.watchPostOpenFile([logFile, beginTime](std::string const&) {
auto const t = duration_cast<duration_t>(now() - beginTime).count();
auto msg = assembleMessage<Step::postSourceTransition>(
static_cast<std::underlying_type_t<Phase>>(Phase::openFile), 0, t);
logFile->write(std::move(msg));
});
iRegistry.watchPreSourceEvent([logFile, beginTime](StreamID id) {
auto const t = duration_cast<duration_t>(now() - beginTime).count();
auto msg = assembleMessage<Step::preSourceTransition>(
Expand Down Expand Up @@ -746,6 +764,7 @@ namespace edm::service::tracer {
<< "# esSync " << Phase::esSync << "\n"
<< "# beginJob " << Phase::beginJob << "\n"
<< "# beginStream " << Phase::beginStream << "\n"
<< "# openFile " << Phase::openFile << "\n"
<< "# beginProcessBlock " << Phase::beginProcessBlock << "\n"
<< "# accessInputProcessBlock " << Phase::accessInputProcessBlock << "\n"
<< "# globalBeginRun " << Phase::globalBeginRun << "\n"
Expand All @@ -762,7 +781,8 @@ namespace edm::service::tracer {
<< "# endProcessBlock " << Phase::endProcessBlock << "\n"
<< "# writeProcessBlock " << Phase::writeProcessBlock << "\n"
<< "# endStream " << Phase::endStream << "\n"
<< "# endJob " << Phase::endJob << "\n\n";
<< "# endJob " << Phase::endJob << "\n"
<< "# destruction " << Phase::destruction << "\n\n";
oss << "# Step Symbol Entries\n"
<< "# -------------------------- ------ ------------------------------------------\n"
<< "# preSourceTransition " << Step::preSourceTransition
Expand Down
41 changes: 41 additions & 0 deletions FWCore/Services/scripts/README.md
Copy link
Contributor

Choose a reason for hiding this comment

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

@smuzaffar Are README files in scripts ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes , it is fine to have non-executable files in scripts directory. scram only copies executable files from scripts to cmssw/bin PATH.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Using edmTracerCompactLogViewer.py

## Introduction
The `edmTracerCompactLogViewer.py` is used to create a human understandable representation of the file generated by the `Tracer` service. Two representations are possible: text and interactive web.

## Creating Tracer file
To create a Tracer file, add the following to a cmsRun configuration
```python
process.add_(cms.Service("Tracer",
useMessageLogger=cms.untracked.bool(False)),
fileName=cms.untracked.string("<name of file>"))
```
Where `"<name of file>"` is whatever name you want to use for the file that will hold the Tracer output. The use of `useMessageLogger=cms.untracked.bool(False)` is optional but does
help avoid creating a large output from cmsRun.

## Processing Tracer file
The Tracer file can either be processed to output a human readable text output (similar to what the Tracer service does when `useMessageLogger==True`) or create a `data.js` file that
can be used by a web application.

### text output
Issue the shell command
```edmTracerCompactLogViewer.py <name of file>```

The script will output to the screen the text output. It is probably most useful to redirect the output to a file.

If you only want to see the framework transitions and not all the information about ED or ES modules, you can use the option `-f`.

### web output
Issue the shell command
```edmTracerCompactLogViewer.py -w <name of file>```

The script will outut a new file named `data.js`.

If you only want to see the framework transitions and not all the information about ED or ES modules, you can use the option `-f`.

#### setup web data

You will need to copy all the files in `$CMSSW_RELEASE_BASE/src/FWCore/Services/web` to a directory you can access from a web browser. Copy the `data.js` file
created by `edmTracerCompactLogViewer.py` into that same web browser accessible directory. Now you can have your web browser access the `index.html` file.

For directions on how to use the web application, see the [`FWCore/Services/web/README.md`](../web/README.md) file.
Loading