Skip to content
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

Add option to disable pretty printing #455

Open
parched opened this issue Nov 29, 2024 · 5 comments
Open

Add option to disable pretty printing #455

parched opened this issue Nov 29, 2024 · 5 comments

Comments

@parched
Copy link

parched commented Nov 29, 2024

I was curious if there was any low hanging fruit to speed up the compiler.
I run with the --instrument flag and found that almost all the time is in the pretty printing.

FlatSharp compiler instrumentation: CompileReflectionFbs took 3328.0253ms.
FlatSharp compiler instrumentation: Initialization.WriteCode took 33.4955ms.
FlatSharp compiler instrumentation: PropertyModeling.CodeWriterToString took 0.5624ms.
FlatSharp compiler instrumentation: PropertyModeling.CompilePreviousAssembly took 854.264ms.
FlatSharp compiler instrumentation: PropertyModeling.WriteCode took 14.225ms.
FlatSharp compiler instrumentation: SerializerAndRpcGeneration.CodeWriterToString took 0.1859ms.
FlatSharp compiler instrumentation: SerializerAndRpcGeneration.CompilePreviousAssembly took 793.4003ms.
FlatSharp compiler instrumentation: SerializerAndRpcGeneration.WriteCode took 1523.0881ms.
FlatSharp compiler instrumentation: FinalStep.CodeWriterToString took 9.3971ms.
FlatSharp compiler instrumentation: PostProcessTransforms took 94.4395ms.
FlatSharp compiler instrumentation: PrettyPrint took 20087.2718ms.

Would you be open to me adding a flag to turn off pretty printing? Perhaps even disabling by default.

Do you see any other suspicious numbers above that should be looked at?

@jamescourtney
Copy link
Owner

I haven't looked at that for awhile, but I do recall that pretty printing was expensive. I agree that adding an option to disable it makes sense. It just never occurred to me because I personally need the code to be prettified to debug it.

Feel free to submit a PR!

@parched
Copy link
Author

parched commented Nov 30, 2024

Would you prefer it on or off by default?

@jamescourtney
Copy link
Owner

I'm actually more conflicted about this than I expected to be before writing this out.

On one hand, I agree cutting the time in half is a big deal.

On the other, I don't want people to open the output with the default settings and go "wow, this can't possibly be any good".

What do you think?

@parched
Copy link
Author

parched commented Dec 3, 2024

IMO the slowness is a worse look than the unformatted generated code. The code is formatted pretty good anyway---so much so, personally, I'd just strip out the pretty printing altogether.

@jamescourtney
Copy link
Owner

Ship it as the default then!

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

No branches or pull requests

2 participants