Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Performance while selecting nodes on a "big" tree #25

Open
sdxlzxjh opened this issue Mar 27, 2020 · 4 comments
Open

Performance while selecting nodes on a "big" tree #25

sdxlzxjh opened this issue Mar 27, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@sdxlzxjh
Copy link

It takes a noticeable period (avg. 3 seconds) to highlight the node to be selected on a relatively big tree, say a thousand leaf nodes with the tree depth of 2. Any idea about improving the performance on big trees?

@martinRenou martinRenou added the bug Something isn't working label May 15, 2020
@insatiablycivil
Copy link

I have similar issue. I feel like every time I run it, memory footprint rises a lot and it slows down a bit.

I don't know intended scope for the tree, maybe I'm expecting too much or I'm just doing it wrong, but here is example code (for JupyterLab). It's really dumb because it's based on code I'm using, but hopefully that's irrelevant.

from ipytree import Tree, Node

dict_temp = {}
for i in range(1,850):
    dict_temp[i] = str(i) + "hello"

n_a = []
for idx_a, val_a in dict_temp.items():
    if idx_a < 200:
        a_contents = [(idx_a*2)+x+200 for x in range(1,3)]
        n_b = []
        for idx_b in a_contents:
            b_contents = [(idx_a*3)+x+200 for x in range(1,5)]
            n_c = []
            for idx_c in b_contents:
                    name = str(idx_c) + "new"
                    n_c.append(Node(name))
            name = str(idx_b) + "bye"
            n_b.append(Node(name, n_c, show_icon = False, opened = False))
        name = str(idx_a) + "cya"
        n_a.append(Node(name, n_b, show_icon = False, opened = False))

tree = Tree(n_a, multiple_selection = False, animation = 0)
tree.layout.height = '2500px'  

And then next cell to create it:

tree

Ignoring the time it takes to process first cell:
If I run this on fresh notebook, it just takes a couple of second to interact with it.
But if I run these two cells like 10 times each, it's substantially slower.
Especially if I were to change node names in between runs.
The main slow down is on clicking a node rather than expanding or closing things

In my use case, I wanted to browse and dynamically edit the tree, so it gets generated quite often.

Is there a command I should be using to 'delete' the tree in between runs or something maybe?
Or maybe it is the nodes I should be trying to 'delete'?

eventually it gets to the point where I get prompted to kill the tab and it taking ~40 secs
or it taking GBs of memory

@pankajp
Copy link

pankajp commented May 19, 2022

You are right, this library's widget model's js code needs to be restructured. It currently stores all the created nodes in a global noderegistry (doesn't seem to delete nodes). and every click iterates through all the nodes (even from different trees) and deselects them. It could be made significantly faster with minor changes, but seems like the repo is now unmaintained.

@deco-dev
Copy link
Contributor

deco-dev commented Oct 21, 2022

I have same issue. I add 800 or more 1000 nodes, error happens.
So I add 500 nodes. If I select node, it is very slow.

@deco-dev
Copy link
Contributor

#72
I try to fix it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants