Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Port idlist #429

Closed
wants to merge 1 commit into from
Closed

Port idlist #429

wants to merge 1 commit into from

Conversation

rpavlik
Copy link
Contributor

@rpavlik rpavlik commented May 23, 2019

Builds on #428 - replaces the manual memory management with something less manual. Had to go with a shared_ptr<vector> instead of just a vector because there's a lot of code that relies on assignment/copy being shallow. The tests pass here. (Unlike its related branch where I also ported List, that fails tests by being off by a few pixels. https://github.com/rpavlik/solvespace/commits/port-both )

@rpavlik
Copy link
Contributor Author

rpavlik commented May 23, 2019

ah, the windows build env. in use doesn't support defaulting move constructors.

@whitequark
Copy link
Contributor

Is this obsoleted by #433?

@rpavlik
Copy link
Contributor Author

rpavlik commented Aug 20, 2019

no, #433 (ideally) builds on this. However, at least in my rebased version of this branch, neither one succeeds at the tests - this branch crashes, while the other fails tests and crashes.

The issue before is that much of the code relies on a copy
or assignment of IdList being a shallow copy,
so using a shared_ptr was the simplest way to preserve
that meaning. (Using a Vector directly was unsuccessful
due to changed copy semantics. The variety of iteration methods
makes a port to shared_ptr<unordered_map> harder and more far-reaching,
if nevertheless worthwhile.)
@rpavlik
Copy link
Contributor Author

rpavlik commented Aug 20, 2019

OK, when I remove the merge-idlists patch from this branch, I do pass all the tests and can open something with a lathe object, though I get a double-free on shutdown.

This is probably the best shot so far at such a port, but I'm not sure the value of it at this point since things break when I poke at stuff with varied ownership semantics.

@whitequark
Copy link
Contributor

yeah it's unfortunately not easy at all

@Evil-Spirit
Copy link
Collaborator

@rpavlik Have you tested performance? There will probably be significant decrease.

@rpavlik
Copy link
Contributor Author

rpavlik commented Dec 10, 2020

Why would it be expected to be slower? (Is MemAlloc a pool? I can't remember. If so, that makes sense.)

I have no great allegiance here: if we somehow manage to avoid leaking/double-freeing/use-after-freeing memory with the current code, it's fine. Raw pointers owning memory just makes me anxious so I did something about it once. (and again, and again, when rebasing and testing ;) )

@Evil-Spirit
Copy link
Collaborator

@rpavlik I am not sure, but it always worth testing before such significant changes. I said so, because almost every change of original containers by @jwesthues since 2.0 lead to performance decrease. std::things is not a very good at performance because should work everywhere and support all the data types. You can just look into id-list-indexing branch, the work I made on improvement of performace which is really significant, if you will test on really big examples like houses modelisation.slvs

@ruevs
Copy link
Member

ruevs commented Apr 7, 2021

@phkahler @rpavlik @pjanx Hi guys - this is the old attempt by @rpavlik mentioned here #939 (comment) . I think after either #1002 or #992 is merged we can safely close this. What do you think?

Discussions are in #939 and #932 .

@pjanx
Copy link
Contributor

pjanx commented Apr 7, 2021

The idea could be revisited after the high-impact optimisations are in. But as it is, this PR isn't getting merged anytime soon, especially if it's unstable. There seems to be a battle of approaches in Solvespace, which originally was much more C-like.

@ruevs
Copy link
Member

ruevs commented Apr 7, 2021

There seems to be a battle of approaches in Solvespace, which originally was much more C-like.

The project is from 2008 when Jonathan Westhues started it based on his SkethFlat and up to 2.0 in 2013 it was not even open source. And it was pretty much only him until 2015 when Whitequark and EvilSpirit joined.
C++11 did not exist in the beginning ;-)

The code is updated/modernized from time to time - usually when there is another reason to touch it - as with the IdList in our case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants