-
Notifications
You must be signed in to change notification settings - Fork 39
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
WIP fix: convert strings to boost:flyweight #1169
base: master
Are you sure you want to change the base?
Conversation
Some tiny progress! Thanks to @milroy for seeing this. Here is the first failure to build (this is for the focal build) /usr/include/boost/flyweight/detail/recursive_lw_mutex.hpp:57: undefined reference to `pthread_mutexattr_init' We are missing Threads! 🧵 No, not the Facebook chat app - nobody wants that kind of threads. :P So I very simply added it to the CMakeLists.txt, and specifically to check that it was supported in the top level one, and then as a library that is needed for linking for the resource public library. That seemed to get through that first failure (this is the same focal build), which now gets through that, albeit the tests still fail: So probably I need to figure out how to use valgrind to debug test failures next. |
Ah, it must default to using the mutex protection for flyweights. If we only use them in the resource module, we can use the |
a03c0f5
to
ae71d07
Compare
Problem: string comparison is immensely inefficient, taking 6-10% of resources (reported by Tom) for a trace. Solution: start with the root of the issue in the scoring module and work backwards to convert string types to boost:: flyweight. I tried to have a minimal footprint here but it spread really quickly Signed-off-by: vsoch <[email protected]>
ae71d07
to
615a5d7
Compare
I wonder if the equality check is just failing because we are still using strings (and comparing different things) in the tests? flux-sched/resource/schema/test/schema_test02.cpp Lines 101 to 116 in cb95173
The only difference between test 5 (passes) and 6 (doesn't passes) is that one has colors for network (5) and the other for storage (6) infra5->colors["network"] = 1;
infra6->colors["storage"] = 1; and the one being compared to matches the first: infra1->colors["network"] = 1; so if the previous test passing meant that when the colors indices are different the objects should be considered the same (passing) that suggests something about the comparison now, using flyweight, is determining they are different. This is what is failing: bo = (bo || (*infra6 == *infra1));
ok (!bo, "pool_infra_t initialized with different colors not equal to original pool_infra_t"); so both the conditions flux-sched/resource/schema/infra_data.hpp Line 41 in cb95173
== here...
hmm if under the hood we are comparing a map with subsystem_t and before it was string, now is flyweight, I guess I'm not sure why having a map with two different strings (network or storage) should be equal in the first place. Maybe I'm misreading the test. |
Yeah I think I'm reading the test wrong too, I think "ok" is from this tap thing: flux-sched/src/common/libtap/tap.h Line 48 in cb95173
|
It's strange that doesn't throw an error. What about if we try an init() somewhere? I'm reading here: https://live.boost.org/doc/libs/1_74_0/libs/flyweight/doc/tutorial/technical.html static flyweight<std::string>::initializer fwinit; |
Signed-off-by: vsoch <[email protected]>
There is also something called a key value flyweight, I wonder if we need to use that for some of the subsystem maps? https://www.boost.org/doc/libs/1_79_0/libs/flyweight/example/key_value.cpp. I also don't know the difference between when they show:
vs. what we are doing, which is missing the middle level:
It could be the first is just an old design - I don't see it here: https://www.boost.org/doc/libs/1_79_0/libs/flyweight/doc/reference/index.html. They also have a note about the threads library there:
Maybe we want a holder too?
|
Problem: string comparison is immensely inefficient, taking 6-10% of resources (reported by Tom) for a trace in the scoring module..
Solution: start with the root of the issue in the scoring module and work backwards to convert string types to boost:: flyweight. I tried to have a minimal footprint here but it spread really quickly
Background: boost::flyweight is a cool type that essentially maps a string to an internal hashmap. @trws chose it because it still works with a lot of native string stuff. The large change was converting the subsystem_t to use it, which bubbles into many places. Design decisions we will need to make:
.get()
There is a lot of room for improvement, but I'm really new to C++ so I'm trying to keep this as simple as possible to start, and first getting something working, and then make it better. The build currently works, but tests fail.
Opening this as a draft because I need help with debugging tests - we have segfaults that need gdb-fu and I've only used -disas - ping @trws when you have time (or others that might be interested - I mostly need to learn how to do it).
Also this is how I feel about C++ strings... 😆 (sorry still laughing about Monk / this entire find)! Gotta make the painful things fun, I think.