plumatic / schema

Clojure(Script) library for declarative data description and validation
Other
2.41k stars 257 forks source link

No-op for cljs #377

Closed sundbry closed 7 years ago

sundbry commented 7 years ago

Hello, First, thank you for this library, I have been using it in projects for two years now.

I would like to publish release builds with the schema code completely compiled out - I am trying to shave the milliseconds off of my startup time (running cljs on mobile) and my CPU profiler is full of calls to schema, with-meta, conditional-schema constructors, etc. With each function or data structure that gets added, it potentially adds a good portion of a millisecond to the launch. I don't know if any prior work has been attempted to this extreme?

w01fe commented 7 years ago

Thanks for the kind words! Have you seen the section of the README about compile-fn-validation? I haven't used it for this purpose, but I believe you should be able to set this flag at cljs compile time to prevent generation of all schema function validation code at macroexpansion time. Is that what you're looking for?

On Thu, Dec 1, 2016 at 6:57 PM, Ryan R Sundberg notifications@github.com wrote:

Hello, First, thank you for this library, I have been using it in projects for two years now.

I would like to publish release builds with the schema code completely compiled out - I am trying to shave the milliseconds off of my startup time (running cljs on mobile) and my CPU profiler is full of calls to schema, with-meta, conditional-schema constructors, etc. With each function or data structure that gets added, it potentially adds milliseconds to the build. I don't know if any prior work has been attempted to this extreme?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/plumatic/schema/issues/377, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIPpn2332qQA6smyD3qHriPcjwhdKbNks5rD4kWgaJpZM4LCJQE .

sundbry commented 7 years ago

Hi @w01fe, I gave that a try yesterday (by disabling assert), or at least I thought I did, and it didn't change the generated code size. Upon further inspection it just seems really finnicky trying to turn off assert in the cljs compiler like @hlship mentioned in #336. Experimenting more, I manually set-compile-fn-validation! to false and it finally delivered a significant performance impact (about 25% faster startup time / ~20% smaller code size). So I think that will be good enough. Thanks.

w01fe commented 7 years ago

Great! If that doesn't end up being good enough let me know and I'll see if there's anything else we can do.

On Fri, Dec 2, 2016 at 3:03 PM, Ryan R Sundberg notifications@github.com wrote:

Closed #377 https://github.com/plumatic/schema/issues/377.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/plumatic/schema/issues/377#event-880706826, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIPpmGrTibJs21DV0ldopU8R-G5spGWks5rEKPegaJpZM4LCJQE .