-
Notifications
You must be signed in to change notification settings - Fork 711
Leading comma 2 #4971
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
Leading comma 2 #4971
Conversation
Few tactical INLINEs and, performance is improved
It's 10ms per cabal file. |
Christmas magic happened, the travis is green! 🎆 ... except that now I rebased, so who knows what happens... |
10 ms per .cabal file is acceptable IMO, do you think the gap could be made narrower with some more optimisations? Do we have any automated perf checks for the parser in the test suite? May be worth adding one, unless there will be too many false positives/negatives due to Travis perf being too wobbly. It may be also worthwhile to look at the distribution of parse times, maybe there are some pathological outliers that we should fix. |
Note: 10ms is just a 1ms slowdown from 9ms from the I tried to run profiler on a test-suite parsing all cabal files of packages staring with m. I didn't saw difference between It would be great to have benchmarks, but Travis is way too noisy environment (and no guarantees that machine are the same)! Below another round of "benchmarks", on a quite machine: master
leading-comma
leading-comma-2 (this)
|
CabalSpecVersion type-class will allow to gather per-spec conditionals. Currently it's used for selecting parsers / grammatical structure. Leading (or trailing commas) for CommaFSep/CommaVSep fields, i.e. fields with mandatory comma are (atm): - build-depends - build-tool-depends - build-tools - mixins - pkgconfig-depends - reexported-modules - setup-depends
Tag Backpack fields (mixins, signatures) to `availableSince [2,0]`. This "fixes" haskell#4448, as fields are recognised, warned, but parsed as empty if cabal-version < 2.0 (actual cut-off is ! (>= 1.25). For example, a file with cabal-version: >=1.10 library: mixins: foo-indef requires (Foo42 as FooImpl) will be accepted, yet warned, and parsed `mixins` in `BuildInfo` will be an empty list. Also availableSince is removed from `build-tool-depends`, as we **want** to parse (and not warn) it in old Cabal files. It can be thought as added retrospectively to old specs, but old `Cabal` s don't know how to use it.
fc0f160
to
6cb9d87
Compare
6cb9d87
to
a316340
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I like these changes, and the 1 ms per .cabal file slowdown doesn't look like a big deal.
@phadej You may want to try heap profiling both branches, maybe it will tell you why the second one allocates more. |
Another take on #4953
Here I followed @23Skidoo and used less-tricky approach, just by passing
CabalVersionSpec
value (not dictionary!). Thus I had to changeParsecParser
to anewtype
(good), but I went all-in and vendored small part ofparsers
. Unfortunately I made two changes at once: introduceCharParsing
, and redoCabalSpecVersion
, so I cannot say what affects more. Performance is noticeably degradedParsing all of Hackage:
leading-comma (old)
leading-comma-2 (this)
TL;DR
I think this approach is better Haskell, though a little slower. If we compare with parsing Hackage with
ReadP
(this includes parsing with parsec), (563 - 116 =~ 450, i.e. 4x slower). And I think the implementation can be optimised, one just have to profile it properly (e.g. find why it allocates more).