firefox-devtools / profiler

Firefox Profiler — Web app for Firefox performance analysis
https://profiler.firefox.com
Mozilla Public License 2.0
1.18k stars 385 forks source link

Can't load perf profile. #4500

Open emilio opened 1 year ago

emilio commented 1 year ago

Trying to upload this profile taken with perf as per the instructions fails in all browsers. Maybe the profile is too big? But it seems to try to do JSON.parse which is suspicious.

┆Issue is synchronized with this Jira Task

emilio commented 1 year ago

The perf.data file is much smaller.

julienw commented 1 year ago

The error is indeed that it's too big, the underlying error I get (in the web console) is NS_ERROR_OUT_OF_MEMORY when trying to decode the file as UTF-8. We should try to use the stream API for this nowadays...

perf.data is smaller but doesn't have symbolication information as far as I know. (I also get a 403 Forbidden error when I try to access it BTW).

mstange commented 1 year ago

Once I publish the next version of samply, we should update our instructions to recommend samply load perf.data instead. @emilio, can you try that on your profile?

jingchangshi commented 1 year ago

It seems like if the file size of the perf.txt generated by perf script is larger than 500MB, Firefox profiler would report such error: Error: Unserializing the profile failed: SyntaxError: Unexpected end of JSON input which occurs at the source code reading the perf file.

Dhull442 commented 1 year ago

Can you try generating the perf data using --call-graph dwarf option. I was stuck at the same thing, but trying this sorted it out for me.

julienw commented 1 year ago

It seems like if the file size of the perf.txt generated by perf script is larger than 500MB, Firefox profiler would report such error: Error: Unserializing the profile failed: SyntaxError: Unexpected end of JSON input which occurs at the source code reading the perf file.

As you can see from this code, this codepath should be reached when it is not a perf profile. Therefore I believe that the text format you're using isn't recognized by our perf format detection. Can you please share the command you used as well as the perf script output with us?

Like markus mentioned above, you can also try loading perf.data directly using samply.

minzak commented 1 week ago

Once I publish the next version of samply, we should update our instructions to recommend samply load perf.data instead. @emilio, can you try that on your profile?

$ ./samply load perf.data 
Could not parse the input file as JSON: expected value at line 1 column 1
If this is a perf.data file, please use `samply import` instead.

And next i run: $ ./samply import perf.data cmd line: /usr/bin/perf record -e cycles --switch-events --sample-cpu --all-cpus --per-thread --timestamp --call-graph dwarf --aio -z -p 2628 --output=perf.data event cpu-clock Could not find segment or section overlapping the file offset range 0x1000..0x2000 Could not find segment or section overlapping the file offset range 0x26000..0x17b000 Local server listening at http://127.0.0.1:3000 Press Ctrl+C to stop. ^C

And result is: https://github.com/firefox-devtools/profiler/issues/5118