Fork me on GitHub
#portal
<
2024-04-17
>
Alexander Kouznetsov18:04:27

Do we track performance of portal? Yesterday I worked with a large map of 90K key value pairs and UI was quite slow. I also noticed that when sending data to the portal, it sometimes takes a while for it to appear in the UI. For example, by looking at a tap-list atom I can see that it contained some number of elements, but the UI was still empty. I’m curious if this is the result of recent changes to hashing. (It could as well be me overloading the system with big structures).

seancorfield18:04:14

I would expect such a large hash map to take quite a while to build the UI for...

💯 1
djblue19:04:10

Portal doesn't track performance internally, but that could be an interesting add. What are you hoping to do with that data structure in Portal once it's loaded?

Alexander Kouznetsov19:04:29

I’d search for a particular entry in it.

Alexander Kouznetsov19:04:09

Searching was also slow. First it would clear the results (which gave me wrong impression that my search entry isn’t found) but then they will slowly appear over time.

Alexander Kouznetsov19:04:46

I might be wrong, but I think it used to work faster in the past.

Alexander Kouznetsov19:04:05

Luckily I recorded a demo of it with 0.51.1 version and the search was snappy. The actual number of elements in that map was 110K entries. It was one of the main differentiators for me that I can now tap and search inside of the data so quickly.

Alexander Kouznetsov19:04:51

I can try to replicate this in a bit with this and the current version and compare the results.

Alexander Kouznetsov19:04:51

It was also previously showing the number of matches - but now it doesn’t seem to do it anymore (or maybe it just takes time to finish calculating?)

djblue20:04:12

So I recently https://github.com/djblue/portal/commit/96bbfc14de9f07a050f053b5a64edb38224eef7f, which improved performance for me in a lot of cases but I think introduced other performance issues. I pushed https://github.com/djblue/portal/commit/be31963a7e324dc1160a88182e82c3c02a49ce27 which I think should fix your issue since we shouldn't even be telling react about a given value if we don't intend to render it. The main performance win was making filtering lazy which is why the count is static.

🙌 1
djblue20:04:47

I tried the filtering with 100k rows and it is much better when using keep-indexed vs map-indexed 👌

🙌 2
Alexander Kouznetsov20:04:12

Thanks! I’ll give it a try.

Alexander Kouznetsov19:04:18

Looks like I cannot just specify this commit as a dependency. I’m getting Error building classpath. The following libs must be prepared before use: [djblue/portal]. How can I test this?

Alexander Kouznetsov19:04:54

I tried setting it like this:

{:extra-deps {djblue/portal    {:git/sha "f686b286ad7c5e258c620d687b008a8f34774534"
                                :git/url ""}}}

Alexander Kouznetsov19:04:00

Here is what I’ve got. I have a symbol to symbol map of 97K elements. In 0.48.0, search works nearly instantaneous with less than 1 second delay (including the case when nothing is found). In the current master, the search takes more than 3 minutes to start reporting any results (when searching for something that doesn’t appear on the top of the map, if sorted). And sometimes the VSCode IDE shows a “Window not responding” message. I had to dismiss it a few times before it actually finally returned the results of something that was closer to the end of the map. Thoughts?

Alexander Kouznetsov19:04:55

This old superfast search was a killer feature.

Alexander Kouznetsov19:04:13

What were the situations when it was slow?

djblue20:04:03

I tried using this value:

(def m
  (into
   {}
   (for [_ (range 100000)]
     [(gensym) (gensym)])))
And it seems to filter for 12345 in about a second.

djblue20:04:52

Are you sure you are using latest? If I switch back to before my fix commit, it is very slow 👌

Alexander Kouznetsov20:04:40

I have a clone of the latest master where I ran this prep command clj -X:deps prep :aliases '[:dev]' and which I added as a dependency with :local/root pointing at that clone’s root folder.

Alexander Kouznetsov20:04:24

Hmm, maybe I’m overriding the version actually. Let me recheck.

Alexander Kouznetsov20:04:51

I see portal’s src and resources on the classpath, so it should be accurate.

djblue20:04:05

If you have both the local/root dep and the jar dep and the jar is earlier in the classpath, you might be getting the older main.js :thinking_face:

Alexander Kouznetsov20:04:14

Could vscode extension be the contributing factor?

Alexander Kouznetsov20:04:30

That’s where I’m testing it.

djblue20:04:56

Perhaps a little but it shouldn't be this much.

djblue20:04:33

Here is a jar with the latest changes. You can replace the one at ~/.m2/repository/djblue/portal/0.55.1/portal-0.55.1.jar and see if that helps

Alexander Kouznetsov20:04:26

Thanks, with this jar I indeed can see search completing in around 1 second. Feels much slower than how it worked in 0.48.0 but a significant improvement over 0.55.1. Thanks for fixing the problem!

djblue06:04:50

I think https://github.com/djblue/portal/commit/31d3486066924e900cda6d584103617e27df5088 should fix the remaining performance issues 👌

🙌 1
Alexander Kouznetsov17:04:57

Nice, thank you for performance improvements! I’ll wait for the next release to give it a try.