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

Precompile Markdown parsing AND printing #55752

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

PallHaraldsson
Copy link
Contributor

@PallHaraldsson PallHaraldsson commented Sep 12, 2024

Improvement on top of #55715, replacing it, to also precompile printing. And then also fixing parsing and using regression for #55706.

@PallHaraldsson
Copy link
Contributor Author

[This shouldn't need a full CI, since a trivial tested add-on.]

This is likely the better backport target for 1.11, assuming it only adds to pkgimage (i.e. not the sysimage), not concerned about bloating it, a bit.

This could precompile a bit more for stdout, not just stderr, but unsure how to do that, also likely not a large improvement. It also misses some tags, for images, not as important, maybe easy to add, but I don't want this to hold up releasing 1.11. Can always be added later...

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Sep 12, 2024

Julia support the CommonMark extension: https://www.markdownguide.org/extended-syntax/ but is it the only one, e.g. no R Markdown allowed? The parser will not fail at any extension, just ignore it, so might be ok to include here, for later compatibility?

I was looking into what basic tags to add here, and what more, maybe, I see we likely do not support latest 2024 CommonMark https://spec.commonmark.org/0.31.2/changes.html since I found in the code: https://spec.commonmark.org/0.19/#absolute-uri

@KristofferC
Copy link
Member

Note that this will precompile many things for

julia> typeof(devnull)
Base.DevNull

which is not the type that will typically be used when printing things.

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Sep 13, 2024

This is now done.

You can't simply skip devnull, because then it would show, and I'm not sure how to avoid that differently, than I do now.

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Sep 15, 2024

I think this is now done for the 1.11 backports. Only question is the precompile I got for Markdown (probably harmless to have here; or skip it): precompile(Tuple{typeof(Base.:(^)), String, Int64})

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Sep 26, 2024

Bump. This was ok for me locally, the CI failure is most likely unrelated, and this can and should be merged, and ideally go into 1.11, since a small better change and this line seems not to be about me:

cd(@__DIR__) do

    Pkg          |           1      1  7m05.9s
    FAILURE
The global RNG seed was 0x6aeb1dca8020ba26586d7a4ba73abb95.
Error in testset Pkg:
Error During Test at none:1
  Got exception outside of a @test
  ProcessExitedException(2)
  Stacktrace:
    [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
      @ Base ./task.jl:1111
    [2] wait()
      @ Base ./task.jl:1175
    [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
      @ Base ./condition.jl:141
    [4] wait
      @ ./condition.jl:136 [inlined]
    [5] take_buffered(c::Channel{Any})
      @ Base ./channels.jl:493
    [6] take!(c::Channel{Any})
      @ Base ./channels.jl:487
    [7] take!(::Distributed.RemoteValue)
      @ Distributed /cache/build/tester-amdci5-15/julialang/julia-master/julia-628169b274/share/julia/stdlib/v1.12/Distributed/src/remotecall.jl:726
    [8] remotecall_fetch(::Function, ::Distributed.Worker, ::String, ::Vararg{String}; kwargs::@Kwargs{seed::UInt128})
      @ Distributed /cache/build/tester-amdci5-15/julialang/julia-master/julia-628169b274/share/julia/stdlib/v1.12/Distributed/src/remotecall.jl:461
    [9] remotecall_fetch(::Function, ::Int64, ::String, ::Vararg{String}; kwargs::@Kwargs{seed::UInt128})
      @ Distributed /cache/build/tester-amdci5-15/julialang/julia-master/julia-628169b274/share/julia/stdlib/v1.12/Distributed/src/remotecall.jl:492
   [10] (::var"#46#47"{Vector{Task}, var"#print_testworker_errored#39"{ReentrantLock, Int64, Int64}, var"#print_testworker_stats#36"{ReentrantLock, Int64, Int64, Int64, Int64, Int64, Int64}, Vector{Any}, Dict{String, DateTime}})()
      @ Main /cache/build/tester-amdci5-15/julialang/julia-master/julia-628169b274/share/julia/test/runtests.jl:264
ERROR: LoadError: Test run finished with errors
in expression starting at /cache/build/tester-amdci5-15/julialang/julia-master/julia-628169b274/share/julia/test/runtests.jl:100
ERROR: A test has failed. Please submit a bug report (https://github.com/JuliaLang/julia/issues)

@PallHaraldsson
Copy link
Contributor Author

Bump.

False alarm CI is a problem for PRs getting accepted I think (a bit too common IMHO, then I miss out on some real CI failures):
Pkg (2) | failed at 2024-09-15T00:55:04.032

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Nov 7, 2024

This can be merged as is. I'm trying a rebase though (for the first time), I think that's the solution to CI false alarms. I meant to do rebase, after button seemed not responding, think I chose the option above, "to branch"(?) by accident, not even sure what it does or if I made worse...

@fredrikekre
Copy link
Member

Any timings before/after?

@PallHaraldsson
Copy link
Contributor Author

E.g.:

julia> @time println(md"# H1")
# H1

  0.000095 seconds (13 allocations: 296 bytes)

before:
julia> @time using Markdown
  0.049139 seconds (16.95 k allocations: 1.171 MiB)

julia> @time println(md"# H1")
# H1

  0.103901 seconds (32.81 k allocations: 1.701 MiB, 99.73% compilation time)

@fredrikekre
Copy link
Member

Ok, and those 0.1 seconds are annoying/noticable when?

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Nov 7, 2024

This doesn't affect the sysimage size, so I think precompilng as much as possible ok here?

I had already fixed the major issue I had with using Markdown being slow, I just thought being more complete would be helpful, in a follow-up PR (I dislike seeing those "precompilation time", they add up..., it's annoying when looking for a root cause which is the real cause). There might be others slower, just showing some before and after, since asked for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants