Coder Social home page Coder Social logo

Comments (9)

kovidgoyal avatar kovidgoyal commented on May 30, 2024 2

I also had a quick other unrelated question, I don't think it's possible to delete all images stored by kitty at once, as the d=A key will not delete virtual refs. I am deleting them by id for now but would it be possible to have a delete command for all images, including Unicode placeholders?

Unicode placeholders can only be deleted by deleting their associated
text, otherwise there are various issues as the lifetimes of unicode
placeholders are not tied to the underlying image data.

@sergei-grechanik should be able to elucidate those issues.

from kitty.

kovidgoyal avatar kovidgoyal commented on May 30, 2024 1

This should be fixed in the vt branch. I havent tested the performance,
but find_hole() is now O(1)

from kitty.

kovidgoyal avatar kovidgoyal commented on May 30, 2024

Wouldn't a simple fix be to have a deletion counter which tracks the
largest available hole size and its position in the file and the number
of holes. Only call find_hole

(largest_hole_size == 0 && num_of_holes > 0) || (largest_hole_size > required_size)

this way for your case of appending lots of images without a deletion,
find_hole wont be called until the cache is full. Once the cache is full
one would evict the oldest n images such that n is as small as possible
and the total size of the evicted images is greater than required_size.
So once again we can avoid calling find_hole.

Of course once deletions come into play, find_hole becomes necessary,
but again its frequency can be reduced by only doing it when cache is
limit is reached and then, depending on the value of the deletion
counter, either call find_hole or do a defrag.

Indeed, one could even maintain a list of the last N holes rather than
simply tracking the number and max size for more sophisticated handling.

from kitty.

Nogesma avatar Nogesma commented on May 30, 2024

I think keeping a list of all holes would make it possible to avoid calling find_hole completely.
It would also mean that one needs to handle merging adjacent holes, and this is probably an expensive operation. Calling defrag when the number of holes becomes too large might solve this issue.
In any case, any solution that avoids sorting the list of entries too often should be faster, and solve my issue.

I also had a quick other unrelated question, I don't think it's possible to delete all images stored by kitty at once, as the d=A key will not delete virtual refs. I am deleting them by id for now but would it be possible to have a delete command for all images, including Unicode placeholders?

from kitty.

sergei-grechanik avatar sergei-grechanik commented on May 30, 2024

Yes, the intended approach when using Unicode placeholders is to erase the text and let the image itself be deleted automatically when the total size/count limit is reached. Deleting an image by id is ok too, but it's still recommended to erase the placeholder text, because there is no guarantee that a redraw will be triggered.

Adding a key to delete all images, including virtual ones, is possible, but I wouldn't recommend actually using it, since it will break images in other panes/windows when running in tmux, for example. (However, there is still value in having such a key for testing purposes).

from kitty.

Nogesma avatar Nogesma commented on May 30, 2024

Okay, I was interested in just cleaning up when my program exits, and at this point the screen does not have any placeholders, and will not use the images anymore. The size limit won't get reached either.

I think for my purpose deleting them by id is fine, but having a key for all of them would be a nice to have. Especially since removing them one by one is actually O(n!) instead of O(n), if I interpreted the code correctly.

from kitty.

Nogesma avatar Nogesma commented on May 30, 2024

I just tested it and it works great, thanks a lot!

from kitty.

kovidgoyal avatar kovidgoyal commented on May 30, 2024

I also just added a new deletion mode to delete images by range of ids. You can specify the upper limit of the range to be the max image id value to delete all images.
cebdc93

from kitty.

Nogesma avatar Nogesma commented on May 30, 2024

Nice, thanks again!

from kitty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.