-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Refactoring: Memory management #4443
base: master
Are you sure you want to change the base?
Conversation
Because you force pushed to the branch while it was closed? |
That's probably it. Didn't know it would cause that. |
|
||
using Stack = LocklessList<size_t>; | ||
{ | ||
size_t n = 100 * 1000 * 1000; |
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.
I think you should make it as constexpr
.
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.
That wouldn't make any difference, would it?
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.
It evaluates at compile-time rather than run-time.
The merge conflicts grew a bit out of hand so I rebased on top of master another time. |
I think you are wrong, but I respect your decision regarding your contributions. You can even license all your past contributions under MIT. However, there is a problem when you add MIT license headers to files because you are affecting future contributions of others. In this case, you are touching the core of LMMS; in my humble opinion, you are breaking project consensus. Solution: state your permission in |
I already stated my permission to re-license all my past contributions in #3412 (comment), so did a handful of other contributors.
I understand your concern, but I don't think this is the case here, because (a) as can be seen in discussions like #3412, there is no clear consensus on the GPL, and (b) developers who don't want to license their contributions to my files under the MIT can simply change the file's license to GPL. |
If you do not want to change
Do you mind if I change those headers now? |
Yes I do, because I wouldn't call it a contribution to my files, but an attempt to enforce your opinion on others. |
Code is authoritative. Your headers state that files are under MIT, thus contributions must be under MIT. Please be unambiguous in code, not just on GitHub issues. |
What exactly is ambiguous in your eyes? |
Again: your headers state that files are under MIT, thus contributions must be under MIT. Is this your intention? |
Yes, the files are under MIT and any contributions to them will therefore be under MIT as well, unless the contributor decides to sublicense the file because he doesn't want his contributions to be under MIT. |
This is ambiguous: sublicensing has nothing to do with contributions. You are forcing MIT onto contributors. This is a GPL project.
It does. I have told you a way to add your permission; if you do not like to use |
I'm not forcing the MIT onto anyone. It's compatible with the GPL and thus MIT files can be relicensed under the GPL. Please explain why you think this wouldn't be possible.
Yes but I don't wish to add permission, I wish to license the files under MIT. This makes future versions of them MIT as well as long as contributors are fine with it. |
You still want to remain ambiguous, but your code and your intention are clear: you are forcing MIT in those files. I object to your refactoring. If you go ahead, I would like a configure option to use the current implementation instead. |
I tried to explain what I'm doing and why it's not forcing the MIT onto anyone. Licensing a file as MIT doesn't force contributions to that file to be MIT, it just makes it the default option. If I'm being unclear about something, just ask specifically and I will gladly try to clarify it. If I'm wrong about the legal implications of MIT licensing, feel free to correct me, but please at least try explaining why you think I'm wrong. I don't know what else is left to say when you insist on reiterating your statements without actually responding to what I write.
Please refrain from making such claims about my intentions when I've just told you differently. I prefer not to be accused of lying or of intentionally obscuring the truth.
This is absurd. No such thing will happen. |
* This file is licensed under the MIT license. See LICENSE.MIT.txt file in the
* project root for details. This is what matters, not whatever you are writing in this pull request. If you want to be unambiguous, just add your explanation: "Contributions to this file are not required to be under MIT, but I request so". |
@jasp00 is correct. Future contributions to this file are forced under MIT unless the project removes the license. This is fine though. We do it for CMake files. @jasp00 please let this issue rest. These files you're attacking are written by one person that's chosen to make them:
No, they're MIT. That's where you're right @jasp00. But that's fine. If the project chooses to downgrade to GPL we can do so at any time. @lukas-w has given us the freedom to do that. |
Thanks. Double standard will make my life easier. |
As indicated, we already have this exception on CMake files. Assuming "double standard" means "two standards", and not the proverbial English slang for "not being treated fairly". |
Resolves some inexplicable linking errors on Windows. Saves us from working around incomplete CMake support of object libraries.
What's missing in this PR to be merged? |
@JohannesLorenz Just review and testing I guess. |
include/Memory.h
Outdated
}; | ||
|
||
static MemoryManager::MmCounter _mm_counter; | ||
static thread_local MemoryManager::MmCounter _mm_thread_counter; |
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.
Why do you have thread local MmCounter
here and ThreadGuard
in Memory.cpp
?
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.
Sorry for missing this question. I don't remember exactly to be honest. The MmCounter
was introduced in ac0081d to fix a crash in MSVC, IIRC it would call rpmalloc_finalize
before rpmalloc_thread_finalize
. I realize this whole Nifty Counter solution may be a bit fragile to use, so I'm open to searching a different solution if we can't make it work reliably.
@lukas-w Sorry for bumping, but could you resolve conflicts again? |
@PhysSong Sure, done. |
Things to check before merging:
|
Rebase? |
On it. |
Does this PR still has a point after #7128 ? |
I think so because it includes some useful changes such as memory pool, etc. |
The As far as I can tell, the single place |
I hope this is a drop in replacement. Btw it's |
Opened a PR at #7335 . Thanks for the heads up. |
I removed some irrelevant change and then updated the branch. This PR will still require some minor changes, I guess. |
benchmark.cpp | ||
) | ||
|
||
# TODO replace usages of include_directories in src/CMakeLists.txt with target_include_directories |
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.
I believe this todo can be done.
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.
Or are you referring to #7255 ?
Copying description from #4311, which for some reason GitHub won't let me reopen. I made these changes in November and April, but didn't have time to fix them on all platforms back then.
Some refactorings regarding memory management and containers.
MemoryManager.h
renamed toMemory.h
MemoryHelper::alignedMalloc
moved toMemory.h
, ported to an stl-compatible allocator calledAlignedAllocator
, implementation replaced by a single rpmalloc call.LocklessAllocator
implementation replaced by a newMemoryPool
class, which now also replaces the implementations ofBufferPool
(formerlyBufferManager
) andNotePlayHandlePool
(formerlyNotePlayHandleManager
). Instead of a custom-written lockless stack,MemoryPool
uses a 3rdparty lockless queue implementation which yields much better performance.This includes a a new submodule,
libcds
, which is a collection of concurrent and lock-free data structures.Starting with this PR, I'd like to license my contributions as MIT, while the project as a whole is still licensed as GPL. Hope that doesn't cause any trouble.