-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Improvements to tree parsing speed #3508
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
Changes from all commits
7132150
ed97074
2580077
ee42bb0
95ae352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,17 +12,20 @@ | |
#include "odb.h" | ||
#include "vector.h" | ||
#include "strmap.h" | ||
#include "pool.h" | ||
|
||
struct git_tree_entry { | ||
uint16_t attr; | ||
uint16_t filename_len; | ||
git_oid oid; | ||
size_t filename_len; | ||
char filename[1]; | ||
bool pooled; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mis-aligns the struct packing, which is not neat for pool allocations. I think we could very easily change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does indeed bring sadness to alignment, I forgot to double-check after testing it out. It's probably enough to have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed to 16-bit and avoided any padding (except for the final one due to the zero-length array). This brings the size down from 32 to 26 bytes. It doesn't seem to make a difference in speed one way or another. |
||
char filename[GIT_FLEX_ARRAY]; | ||
}; | ||
|
||
struct git_tree { | ||
git_object object; | ||
git_vector entries; | ||
git_pool pool; | ||
}; | ||
|
||
struct git_treebuilder { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a check here to make sure that
filename_len
fits in auint16_t
? I don't see any obvious vulnerabilities if one were to somehow build a tree that had a longer filename in it, but I'm also not the most creative person in the owrld.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, I've pushed up a commit which does this and de-duplicates the size and overflow checks.