{"action":"created","issue":{"url":"https://api.github.com/repos/timbod7/haskell-chart/issues/112","repository_url":"https://api.github.com/repos/timbod7/haskell-chart","labels_url":"https://api.github.com/repos/timbod7/haskell-chart/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/timbod7/haskell-chart/issues/112/comments","events_url":"https://api.github.com/repos/timbod7/haskell-chart/issues/112/events","html_url":"https://github.com/timbod7/haskell-chart/pull/112","id":140867517,"number":112,"title":"Make font loading much faster for diagrams backend","user":{"login":"sid-kap","id":6425077,"avatar_url":"https://avatars.githubusercontent.com/u/6425077?v=3","gravatar_id":"","url":"https://api.github.com/users/sid-kap","html_url":"https://github.com/sid-kap","followers_url":"https://api.github.com/users/sid-kap/followers","following_url":"https://api.github.com/users/sid-kap/following{/other_user}","gists_url":"https://api.github.com/users/sid-kap/gists{/gist_id}","starred_url":"https://api.github.com/users/sid-kap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sid-kap/subscriptions","organizations_url":"https://api.github.com/users/sid-kap/orgs","repos_url":"https://api.github.com/users/sid-kap/repos","events_url":"https://api.github.com/users/sid-kap/events{/privacy}","received_events_url":"https://api.github.com/users/sid-kap/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-15T04:20:00Z","updated_at":"2016-03-16T12:10:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/timbod7/haskell-chart/pulls/112","html_url":"https://github.com/timbod7/haskell-chart/pull/112","diff_url":"https://github.com/timbod7/haskell-chart/pull/112.diff","patch_url":"https://github.com/timbod7/haskell-chart/pull/112.patch"},"body":"On my computer, this brings the runtime of a simple diagrams-backend chart from >1s to 0.2s. (This is pretty close to the optimal time, which is 0.1s if no fonts are loaded at all.)\r\n\r\nChanges:\r\n* Added Serialize instance for PreparedFont. (I used cereal instead of binary because is much faster for floating-point numbers. See https://www.reddit.com/r/haskell/comments/44w15q/psa_if_youre_serializing_floating_point_numbers/ With binary, I could only get 0.3-0.35s for this program.)\r\n* Added a script (MakeFontBinaries.hs) to convert svg files to cereal binary files. (It would be nice if we could get the compiler to run this script before compiling the other files.)\r\n* Embed serialized fonts into binary for fast loading\r\n* Make `loadSansSerifFiles` load the fonts from the embedded serialized fonts instead of from the SVG files\r\n\r\nTODO/questions:\r\n* Get diagrams/SVGFonts/pull/19 PR merged (This depends on that PR)\r\n* Update `loadCommonFonts` to use serialized fonts\r\n* Should we try to upstream some of these instances (especially the Generic ones) to diagrams-lib and SVGFonts?\r\n* Should we make `Get` and `Put` objects instead of instances, so that the orphan instances don't cause OverlappingInstances problems?\r\n* Somehow make cabal run the MakeFontBinaries script before compiling Diagrams.hs"},"comment":{"url":"https://api.github.com/repos/timbod7/haskell-chart/issues/comments/197288843","html_url":"https://github.com/timbod7/haskell-chart/pull/112#issuecomment-197288843","issue_url":"https://api.github.com/repos/timbod7/haskell-chart/issues/112","id":197288843,"user":{"login":"bergey","id":251106,"avatar_url":"https://avatars.githubusercontent.com/u/251106?v=3","gravatar_id":"","url":"https://api.github.com/users/bergey","html_url":"https://github.com/bergey","followers_url":"https://api.github.com/users/bergey/followers","following_url":"https://api.github.com/users/bergey/following{/other_user}","gists_url":"https://api.github.com/users/bergey/gists{/gist_id}","starred_url":"https://api.github.com/users/bergey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bergey/subscriptions","organizations_url":"https://api.github.com/users/bergey/orgs","repos_url":"https://api.github.com/users/bergey/repos","events_url":"https://api.github.com/users/bergey/events{/privacy}","received_events_url":"https://api.github.com/users/bergey/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T12:10:00Z","updated_at":"2016-03-16T12:10:00Z","body":"Please send a PR with the instances.\r\n\r\nI have a student who will be looking at Diagrams performance for a couple of months this spring.  We can include some Charts examples in the profiling runs.  Reducing the time in font loading will make tracking down other issues that much easier."}}