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

Support for nbb #188

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Support for nbb #188

wants to merge 4 commits into from

Conversation

gdw2
Copy link

@gdw2 gdw2 commented Nov 26, 2024

Very much a WIP

It was simple to remove (assuming it works) and ring buffer isn't
compatible with nbb.
needed for nbb
Copy link
Member

@jpmonettas jpmonettas left a comment

Choose a reason for hiding this comment

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

I added a couple of comments regarding removing ring-buffer.
Apart from that, what I'm not sure is about how instrumentation would work for nbb since if I understand correctly it doesn't use Clojure or ClojureScript for compilation, it uses SCI to interpret Clojure right?

@@ -26,11 +25,11 @@
(rt-events/publish-event! (rt-events/make-last-evals-update-event last-evals-refs))))

(defn clear-outputs []
(reset! *last-evals-results (ring-buffer 10))
(reset! *last-evals-results [])
Copy link
Member

Choose a reason for hiding this comment

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

The reason I added a ring-buffer here is because the ring-buffer library was already here for other functionality (see my comment below) and I think it looks cleaner

(defn grep-coll

"Search over coll with pred, when it matches returns the
A elements before and the B elements after"

[coll A B pred]
(loop [elems-before (ring-buffer A)
(loop [elems-before []
Copy link
Member

Choose a reason for hiding this comment

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

I brought a ring-buffer for this only for performance reasons. If we change it like the proposed time will grow linearly on A, making it too slow for the current case.

On my box :

(def col (doall (repeat 10000000 :elem)))

(time (grep-coll                     col 1000 1 (constantly false))) ; ~ 1 sec
(time (grep-coll-without-ring-buffer col 1000 1 (constantly false))) ; ~ 207 sec

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.

3 participants