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

Use JSON3 #479

Open
rafaqz opened this issue Jan 22, 2022 · 3 comments
Open

Use JSON3 #479

rafaqz opened this issue Jan 22, 2022 · 3 comments

Comments

@rafaqz
Copy link

rafaqz commented Jan 22, 2022

Type instability in JSON.Parser.parse is responsible for a massive amount of time-to-first X for most JuliaGizmos packages. It is responsible for about 10 seconds or half of the load time for Blink.Window().

Swapping AssetRegistry over to JSON3 more than halved the load time of Interact.slider
JuliaGizmos/AssetRegistry.jl#15

It should do something similar here. This probably also means swapping over JSExpr.jl, Knockout.jl and pretty much everything else in JuliaGizmos to use JSON3. I've done most of this, but its a bit of work to finish, so flagging to make sure it can be merged if I do finish it.

This is a flame-graph for @profview Blink.Window(). The large red areas are all JSON.Parser.parse, and likely some of the towers of type inference are too. The whole thing is about 20 seconds.

2022-01-22-224716_1920x1080_scrot

@twavv
Copy link
Member

twavv commented Jan 23, 2022

Unfortunately I think this would be a breaking change since WebIO users can overload the JSON functions to customize their output when serialized. It might be possible to do it in a backwards compatible way (eg fall back to slow JSON), but if not it'd have to be a major version.

@rafaqz
Copy link
Author

rafaqz commented Jan 23, 2022

Yes, it would mean moving everything to JSON3 and defining serialization with StructTypes.jl. But probably everyone should be doing that anyway, it will solve a lot of problems, and the serialization is more generic.

It seems worth it to me - but I'll see how much of that red can be removed first and post another flame graph.

@rafaqz
Copy link
Author

rafaqz commented Jan 23, 2022

Also turns out most of this is from JSON.parse calls in Blink.jl, so I'll focus on that for a while and might make some type stability PRs here instead.

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

No branches or pull requests

2 participants