@@ -21,15 +21,15 @@ import React, {
2121 useState ,
2222} from 'react' ;
2323
24- import { Dictionary , Table , Vector , tableFromIPC } from 'apache-arrow' ;
24+ import { Table , tableFromIPC } from 'apache-arrow' ;
2525import { useContextMenu } from 'react-contexify' ;
2626
2727import { FlamegraphArrow } from '@parca/client' ;
28- import { useParcaContext , useURLState } from '@parca/components' ;
28+ import { useParcaContext } from '@parca/components' ;
2929import { USER_PREFERENCES , useCurrentColorProfile , useUserPreference } from '@parca/hooks' ;
3030import { ProfileType } from '@parca/parser' ;
3131import { getColorForFeature , selectDarkMode , useAppSelector } from '@parca/store' ;
32- import { getLastItem , type ColorConfig } from '@parca/utilities' ;
32+ import { type ColorConfig } from '@parca/utilities' ;
3333
3434import { ProfileSource } from '../../ProfileSource' ;
3535import { useProfileFilters } from '../../ProfileView/components/ProfileFilters/useProfileFilters' ;
@@ -38,12 +38,10 @@ import ContextMenuWrapper, {ContextMenuWrapperRef} from './ContextMenuWrapper';
3838import { FlameNode , RowHeight , colorByColors } from './FlameGraphNodes' ;
3939import { MemoizedTooltip } from './MemoizedTooltip' ;
4040import { TooltipProvider } from './TooltipContext' ;
41- import { useFilenamesList } from './useMappingList' ;
4241import { useScrollViewport } from './useScrollViewport' ;
4342import { useVisibleNodes } from './useVisibleNodes' ;
4443import {
4544 CurrentPathFrame ,
46- arrowToString ,
4745 extractFeature ,
4846 extractFilenameFeature ,
4947 getCurrentPathFrameData ,
@@ -84,6 +82,8 @@ interface FlameGraphArrowProps {
8482 setCurPath : ( path : CurrentPathFrame [ ] ) => void ;
8583 isHalfScreen : boolean ;
8684 mappingsListFromMetadata : string [ ] ;
85+ filenamesListFromMetadata : string [ ] ;
86+ colorBy : string ;
8787 compareAbsolute : boolean ;
8888 isFlameChart ?: boolean ;
8989 isRenderedAsFlamegraph ?: boolean ;
@@ -139,6 +139,9 @@ export const FlameGraphArrow = memo(function FlameGraphArrow({
139139 tooltipId = 'default' ,
140140 maxFrameCount,
141141 isExpanded = false ,
142+ mappingsListFromMetadata,
143+ filenamesListFromMetadata,
144+ colorBy,
142145} : FlameGraphArrowProps ) : React . JSX . Element {
143146 const [ highlightSimilarStacksPreference ] = useUserPreference < boolean > (
144147 USER_PREFERENCES . HIGHLIGHT_SIMILAR_STACKS . key
@@ -169,49 +172,17 @@ export const FlameGraphArrow = memo(function FlameGraphArrow({
169172 const currentColorProfile = useCurrentColorProfile ( ) ;
170173 const colorForSimilarNodes = currentColorProfile . colorForSimilarNodes ;
171174
172- const [ colorBy , _ ] = useURLState ( 'color_by' ) ;
173- const colorByValue = colorBy === undefined || colorBy === '' ? 'binary' : ( colorBy as string ) ;
174-
175- const filenamesList = useFilenamesList ( table ) ;
176-
177- const mappingsList = useMemo ( ( ) => {
178- // Read the mappings from the dictionary that contains all mapping strings.
179- // This is great, as might only have a dozen or so mappings,
180- // and don't need to read through all the rows (potentially thousands).
181- const mappingsDict : Vector < Dictionary > | null = table . getChild ( FIELD_MAPPING_FILE ) ;
182- const mappings =
183- mappingsDict ?. data
184- . map ( mapping => {
185- if ( mapping . dictionary == null ) {
186- return [ ] ;
187- }
188- const len = mapping . dictionary . length ;
189- const entries : string [ ] = [ ] ;
190- for ( let i = 0 ; i < len ; i ++ ) {
191- const fn = arrowToString ( mapping . dictionary . get ( i ) ) ;
192- entries . push ( getLastItem ( fn ) ?? '' ) ;
193- }
194- return entries ;
195- } )
196- . flat ( ) ?? [ ] ;
197-
198- // We add a EVERYTHING ELSE mapping to the list.
199- mappings . push ( '' ) ;
200-
201- // We sort the mappings alphabetically to make sure that the order is always the same.
202- mappings . sort ( ( a , b ) => a . localeCompare ( b ) ) ;
203- return mappings ;
204- } , [ table ] ) ;
175+ const colorByValue = colorBy === undefined || colorBy === '' ? 'binary' : colorBy ;
205176
206177 const filenameColors = useMemo ( ( ) => {
207- const colors = getFilenameColors ( filenamesList , isDarkMode , currentColorProfile ) ;
178+ const colors = getFilenameColors ( filenamesListFromMetadata , isDarkMode , currentColorProfile ) ;
208179 return colors ;
209- } , [ isDarkMode , filenamesList , currentColorProfile ] ) ;
180+ } , [ isDarkMode , filenamesListFromMetadata , currentColorProfile ] ) ;
210181
211182 const mappingColors = useMemo ( ( ) => {
212- const colors = getMappingColors ( mappingsList , isDarkMode , currentColorProfile ) ;
183+ const colors = getMappingColors ( mappingsListFromMetadata , isDarkMode , currentColorProfile ) ;
213184 return colors ;
214- } , [ isDarkMode , mappingsList , currentColorProfile ] ) ;
185+ } , [ isDarkMode , mappingsListFromMetadata , currentColorProfile ] ) ;
215186
216187 const colorByList = {
217188 filename : filenameColors ,
0 commit comments