Code Monkey home page Code Monkey logo

Comments (8)

sccolbert avatar sccolbert commented on July 20, 2024

I omitted stay constraints in my version. I found that for my purposes of typical application layout they weren't needed (such systems are typically well-constrained).

From what I've seen, stays are useful when doing pick-and-move type operations where the system is naturally under-constrained and the stays are needed to make it well-behaved.

Kiwi is fast for a couple of key reasons:

  • There are no virtual functions in kiwi. Virtual classes take longer to instantiate and have non-trivial copy-semantics. The only exception is for the user data variable context, which is never copied.
  • Variables are replaced in the solver with trivially-copyable symbols.
  • Maps are implemented using sorted vectors instead of node-based containers. This makes them very cpu-cache friendly. Most of the speed and memory wins come from this point. Recompile after uncommenting this line and see for yourself (the difference is huge): https://github.com/nucleic/kiwi/blob/master/kiwi/maptype.h#L31

from kiwi.

Nocte- avatar Nocte- commented on July 20, 2024

It's good to hear stays can be removed without a problem for doing GUI layouts, I'll definitely give that a try and see if anyone actually misses them. Replacing the big polymorphic variables with symbols is also a very good idea! (I had already replaced all maps with sorted vectors and unordered_maps, might be a trivial optimization but like you said, it makes a huge difference.)

Thank you for the detailed answer!

from kiwi.

helmesjo avatar helmesjo commented on July 20, 2024

Is there any way to work around this (read hack), or extend current code base? I'm not very (read barely) familiar with the implementation-details of cassowary & stays, but they are vital in my case since I use the solver in a "drag-n-drop" editor which is at most times under-constrained...

Is it possible without too much trouble?

from kiwi.

sccolbert avatar sccolbert commented on July 20, 2024

You can probably work-around it by adding non-required == constraints for the variables which should remain in their current location. When editing parameters, remove the the == constraints and use suggestValue for the variables which should be edited.

from kiwi.

helmesjo avatar helmesjo commented on July 20, 2024

Yeah thought about that, but I want to avoid this since then I have to keep adding/removing constraints when moving vars around which might cause performance issues...

Just looked over another implementation of cassowary and stay-constraints seem to be highly embedded (lots of nasty if/else special cases), which is what I feared.

from kiwi.

hfossli avatar hfossli commented on July 20, 2024

In my experience cassowary is solving things very quickly. I wouldn't worry about performance issues.

from kiwi.

helmesjo avatar helmesjo commented on July 20, 2024

Been having some issues with older implementations which is why I set my hopes for this one, but then again I'm running on mobile devices so every inch counts!

But yeah I might be able to mimic it with equal-constraints without to much effort... :)

from kiwi.

hfossli avatar hfossli commented on July 20, 2024

I'm also on mobile c++ (ios). The java implementation seems slower.

from kiwi.

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.