Skip to content

add regex precompilation to build step #361

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

Merged

Conversation

karthik2804
Copy link
Collaborator

@karthik2804 karthik2804 commented Apr 15, 2025

alternatively, we could write the precompiled source to a file and keep the new syntax. @tschneidereit Do you have a preference.

Copy link
Collaborator

@tschneidereit tschneidereit left a comment

Choose a reason for hiding this comment

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

The problem with this approach is that it will make debugging impossible, unfortunately. I think it's okay to land for now, but we'll have to restructure it pretty substantially before too long.

What I imagine we'll end up doing is along the lines of

  • instead of relying on bundles, support walking all imports and looking for regexs in all of them
  • then, instead of overwriting regex occurrences in the source, we collect them and write compilation steps for them into a new file
  • finally, we pass a new file as input to componentize that imports the original main file and this generated file

I think that should make everything work, keep source maps intact, etc.

But for now, let's land this so we get the speedup :)

@@ -36,7 +35,7 @@ echo "\n\nTest completed"

# kill the spin app
echo "Stopping Spin"
kill -9 $SPIN_PID
killall spin
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can keep this to the specific process by changing from kill -9 to kill -6. Can you test that and see if it works? I had this result in very unexpected behavior before, and am certain that we (and others) would run into it again in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This did not work, I can take a look at how to fix this in a separate PR.

@karthik2804
Copy link
Collaborator Author

@tschneidereit Do we want to optionally enable the regex stuff, so that if debugging is enabled, we can ignore the precompile step for the time being? Is that an acceptable tradeoff?

@tschneidereit
Copy link
Collaborator

oh, that's a great idea! Let's maybe tie it to the -d flag and disable the precompilation automatically if that flag is set?

@karthik2804
Copy link
Collaborator Author

The only downside is that we will not be able to compile applications that have unicode regex in debug, but I am okay with the tradeoff.
An alternative I see is that when debugging, we can write the output to a file instead of in memory, so that you can still have stack traces to something on the disk.

@tschneidereit
Copy link
Collaborator

Yeah, we could do that, and it might be nicer for the time being

Signed-off-by: Karthik Ganeshram <[email protected]>
Signed-off-by: Karthik Ganeshram <[email protected]>
@karthik2804 karthik2804 merged commit 6afe64f into spinframework:main Apr 23, 2025
11 checks passed
@karthik2804 karthik2804 deleted the readd_regex_precompilation branch April 23, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants