Comments (8)
This points to a possibly faster approach: https://www.reddit.com/r/rust/comments/b8gha1/javascript_lexing_for_high_performance_in_rust/
from fluent-rs.
new rustc lexer is very similar to what I've been exploring - https://github.com/rust-lang/rust/blob/e2b4165a6c2fbab4c1bde97d0c2e47b4602f7bc0/src/librustc_lexer/src/lib.rs
from fluent-rs.
https://dev.to/cad97/what-is-a-lexer-anyway-4kdo
from fluent-rs.
I got to the point where I have a lexer branch (lexer5
) which passes all-but-one fixtures and benchmark fixtures.
The performance is promising:
parse/"simple" time: [8.2312 us 8.2357 us 8.2410 us]
change: [-45.982% -45.885% -45.795%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
3 (3.00%) high mild
parse/"preferences" time: [171.52 us 171.65 us 171.78 us]
change: [-33.596% -33.473% -33.353%] (p = 0.00 < 0.05)
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
2 (2.00%) low severe
3 (3.00%) high mild
3 (3.00%) high severe
parse/"menubar" time: [40.406 us 40.440 us 40.482 us]
change: [-28.479% -28.049% -27.562%] (p = 0.00 < 0.05)
Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
6 (6.00%) high mild
3 (3.00%) high severe
parse_ctx/"browser" time: [185.77 us 185.99 us 186.22 us]
change: [-27.016% -26.814% -26.633%] (p = 0.00 < 0.05)
Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe
parse_ctx/"preferences" time: [440.48 us 441.21 us 442.02 us]
change: [-30.603% -30.229% -29.775%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) low mild
1 (1.00%) high severe
Gnuplot not found, disabling plotting
This is what I'd call a lower bound of what I think is possible. This is a pretty dummy and dirty lexer which doesn't have any peeking, keeps stack and does many other things that I think we can avoid.
But even with that we get 25-30% perf win and a separated lexer which helps maintain cleaner code.
I'm going to continue toying with a lexer for the forseeable future as it's not a blocker for any work, but I like tinkering with it in my spare time.
My hope is to get lexer6
to build a cleaner lexer on top of lexer5
next.
from fluent-rs.
I will try to do some experiments in the next few days and try to achieve faster perf win.
If I succeed, I will open a PR and share the results here.
from fluent-rs.
great! here's my last attempt - https://github.com/zbraniecki/fluent-rs/tree/lexer5
from fluent-rs.
At this point, I don't believe we should be trying to add a lexer. The Parser is Really Fast, and if someone can come up with a significant performance improvement, that should be a separate issue filed by the person who's able to make that PR :)
@Stupremee - please, open a issue/PR if you get to it!
from fluent-rs.
In case we revisit - https://github.com/maciejhirsz/logos
from fluent-rs.
Related Issues (20)
- ResourceManager::get_bundle and get_bundles is inconsistent and confusing
- ResourceManager ignores and hides errors
- ResourceManager needs to implement BundleGenerator HOT 2
- Parser swallows leading whitespace after indented placeable HOT 2
- Clippy should be run in CI HOT 2
- rustmt should be run in CI
- error[E0277]: `(dyn Any + 'static)` cannot be sent between threads safely HOT 11
- Cannot use built-in functions HOT 2
- Which data providers Fluent crates use? HOT 3
- Make FluentArgs a trait? HOT 1
- Switching windows process/thread ui languages HOT 2
- Provide Way to Avoid Allocating To Collect Formatting Errors HOT 7
- Using or switching to icu4x crates? HOT 4
- Output looks the same, but is different HOT 3
- Behaviour of FluentArgs::set is misleading HOT 1
- Support full precision of all numbers HOT 1
- How to use this in a command line program and properly parse POSIX locales? HOT 1
- [Feature request] Allow serialize all AST types instead of just Resource HOT 7
- Include source position in the AST HOT 5
- Does a 'safe harbor' release of the current HEAD make sense before further changes? HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluent-rs.