Fork me on GitHub
#malli
<
2021-05-05
>
ikitommi06:05:06

great work @ben.sless! need to read the code & think about this a bit. could you check the corresponding features from JSON Schema (https://json-schema.org/understanding-json-schema/reference/object.html#dependencies) so that Malli can be as compliant as it’s reasonable with it. I think your suggestion already a superset of what is in JSON Schema…

ikitommi06:05:38

meanwhile, a quick poke on the schema inferring / providing: • part1: make it suck less (5x faster on sample dataset): https://github.com/metosin/malli/pull/439 • part2: make inferring first class, most likely 100x faster: https://github.com/metosin/malli/pull/440

ikitommi06:05:17

with part2, all schemas are reponsible for describing how values can/not be described with schemas. This will open up things like inferring types from enums etc, e.g. [:enum "small" "medium" "large"] has a child schema of :string.

ikitommi06:05:52

the part1 (5x faster) of new provider is now 68 loc, instead of the old 69. The old was kinda bloated anyways 😉

ikitommi06:05:51

➜  malli git:(faster-inferrer-part1) ✗ cloc src --by-file
      15 text files.
      15 unique files.
       0 files ignored.

 v 1.86  T=0.03 s (571.3 files/s, 180498.1 lines/s)
----------------------------------------------------------------------------------------
File                                      blank        comment           code
----------------------------------------------------------------------------------------
src/malli/core.cljc                         146             46           1779
src/malli/impl/regex.cljc                    93             23            508
src/malli/util.cljc                          44             15            350
src/malli/transform.cljc                     64             22            335
src/malli/generator.cljc                     48             13            281
src/malli/error.cljc                         24              6            249
src/malli/clj_kondo.cljc                     21              3            141
src/malli/json_schema.cljc                   23              3            128
src/malli/dot.cljc                            7              3             69
src/malli/provider.cljc                      10              3             68
src/malli/registry.cljc                      15              3             65
src/malli/swagger.cljc                       14              4             51
src/malli/impl/util.cljc                      7              0             24
src/malli/edn.cljc                            3              0             16
src/malli/sci.cljc                            1              0             11
----------------------------------------------------------------------------------------
SUM:                                        520            144           4075
----------------------------------------------------------------------------------------

ikitommi06:05:22

➜  malli git:(faster-inferrer-part1) cloc test --by-file
      11 text files.
      11 unique files.
       0 files ignored.

 v 1.86  T=0.04 s (264.8 files/s, 133395.9 lines/s)
-----------------------------------------------------------------------------------
File                                            blank        comment           code
-----------------------------------------------------------------------------------
test/malli/core_test.cljc                         330              6           1902
test/malli/util_test.cljc                         115              4            789
test/malli/transform_test.cljc                     93              3            714
test/malli/error_test.cljc                         42              3            439
test/malli/generator_test.cljc                     39              3            266
test/malli/swagger_test.cljc                       11              4            258
test/malli/json_schema_test.cljc                   14              4            236
test/malli/dot_test.cljc                           12              0             73
test/malli/registry_test.cljc                      10              2             61
test/malli/clj_kondo_test.cljc                      8              0             55
test/malli/provider_test.cljc                       4              0             41
-----------------------------------------------------------------------------------
SUM:                                              678             29           4834
-----------------------------------------------------------------------------------

Ben Sless07:05:40

Regarding part 1, from the profiling I did yesterday it looks like most CPU is based on miu/-fail. I'll profile again with part1 merged to see what conclusions I can infer

👍 1
Ben Sless08:05:07

disregard the last message I had some repl state

Ben Sless08:05:43

ok, see ~2x speedup

Ben Sless08:05:08

-fail still dominates CPU, though. Would you like me to prepare a MR for the exception speedup?

Ben Sless18:05:51

Question about Malli's design - what's the rationale behind IntoSchemas? Why aren't Schemas and local bindings sufficient?