Skip to content

parse_file: performance improvements#34

Merged
grg merged 4 commits intoStanfordVLSI:masterfrom
grg:gleng/perf_1
Mar 3, 2026
Merged

parse_file: performance improvements#34
grg merged 4 commits intoStanfordVLSI:masterfrom
grg:gleng/perf_1

Conversation

@grg
Copy link
Copy Markdown
Collaborator

@grg grg commented Mar 2, 2026

Restructure parse_file slightly to improve performance, based on observations from a perl profile.

Changes:

  • Perform full processing only on lines with a potential perl escape (//; or `).
  • Avoid duplicate regex processing.
  • When performing full processing of a line, invoke length only once, and eliminate duplicate substr calls.

Performance improvements in parse_file runtime:

  • Test program 1: ~4.5s -> 1s
  • Test program 2: ~15s -> ~5s

@grg grg marked this pull request as draft March 2, 2026 15:34
@grg grg marked this pull request as ready for review March 2, 2026 16:09
@grg grg requested a review from steveri March 2, 2026 16:09
#
# Performance optimization:
# Run a "fast" regex to see if a line contains a potential perl
# expression (//; or `). Do more throrough processing only if this
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here..."throrough"...I leave it to you if you think it's worth correcting...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out. I'll correct before merging.

Copy link
Copy Markdown
Contributor

@steveri steveri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks complicated....I'm mostly going to just trust you and the CI on this one...

grg added 4 commits March 2, 2026 16:21
Restructure parse_file slightly to improve performance, based on
observations from a perl profile.

Changes:
 - Perform full processing only on lines with a potential perl escape
   (//; or `).
 - Avoid duplicate regex processing.
 - When performing full processing of a line, invoke length only once,
   and eliminate duplicate substr calls.

Performance improvements in parse_file runtime:
 - Test program 1: ~4.5s -> 1s
 - Test program 2: ~15s -> ~5s
Reset the prev_backslash var when processing a backtick character in
parse_file.
@grg grg merged commit f8ce122 into StanfordVLSI:master Mar 3, 2026
4 checks passed
@grg grg deleted the gleng/perf_1 branch March 3, 2026 00:52
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.

2 participants