Skip to content

Commit

Permalink
feat: highlight expensive compute cranks in slog-to-diagram
Browse files Browse the repository at this point in the history
  - show promise resolution state
  - add @startuml , @enduml
  • Loading branch information
dckc committed Oct 14, 2021
1 parent 7a79b3a commit a923083
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/SwingSet/tools/slog-to-diagram.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ async function* slogToDiagram(entries) {
}
case 'notify': {
const [_tag, resolutions] = kd;
for (const [kp] of resolutions) {
for (const [kp, { state }] of resolutions) {
dInfo = {
time: entry.time,
elapsed: entry.time - tBlock,
vatID: entry.vatID,
method: '@',
method: state,
target: kp,
};
arrival.set(`R${kp}`, dInfo);
Expand Down Expand Up @@ -137,6 +137,8 @@ async function* slogToDiagram(entries) {
}
}

yield '@startuml slog\n';

for (const [vatID, _info] of vatInfo) {
yield `control ${vatID}\n`;
}
Expand All @@ -156,20 +158,25 @@ async function* slogToDiagram(entries) {
const t = Math.round(elapsed * 1000) / 1000;
// yield `autonumber ${blockHeight}.${t}\n`;
yield `autonumber ${t}\n`;
const showCompute = compute && compute > 50000 ? compute : '';
if (typeof ref === 'object') {
yield `[-> ${dest} : ${target}.${method}(${argSize ||
''}) ${showCompute}\n`;
yield `[-> ${dest} : ${target}.${method}(${argSize || ''})\n`;
if (compute && compute > 50000) {
yield `note right\n${compute.toLocaleString()} compute\nend note\n`;
}
continue;
}
if (!departure.has(ref)) {
console.warn({ ref });
continue;
}
const { vatID: src } = departure.get(ref);
yield `${src} -> ${dest} : ${target}.${method}(${argSize ||
''}) ${showCompute}\n`;
yield `${src} -> ${dest} : ${target}.${method}(${argSize || ''})\n`;
if (compute && compute > 50000) {
yield `note right\n${compute.toLocaleString()} compute\nend note\n`;
}
}

yield '@enduml\n';
}

/**
Expand Down

0 comments on commit a923083

Please sign in to comment.