inkstitch icon indicating copy to clipboard operation
inkstitch copied to clipboard

stitch plan caching

Open lexelby opened this issue 2 years ago • 8 comments

This saves the stitch plan for each object in a cache. If the object's params haven't changed, then the cached stitch plan is used the next time, rather than re-calculating the stitches.

The caching should be totally transparent other than the speed boost. The caching should not interfere with your ability to change parameters, add/modify guide lines, add/modify patterns, etc.

lexelby avatar Jul 16 '22 03:07 lexelby

@tyrosinase (and anyone else) I'd be interested in your feedback, if you have time to test this branch out. It should just make things faster without causing any problems.

The thing to look out for is that you make a change but it isn't reflected in the stitch plan. That could mean that the caching code missed your change and used the cached version incorrectly.

lexelby avatar Aug 22 '22 00:08 lexelby

Innnnteresting!

I'll look at it, but may not be able to get to it for a couple weeks, being on the road.

tyrosinase avatar Aug 22 '22 13:08 tyrosinase

no worries!

lexelby avatar Aug 22 '22 16:08 lexelby

Okay, someday I'll have to learn how to navigate git/Github and figure out how to get the relevant files for a commit.

(I would prefer to build it myself; this lets me change the defaults for stitch tolerance and stitch length, which cuts down on the swearing and wasted fabric here by about 95%.)

tyrosinase avatar Sep 18 '22 00:09 tyrosinase

What we need to do is make it so you can set the defaults for those and all the other params without editing the code. That'd be cool!

For now, in your local directory:

git fetch
git checkout -b fix-defaults origin/main
(change the default values to suit your needs)
git add lib
git commit -m "fix defaults"

Now to test this branch:

git fetch
git checkout -b tyrosinase/cache-stitch-plan origin/lexelby/cache-stitch-plan
git cherry-pick fix-defaults
git push origin

That will keep your changes handy in a local branch (fix-defaults) and then you can apply them to any branch you like using cherry-pick.

If I later push changes to lexelby/cache-stitch-plan, do this:

git checkout tyrosinase/cache-stitch-plan
git fetch
git rebase origin/lexelby/cache-stitch-plan
git push

That will pull in my changes and re-apply your fix on top.

Each time you push, a new version will get built off your branch so you can test.

I hope that helps!

lexelby avatar Sep 21 '22 03:09 lexelby

I've just granted you write access so you can push branches to have them built.

lexelby avatar Sep 21 '22 03:09 lexelby

oh noooo I'm gonna break things

tyrosinase avatar Sep 21 '22 14:09 tyrosinase

It's pretty hard to break things in a way we can't just undo :)

lexelby avatar Sep 23 '22 01:09 lexelby

Is there an easy way to determine if the cache was hit, or not? With this feature the computation duration of the density map has improved significantly (from minutes to few seconds, for ~50k stitches), but only in some cases and I am wondering if somehow the cache is missed, or the heat map calculation takes sometimes much longer.

Nevertheless the caching is really cool and I am hoping to see it soon in the official version. :)

felix300F avatar Oct 16 '22 19:10 felix300F

Is there an easy way to determine if the cache was hit, or not?

Having a file named DEBUG in the inkstich folder (https://inkstitch.org/developers/inkstitch/debug/) provides further logging output and produces a debug.log file. There you can see wether the cache is used or not.

felix300F avatar Oct 24 '22 18:10 felix300F

Yup! And if the information you need isn't there, feel free to add more debug logging.

lexelby avatar Oct 24 '22 21:10 lexelby

Oh, I see you aren't a contributor yet. If you'd like, I can add you, which would allow you to push commits to this branch and others. Want in?

lexelby avatar Oct 24 '22 21:10 lexelby

Oh, I see you aren't a contributor yet. If you'd like, I can add you, which would allow you to push commits to this branch and others. Want in?

As you like, otherwise I should still be able to create PR against your branch

felix300F avatar Oct 26 '22 18:10 felix300F

Nah, doing a PR against a branch just makes everything complicated. I added you, you're a contributor now. Feel free to push to this branch.

lexelby avatar Oct 28 '22 01:10 lexelby

I think this is ready to go. If there's an issue preventing the cache from being used with density map, we can fix it in a later PR.

lexelby avatar Feb 19 '23 03:02 lexelby