0vercl0k / lockmem

This utility allows you to lock every available memory regions of an arbitrary process into its working set.
MIT License
64 stars 14 forks source link

Feature request: selective heap/stack segment locking and address range specification #4

Open Ceiridge opened 1 year ago

Ceiridge commented 1 year ago

Thank you so much for creating this repository! It's a really useful tool that I've found myself using quite frequently.

I just had a suggestion for a potential feature that I think could be really helpful: the ability to selectively lock either heap segments or stack segments into the working set. This would allow users to save resources by only locking the segments that they need, rather than locking all of them at once.

Additionally, it would be great if there was the option to specify a specific address range using command line options. This would allow users to be even more precise in terms of which segments they want to lock, and could be especially useful for larger projects where memory usage is a concern.

Thanks again for all of your hard work on this repository - it's greatly appreciated!

0vercl0k commented 1 year ago

Awesome, all of those seem like great ideas - will try to implement those in the next month or so :)

Cheers

On Sun, Dec 25, 2022 at 10:46 PM Ceiridge @.***> wrote:

Thank you so much for creating this repository! It's a really useful tool that I've found myself using quite frequently.

I just had a suggestion for a potential feature that I think could be really helpful: the ability to selectively lock either heap segments or stack segments into the working set. This would allow users to save resources by only locking the segments that they need, rather than locking all of them at once.

Additionally, it would be great if there was the option to specify a specific address range using command line options. This would allow users to be even more precise in terms of which segments they want to lock, and could be especially useful for larger projects where memory usage is a concern.

Thanks again for all of your hard work on this repository - it's greatly appreciated!

— Reply to this email directly, view it on GitHub https://github.com/0vercl0k/lockmem/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALIOROU77HU7CGHYJXWIUTWPE5NRANCNFSM6AAAAAATJNP6NY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

0vercl0k commented 1 year ago

Hey @Ceiridge,

I haven't forgotten about this; I had some free time this w-e so I started working on it.

I've drafted the --ranges feature in https://github.com/0vercl0k/lockmem/commit/bc950551f0de974103e32186c97af833c7ce849e (binaries from the CI if you want to dogfood it https://github.com/0vercl0k/lockmem/actions/runs/4239731588).

I also know how to do the stack one so it'll follow shortly hopefully. For the heap I need to do some testing.

Cheers

0vercl0k commented 1 year ago

Some updates, I have a first draft for handling stacks and handle better all those range filters via an interval tree. It uses boost which is way bigger than I'd like so let's see if I can trim it down.

It hasn't been extensively tested, but if you want to play w/ it you can grab binary in 44df8776f9fd0be8e94a592a3f3f98f8d4b97de7 (https://github.com/0vercl0k/lockmem/actions/runs/4273459202).

Cheers

Ceiridge commented 1 year ago

You have pushed all of boost o_o? You shouldn't really do that, but instead it should be achieved with git submodules for example. Are you sure that you need boost? Can you send the file where you are using it? My suggestion was that lockmem could find all heap or stack or code segments (whichever the user wants) in the process and lock them.

0vercl0k commented 1 year ago

Haha of course not! Boost is hundreds of megs if I had to guess 🤣I just pushed the ICL module which implements the interval_set that I am using to track ranges & overlaps, etc. I am not a fan of submodules; it requires people to download them on checkout with a special command line, if you want to patch the dependency it makes it hard, etc. I prefer subtrees.

And yes I understand your request, it is implemented under --stacks and you can see the code in lockmem.cc.

I might try to trim its dependencies or implement my own but feel free to ignore the implementation details for now :)

Cheers

Ceiridge commented 1 year ago

Ok, very good!

Adding 500 libraries for a small feature

0vercl0k commented 1 year ago

Haha getting trolled hard here 😅I wish there were more libraries that did what I want.. trust me. Looking into AVL trees library and maybe slap my interval tree on top..

Anyways, will let you know!

Cheers

0vercl0k commented 1 year ago

All right - I couldn't get boost.icl into a small enough state, so I implemented a ghetto version which works fine enough for that small tool.

Cheers