Commit Graph

8 Commits

Author SHA1 Message Date
Mark Thomas
c6c99b4777 configparser: update pest to 2.1.0
Summary:
Update pest to 2.1.0.

This version has a new behaviour for parser error messages: the line feed at
the end of the line is shown in the error output.

Reviewed By: wez

Differential Revision: D13671099

fbshipit-source-id: b8d1142a44a56a0b21b3b72cf027f3f8a30f421e
2019-01-16 03:52:09 -08:00
Lukas Piatkowski
d01ebe2166 rust-crates-io: add crossbeam to tp2
Reviewed By: ikostia

Differential Revision: D10244968

fbshipit-source-id: 8d06bb64b6a1227ae589caf0588a1f3657603ce9
2018-10-08 21:32:00 -07:00
Jun Wu
43bda98976 configparser: add a benchmark parsing large files
Summary: This would provide information about performance changes.

Reviewed By: singhsrb

Differential Revision: D9620252

fbshipit-source-id: 51d243b50b349c63e552bd1c43db17497025f73a
2018-09-07 16:56:38 -07:00
Jun Wu
28b42961e8 configparser: use indexmap
Summary:
Switch to indexmap, which is more actively maintained than linked-hash-map.

There is no visible performance difference when parsing large config files.

Reviewed By: DurhamG

Differential Revision: D8960870

fbshipit-source-id: 8d6650e2d8b14989061dceb2081a3f93004cea76
2018-08-09 21:21:48 -07:00
Jun Wu
3bfce55697 configparser: use dirs crate
Summary:
`home_dir` in stdlib is going to be deprecated. Therefore switch to
external crate.

Reviewed By: DurhamG

Differential Revision: D8960874

fbshipit-source-id: e123debc5c58e6a632a801dedcd9fc6834cb1f65
2018-08-09 21:21:48 -07:00
Jun Wu
8aefad1c97 configparser: use shellexpand crate to expand paths
Summary: The crate also helps expanding environment variables.

Reviewed By: DurhamG

Differential Revision: D8960873

fbshipit-source-id: c83fc7256a8297752a14c1d86d1ddb3735f95682
2018-08-09 21:21:48 -07:00
Jun Wu
a4129f8d53 configparser: use pest to parse config files
Summary:
[pest](https://github.com/pest-parser/pest) is an elegant Rust library for
parsing text.

A navie benchmark on a 1MB config file shows pest is about 1.5 to 2x slower.
But the better error message and cleaner code seems worth it.

Practically, in a VirtualBox VM, parsing a set of our config files takes 3-7ms.
The overhead seems to be opening too many files. Reducing it to one file makes
parsing complete in 2-4ms.

Unfortunately the buck build has issues with the elegant syntax
`#[grammar = "spec.pest"]`, because "spec.pest" cannot be located by pest_derive.
Therefore a workaround is used to generate the parser.

The motivation behind this is because I noticed multi-line value can not be
taken as a plain Bytes slice. For example:

  [section]
  foo = line1
    line2

"foo" should be "line1\nline2", instead of "line1\n  line2". It does not make a
difference on configlist. But it affects templates. Rather than making the
parser more complex, it seems better to just adopt a reasonbly fast parsing
library.

Reviewed By: DurhamG

Differential Revision: D8960876

fbshipit-source-id: 2fa04e38b706f7126008512732c9efa168f84cc7
2018-08-08 17:20:00 -07:00
Jun Wu
9e08d19d8e configparser: add a new Rust library
Summary: This will be used to parse hgrc-like config files.

Reviewed By: mitrandir77

Differential Revision: D8777330

fbshipit-source-id: 73a114df36e23246a3fc1206be202fba8705453a
2018-07-11 17:36:06 -07:00