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

Speed up the craft definition handling #8097

Merged
merged 1 commit into from Jan 13, 2019

Conversation

osjc
Copy link
Contributor

@osjc osjc commented Jan 12, 2019

The craft definition handling code that collects the names of
the craftable nodes suffers from vector reallocation
performance hits, slowing down instances with lots of
crafting recipes (VanessaE's DreamBuilder and most public
server some to my mind when thinking about this). As in each
instance the size of the resulting vector is already known,
add a reserve() call before the offending loops to allocate
the needed chunk of memory within the result vector in one
go, getting rid of the overhead.

@osjc
Copy link
Contributor Author

osjc commented Jan 12, 2019

Didn't notice this until SmallJoker pointed this out.

The craft definition handling code that collects the names of
the craftable nodes suffers from vector reallocation
performance hits, slowing down instances with lots of
crafting recipes (VanessaE's DreamBuilder and most public
server some to my mind when thinking about this). As in each
instance the size of the resulting vector is already known,
add a reserve() call before the offending loops to allocate
the needed chunk of memory within the result vector in one
go, getting rid of the overhead.
@osjc
Copy link
Contributor Author

osjc commented Jan 12, 2019

Clarified the commit message a bit.

@nerzhul nerzhul added the Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines label Jan 13, 2019
@nerzhul nerzhul added this to the 5.0.0 milestone Jan 13, 2019
@nerzhul nerzhul merged commit a51909b into minetest:master Jan 13, 2019
osjc added a commit to osjc/minetest that referenced this pull request Jan 23, 2019
The craft definition handling code that collects the names of
the craftable nodes suffers from vector reallocation
performance hits, slowing down instances with lots of
crafting recipes (VanessaE's DreamBuilder and most public
server some to my mind when thinking about this). As in each
instance the size of the resulting vector is already known,
add a reserve() call before the offending loops to allocate
the needed chunk of memory within the result vector in one
go, getting rid of the overhead.
@osjc osjc deleted the OptimizeCraftDef branch January 23, 2019 14:15
luk3yx pushed a commit to luk3yx/minetest that referenced this pull request Feb 5, 2019
The craft definition handling code that collects the names of
the craftable nodes suffers from vector reallocation
performance hits, slowing down instances with lots of
crafting recipes (VanessaE's DreamBuilder and most public
server some to my mind when thinking about this). As in each
instance the size of the resulting vector is already known,
add a reserve() call before the offending loops to allocate
the needed chunk of memory within the result vector in one
go, getting rid of the overhead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants