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

Make configurable size of internal storage in util::function #1987

Merged
merged 3 commits into from Feb 16, 2016

Conversation

hkaiser
Copy link
Member

@hkaiser hkaiser commented Feb 14, 2016

No description provided.

@hkaiser hkaiser added this to the 0.9.12 milestone Feb 14, 2016
@hkaiser
Copy link
Member Author

hkaiser commented Feb 16, 2016

[16 Feb 16 08:20] * hkaiser * K-ballo: btw, may I ask you to look at #1987, please?
[16 Feb 16 08:21] * hkaiser * (if you have the time)
[16 Feb 16 08:21] * K-ballo * the one for fatter functions?
[16 Feb 16 08:21] * hkaiser * nod
16 Feb 16 08:22] * K-ballo * I don't think it's a good idea in the long term, but if you are gonna use that to search for the optimal size then it looks good
[16 Feb 16 08:22] * hkaiser * K-ballo: that's the idea, yes
[16 Feb 16 08:22] * hkaiser * I've seen some speedup because of reduced allocations, though
[16 Feb 16 08:22] * hkaiser * K-ballo: why do you think this is a bad idea?
[16 Feb 16 08:23] * hkaiser * move/copy-overheads?
[16 Feb 16 08:23] * K-ballo * having it configurable by the user, is another source of problems if they link the wrong builds
[16 Feb 16 08:24] * hkaiser * K-ballo: ahh, sure - I plan not to expose that number
[16 Feb 16 08:24] * K-ballo * use it to find the optimal size, which is likely to be ~3, and then drop the config flag
[16 Feb 16 08:24] * hkaiser * nod
[16 Feb 16 08:25] * hkaiser * K-ballo: do other implementations have fatter functions?
[16 Feb 16 08:25] * K-ballo * mmh, msvc uses "the size of a std::string" as heuristic...................
[16 Feb 16 08:26] * K-ballo * libc++ has a 3 pointer buffer I think, but it wastes some space too
[16 Feb 16 08:26] * hkaiser * so they went through the motions of optimizing small string optimization for std::string
[16 Feb 16 08:27] * hkaiser * and just adopted that value
[16 Feb 16 08:27] * K-ballo * libstdc++ uses the size of the biggest mem-fun-ptr
[16 Feb 16 08:30] * hkaiser * which is probably 3
[16 Feb 16 08:30] * K-ballo * they can get pretty fat for virtual functions of classes with multiple inheritance, let me see
[16 Feb 16 08:32] * K-ballo * it can go up to 4 or 5 pointers on some compilers
[16 Feb 16 08:33] * hkaiser * nod, figures - how do they figure that out?
[16 Feb 16 08:33] * hkaiser * at compile time, that is
[16 Feb 16 08:33] * K-ballo * sizeof this https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/functional#L1457
[16 Feb 16 08:34] * hkaiser * tks
[16 Feb 16 08:34] * K-ballo * a pointer to member function of incomplete class has to get the worst possible size

@hkaiser
Copy link
Member Author

hkaiser commented Feb 16, 2016

The latest commit sets the size for the internal function storage to 3*sizeof(void*) which seems to give best performance results.

hkaiser added a commit that referenced this pull request Feb 16, 2016
…imization

Make configurable size of internal storage in util::function
@hkaiser hkaiser merged commit f613c8e into master Feb 16, 2016
@hkaiser hkaiser deleted the function_small_object_optimization branch February 16, 2016 20:51
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

1 participant