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

Idea: Cache some defschema specs #456

Closed
wants to merge 3 commits into from
Closed

Idea: Cache some defschema specs #456

wants to merge 3 commits into from

Conversation

frenchy64
Copy link
Contributor

I've been experimenting with caching the results of the Schema protocols. This seemed like promising low-hanging fruit, short-circuiting the need to reparse non-metadata schemas declared via defschema.

There would need to be a way to return the original syntax, but this explains the gist of the idea.

Sometimes the Node tests fail on this branch, haven't figured it out yet.

(comment
(defschema Bar (nth (iterate #(vector #{%}) Integer) 100))
(dotimes [_ 10]
  (time (spec Bar)))
;="Elapsed time: 0.926795 msecs"
;="Elapsed time: 0.055069 msecs"
;="Elapsed time: 0.02755 msecs"
;="Elapsed time: 0.02287 msecs"
;="Elapsed time: 0.018021 msecs"
;="Elapsed time: 0.020887 msecs"
;="Elapsed time: 0.023733 msecs"
;="Elapsed time: 0.02642 msecs"
;="Elapsed time: 0.022624 msecs"
;="Elapsed time: 0.034662 msecs"
(dotimes [_ 10]
  (time (spec (nth (iterate #(vector #{%}) Integer) 100))))
;="Elapsed time: 0.298001 msecs"
;="Elapsed time: 0.171665 msecs"
;="Elapsed time: 0.231007 msecs"
;="Elapsed time: 0.324284 msecs"
;="Elapsed time: 0.105173 msecs"
;="Elapsed time: 0.083637 msecs"
;="Elapsed time: 0.090645 msecs"
;="Elapsed time: 0.087503 msecs"
;="Elapsed time: 0.098164 msecs"
;="Elapsed time: 0.06527 msecs"
  )

@frenchy64
Copy link
Contributor Author

This doesn't seem to give any speedup.

@frenchy64 frenchy64 closed this Apr 28, 2024
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.

1 participant