Skip to content

Cache parsed definitions from standard library#279

Closed
01mf02 wants to merge 2 commits intomainfrom
cache-parse
Closed

Cache parsed definitions from standard library#279
01mf02 wants to merge 2 commits intomainfrom
cache-parse

Conversation

@01mf02
Copy link
Copy Markdown
Owner

@01mf02 01mf02 commented Apr 2, 2025

This PR moves the parsing of the standard library from run-time to compile-time.
Parsing the standard library 1024 times takes 116ms before and 12ms after this change.

I'm not sure yet whether to merge this.

Advantages:

  • startup time decreases a bit, but not too much; it is still about 9% above gojq (1.04s for jaq vs. 0.95s for gojq-0.12.16 when running {jq} -n empty 2048 times in a row)
  • when printing a parsed term with dbg!, the output is now valid Rust code and can be copy-pasted

Disadvantages:

  • binary size increases from 2.0MB to 2.2MB
  • code size increases by about 100 lines
  • build.rs is required in jaq-{std,json}
  • symlink used for jaq-json/build.rs, this might not be portable

If you have any comments about this, then please feel free to add them!

01mf02 added 2 commits April 2, 2025 08:54
Parsing the standard library 1024 times takes
116ms before and 12ms after this change.
@01mf02
Copy link
Copy Markdown
Owner Author

01mf02 commented Apr 25, 2025

I have decided not to merge this. The disadvantages far outweigh the advantages.

@01mf02 01mf02 closed this Apr 25, 2025
@01mf02 01mf02 deleted the cache-parse branch March 26, 2026 16:28
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

Successfully merging this pull request may close these issues.

1 participant