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

[deploy preview] Experimental UI for flows #5190

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
85 changes: 85 additions & 0 deletions src/actions/profile-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import {
getThreadSelectorsFromThreadsKey,
selectedThreadSelectors,
} from 'firefox-profiler/selectors/per-thread';
import {
getProfileFlowInfo,
getStringTablePerThread,
getFullMarkerListPerThread,
} from 'firefox-profiler/selectors/flow';
import {
getAllCommittedRanges,
getImplementationFilter,
Expand Down Expand Up @@ -79,11 +84,13 @@ import type {
TableViewOptions,
SelectionContext,
BottomBoxInfo,
IndexIntoFlowTable,
} from 'firefox-profiler/types';
import {
funcHasDirectRecursiveCall,
funcHasRecursiveCall,
} from '../profile-logic/transforms';
import { computeMarkerFlows } from '../profile-logic/marker-data';
import { changeStoredProfileNameInDb } from 'firefox-profiler/app-logic/uploaded-profiles-db';
import type { TabSlug } from '../app-logic/tabs-handling';
import { intersectSets } from 'firefox-profiler/utils/set';
Expand Down Expand Up @@ -999,6 +1006,53 @@ export function showProvidedTracks(
};
}

export function showProvidedThreads(
threadsToShow: Set<ThreadIndex>
): ThunkAction<void> {
return (dispatch, getState) => {
const globalTracks = getGlobalTracks(getState());
const localTracksByPid = getLocalTracksByPid(getState());

const globalTracksToShow: Set<TrackIndex> = new Set();
const localTracksByPidToShow: Map<Pid, Set<TrackIndex>> = new Map();

for (const [globalTrackIndex, globalTrack] of globalTracks.entries()) {
if (globalTrack.type !== 'process') {
continue;
}
const { mainThreadIndex, pid } = globalTrack;
if (mainThreadIndex !== null && threadsToShow.has(mainThreadIndex)) {
globalTracksToShow.add(globalTrackIndex);
}
const localTracks = localTracksByPid.get(pid);
if (localTracks === undefined) {
continue;
}

for (const [localTrackIndex, localTrack] of localTracks.entries()) {
if (localTrack.type !== 'thread') {
continue;
}
if (threadsToShow.has(localTrack.threadIndex)) {
const localTracksToShow = localTracksByPidToShow.get(pid);
if (localTracksToShow === undefined) {
localTracksByPidToShow.set(pid, new Set([localTrackIndex]));
} else {
localTracksToShow.add(localTrackIndex);
}
globalTracksToShow.add(globalTrackIndex);
}
}
}

dispatch({
type: 'SHOW_PROVIDED_TRACKS',
globalTracksToShow,
localTracksByPidToShow,
});
};
}

/**
* This action makes the tracks that are provided hidden.
*/
Expand Down Expand Up @@ -1680,6 +1734,37 @@ export function changeHoveredMarker(
};
}

export function changeActiveFlows(activeFlows: IndexIntoFlowTable[]): Action {
return {
type: 'CHANGE_ACTIVE_FLOWS',
activeFlows,
};
}

export function activateFlowsForMarker(
threadIndex: ThreadIndex,
markerIndex: MarkerIndex
): ThunkAction<void> {
console.log('yo');
return (dispatch, getState) => {
console.log('aha');
const profileFlowInfo = getProfileFlowInfo(getState());
const stringTablePerThread = getStringTablePerThread(getState());
const fullMarkerListPerThread = getFullMarkerListPerThread(getState());
console.log('aha2');
const flows =
computeMarkerFlows(
threadIndex,
markerIndex,
profileFlowInfo,
stringTablePerThread,
fullMarkerListPerThread
) ?? [];
console.log({ flows });
dispatch(changeActiveFlows(flows));
};
}

/**
* This action is used when the user right clicks a marker, and is especially
* used to display its context menu.
Expand Down
7 changes: 7 additions & 0 deletions src/app-logic/url-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ type BaseQuery = {|
timelineType: string,
sourceView: string,
assemblyView: string,
activeFlows: string,
...FullProfileSpecificBaseQuery,
...ActiveTabProfileSpecificBaseQuery,
...OriginsProfileSpecificBaseQuery,
Expand Down Expand Up @@ -436,6 +437,9 @@ export function getQueryStringFromUrlState(urlState: UrlState): string {
query = (baseQuery: MarkersQueryShape);
query.markerSearch =
urlState.profileSpecific.markersSearchString || undefined;
query.activeFlows =
encodeUintArrayForUrlComponent(urlState.profileSpecific.activeFlows) ||
undefined;
break;
case 'network-chart':
query = (baseQuery: NetworkQueryShape);
Expand Down Expand Up @@ -578,6 +582,8 @@ export function stateFromLocation(
implementation = query.implementation;
}

const activeFlows = decodeUintArrayFromUrlComponent(query.activeFlows ?? '');

const transforms = {};
if (selectedThreadsKey !== null) {
transforms[selectedThreadsKey] = parseTransforms(query.transforms);
Expand Down Expand Up @@ -658,6 +664,7 @@ export function stateFromLocation(
transforms,
sourceView,
assemblyView,
activeFlows,
isBottomBoxOpenPerPanel,
timelineType: validateTimelineType(query.timelineType),
full: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { LocalizedErrorBoundary } from './ErrorBoundary';
import { ProfileCallTreeView } from 'firefox-profiler/components/calltree/ProfileCallTreeView';
import { MarkerTable } from 'firefox-profiler/components/marker-table';
import { StackChart } from 'firefox-profiler/components/stack-chart/';
import { MarkerChart } from 'firefox-profiler/components/marker-chart/';
import { MarkerChartTab } from 'firefox-profiler/components/marker-chart-tab';
import { NetworkChart } from 'firefox-profiler/components/network-chart/';
import { FlameGraph } from 'firefox-profiler/components/flame-graph/';
import { JsTracer } from 'firefox-profiler/components/js-tracer/';
Expand Down Expand Up @@ -115,7 +115,7 @@ class ProfileViewerImpl extends PureComponent<Props> {
calltree: <ProfileCallTreeView />,
'flame-graph': <FlameGraph />,
'stack-chart': <StackChart />,
'marker-chart': <MarkerChart />,
'marker-chart': <MarkerChartTab />,
'marker-table': <MarkerTable />,
'network-chart': <NetworkChart />,
'js-tracer': <JsTracer />,
Expand Down
8 changes: 4 additions & 4 deletions src/components/app/DetailsContainer.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.DetailsContainer .layout-pane > * {
.DetailsContainer > .layout-pane > * {
width: 100%;
height: 100%;
box-sizing: border-box;
}

.DetailsContainer .layout-pane:not(.layout-pane-primary) {
.DetailsContainer > .layout-pane:not(.layout-pane-primary) {
max-width: 600px;
}

Expand All @@ -15,12 +15,12 @@
position: unset;
}

.DetailsContainer .layout-splitter {
.DetailsContainer > .layout-splitter {
border-top: 1px solid var(--grey-30);
border-left: 1px solid var(--grey-30);
background: var(--grey-10); /* Same background as sidebars */
}

.DetailsContainer .layout-splitter:hover {
.DetailsContainer > .layout-splitter:hover {
background: var(--grey-30); /* same as the border above */
}
Loading