TechnikEmpire / HttpFilteringEngine

Transparent filtering TLS proxy.
Mozilla Public License 2.0
60 stars 33 forks source link

New host specific TLS contexts system is a memory hog #131

Open TechnikEmpire opened 7 years ago

TechnikEmpire commented 7 years ago

Didn't realize that TLS contexts were so memory hungry. After extended browsing, this will eat and hold forever a tremendous amount of RAM. This feature needs to be undone.

TechnikEmpire commented 7 years ago

We did notice significant performance increases from this system though. There may be a middle ground possible here where we just generate a new context per connection. Some things to consider in whatever solution here include:

Disabling both may be necessary, no idea.

TechnikEmpire commented 7 years ago

Possibly use global yet ref counted host specific contexts. This may be possible by forcing down the ref count on the initial shared_ptr and then we just look for nullptr if we find an existing entry for a host, and re-init the instance when it is nullptr. That may work nicely.

TechnikEmpire commented 7 years ago

should be able to just do something like this:

auto firstSharedPtr = {...};
auto second = firstSharedPtr;
firstSharedPtr.reset();
shared_ptr_container.emplace("hostname", std::move(firstSharedPtr));
return second;

Then just do this when we find an existing elm:

auto res = shared_ptr_container.find("hostname");
if(res != shared_ptr_container.end())
{
    if(res->second.get() == nullptr)
    {
        // Needs to be created again.
    }
}