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

Faster import #1139

Merged
merged 8 commits into from
Feb 3, 2025
Merged

Faster import #1139

merged 8 commits into from
Feb 3, 2025

Conversation

pca006132
Copy link
Collaborator

@pca006132 pca006132 commented Jan 30, 2025

Optimize #1138 a bit.

  1. Avoids calling fill after resize when possible. We often use resize and then fill in the vectors with various values, so we don't have to ensure that the vector content is not uninitialized values after calling resize. This adds a resize_nofill to explicitly avoid initializing the buffer.
  2. Speed up simplification by trying to do things in parallel.
  3. Fixing FlagEdge as mentioned in Potential boolean bug #970

This seems to be faster for cases where there are not too many edges to simplify. However, for Samples.Sponge4, this is slower, probably because there are too many edges to simplify. Will try to fix that.

Should also fix #1140.

@pca006132
Copy link
Collaborator Author

Basically, around 10% improvement for perfTest and mesh import.

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 93.63636% with 7 lines in your changes missing coverage. Please review.

Project coverage is 91.71%. Comparing base (ac82767) to head (63c3833).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/impl.h 61.53% 5 Missing ⚠️
src/edge_op.cpp 98.03% 1 Missing ⚠️
src/manifold.cpp 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1139      +/-   ##
==========================================
+ Coverage   91.58%   91.71%   +0.13%     
==========================================
  Files          30       30              
  Lines        5915     5951      +36     
==========================================
+ Hits         5417     5458      +41     
+ Misses        498      493       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pca006132
Copy link
Collaborator Author

Need to think about why the sequential version is not working...

@pca006132
Copy link
Collaborator Author

Some resize_nofill is probably wrong... need to check them sometime later.

Copy link
Owner

@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that knot42 is non-finite; hopefully that's easy to track down. Did you see the error about magic-nix? Looks like that's already past its drop-dead date.

size_t index;
inline bool operator<(const SortEntry& other) const {
return start == other.start ? end < other.end : start < other.start;
struct FlagStore {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a comment about what this struct is used for? I don't entirely follow from reading it.

// place all backward edges at the end
if (!other.IsForward()) return true;
if (!self.IsForward()) return false;
// dictionary order based on start and end vertices
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we sort differently for parallel and serial?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now explained in the comment:

      // Note that this is slightly different from the single thread version
      // because we store all indices instead of just indices of forward
      // halfedges. Backward halfedges are placed at the end by modifying the
      // comparison function.

halfedge_.clear();
vertNormal_.clear();
faceNormal_.clear();
halfedgeTangent_.clear();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/csg_tree.cpp Outdated
if (numPropOut > 0) {
combined.meshRelation_.numProp = numPropOut;
combined.meshRelation_.properties.resize(numPropOut * numPropVert, 0);
combined.meshRelation_.triProperties.resize(numTri);
combined.meshRelation_.triProperties.resize(numTri, ivec3(0));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing the test failure. I forgot what triProperties is used for and why are we adding it instead of copying them in with a per input mesh offset.

Also, the weird thing is that the bug is order dependent. I am rerunning the tests with shuffling enabled to try and see if there is something else that is similar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was mistaken, this is not the issue. Halfedge tangent is the issue. I guess this may be caused by having empty halfedge tangents?

Copy link
Owner

@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

if (!manifold::all_of(meshGL.vertProperties.begin(),
meshGL.vertProperties.end(),
[](Precision x) { return std::isfinite(x); })) {
MarkFailure(Error::NonFiniteVertex);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pca006132 pca006132 merged commit 447921c into master Feb 3, 2025
27 checks passed
@pca006132 pca006132 deleted the faster-import branch February 3, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NaN values in vertex properties sometimes trigger RuntimeError: memory access out of bounds
2 participants