Skip to content

Commit

Permalink
Profile.print: color Base/Core & packages. Make paths clickable (Juli…
Browse files Browse the repository at this point in the history
…aLang#55335)

Updated
## This PR
![Screenshot 2024-09-02 at 1 47
23 PM](https://github.com/user-attachments/assets/1264e623-70b2-462a-a595-1db2985caf64)


## master
![Screenshot 2024-09-02 at 1 49
42 PM](https://github.com/user-attachments/assets/14d62fe1-c317-4df5-86e9-7c555f9ab6f1)



Todo:
- [ ] ~Maybe drop the `@` prefix when coloring it, given it's obviously
special when colored~ If someone copy-pasted the profile into an issue
this would make it confusing.
- [ ] Figure out why `Profile.print(format=:flat)` is truncating before
the terminal width is used up
- [x] Make filepaths terminal links (even if they're truncated)
  • Loading branch information
IanButterworth authored Sep 4, 2024
1 parent e474e0b commit 48b40ac
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 64 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ Standard library changes
* `Profile.take_heap_snapshot` takes a new keyword argument, `redact_data::Bool`,
that is `true` by default. When set, the contents of Julia objects are not emitted
in the heap snapshot. This currently only applies to strings. ([#55326])
* `Profile.print()` now colors Base/Core/Package modules similarly to how they are in stacktraces.
Also paths, even if truncated, are now clickable in terminals that support URI links
to take you to the specified `JULIA_EDITOR` for the given file & line number. ([#55335])

#### Random

Expand Down
19 changes: 10 additions & 9 deletions stdlib/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ version = "1.11.0"
[[deps.JuliaSyntaxHighlighting]]
deps = ["StyledStrings"]
uuid = "dc6e5ff7-fb65-4e79-a425-ec3bc9c03011"
version = "1.11.0"
version = "1.12.0"

[[deps.LLD_jll]]
deps = ["Artifacts", "Libdl", "Zlib_jll", "libLLVM_jll"]
uuid = "d55e3150-da41-5e91-b323-ecfd1eec6109"
version = "16.0.6+4"
version = "18.1.7+2"

[[deps.LLVMLibUnwind_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down Expand Up @@ -113,12 +113,12 @@ version = "1.11.0+1"
[[deps.LibUV_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "183b4373-6708-53ba-ad28-60e28bb38547"
version = "2.0.1+16"
version = "2.0.1+17"

[[deps.LibUnwind_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "745a5e78-f969-53e9-954f-d19f2f74f4e3"
version = "1.8.1+0"
version = "1.8.1+1"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand Down Expand Up @@ -163,7 +163,7 @@ version = "1.2.0"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.26+2"
version = "0.3.28+2"

[[deps.OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
Expand All @@ -190,6 +190,7 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
version = "1.11.0"

[[deps.Profile]]
deps = ["StyledStrings"]
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
version = "1.11.0"

Expand Down Expand Up @@ -223,7 +224,7 @@ version = "1.11.0"
[[deps.SparseArrays]]
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
version = "1.11.0"
version = "1.12.0"

[[deps.Statistics]]
deps = ["LinearAlgebra"]
Expand All @@ -242,7 +243,7 @@ version = "1.11.0"
[[deps.SuiteSparse_jll]]
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
version = "7.7.0+0"
version = "7.8.0+0"

[[deps.TOML]]
deps = ["Dates"]
Expand Down Expand Up @@ -281,12 +282,12 @@ version = "2.2.5+0"
[[deps.libLLVM_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a"
version = "16.0.6+4"
version = "18.1.7+2"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.8.0+1"
version = "5.11.0+0"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down
6 changes: 6 additions & 0 deletions stdlib/Profile/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name = "Profile"
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
version = "1.11.0"

[deps]
StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b"

[compat]
StyledStrings = "1.11.0"

[extras]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Profile/src/Allocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ end
function flat(io::IO, data::Vector{Alloc}, cols::Int, fmt::ProfileFormat)
fmt.combine || error(ArgumentError("combine=false"))
lilist, n, m, totalbytes = parse_flat(fmt.combine ? StackFrame : UInt64, data, fmt.C)
filenamemap = Dict{Symbol,String}()
filenamemap = Profile.FileNameMap()
if isempty(lilist)
warning_empty()
return true
Expand Down
Loading

0 comments on commit 48b40ac

Please sign in to comment.