Compare commits

2 Commits

Author SHA1 Message Date
002f21fc9e version 4.4.1 2024-11-21 00:10:35 +03:00
9ab46e4afc version 4.4.1
PIVector and PIDeque now growth to 64 MiB with PoT, then increments size by 64 MiB
in case of large containers it significantly save memory
2024-11-21 00:10:14 +03:00
5 changed files with 38 additions and 20 deletions

View File

@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(PIP) project(PIP)
set(PIP_MAJOR 4) set(PIP_MAJOR 4)
set(PIP_MINOR 4) set(PIP_MINOR 4)
set(PIP_REVISION 0) set(PIP_REVISION 1)
set(PIP_SUFFIX ) set(PIP_SUFFIX )
set(PIP_COMPANY SHS) set(PIP_COMPANY SHS)
set(PIP_DOMAIN org.SHS) set(PIP_DOMAIN org.SHS)

View File

@@ -23,7 +23,7 @@
const size_t minAlloc = 64; const size_t minAlloc = 64;
const size_t maxPoTAlloc = 4_MiB; const size_t maxPoTAlloc = 64_MiB;
size_t _PIContainerConstantsBase::calcMinCountPoT(size_t szof) { size_t _PIContainerConstantsBase::calcMinCountPoT(size_t szof) {
@@ -39,10 +39,12 @@ size_t _PIContainerConstantsBase::calcMinCountPoT(size_t szof) {
size_t _PIContainerConstantsBase::calcMaxCountForPoT(size_t szof) { size_t _PIContainerConstantsBase::calcMaxCountForPoT(size_t szof) {
// printf("calcMaxCountForPoT sizeof = %d, size = %d\n", szof, maxPoTAlloc / szof);
return maxPoTAlloc / szof; return maxPoTAlloc / szof;
} }
size_t _PIContainerConstantsBase::calcStepAfterPoT(size_t szof) { size_t _PIContainerConstantsBase::calcStepAfterPoT(size_t szof) {
// printf("calcStepAfterPoT sizeof = %d, size = %d\n", szof, calcMaxCountForPoT(szof));
return calcMaxCountForPoT(szof); return calcMaxCountForPoT(szof);
} }

View File

@@ -2575,17 +2575,25 @@ private:
pid_data = nullptr; pid_data = nullptr;
} }
inline size_t asize(ssize_t s) { inline size_t asize(ssize_t ss) {
if (s <= 0) return 0; if (ss <= 0) return 0;
if (pid_rsize * 2 >= size_t(s) && pid_rsize < size_t(s)) { size_t s = ss;
return pid_rsize * 2; if (s <= _PIContainerConstants<T>::maxCountForPoT()) {
if (pid_rsize * 2 >= s && pid_rsize < s) {
return pid_rsize * 2;
}
ssize_t t = _PIContainerConstants<T>::minCountPoT();
s -= 1;
while (s >> t)
++t;
return (1 << t);
} else {
size_t ret = pid_rsize;
while (ret < s)
ret += _PIContainerConstants<T>::stepAfterPoT();
return ret;
} }
size_t t = _PIContainerConstants<T>::minCountPoT(); return 0;
s -= 1;
while (s >> t) {
++t;
}
return (1 << t);
} }
template<typename T1 = T, typename std::enable_if<!std::is_trivially_copyable<T1>::value, int>::type = 0> template<typename T1 = T, typename std::enable_if<!std::is_trivially_copyable<T1>::value, int>::type = 0>

View File

@@ -2461,14 +2461,22 @@ private:
inline size_t asize(size_t s) { inline size_t asize(size_t s) {
if (s == 0) return 0; if (s == 0) return 0;
if (piv_rsize * 2 >= s && piv_rsize < s) { if (s <= _PIContainerConstants<T>::maxCountForPoT()) {
return piv_rsize * 2; if (piv_rsize * 2 >= s && piv_rsize < s) {
return piv_rsize * 2;
}
ssize_t t = _PIContainerConstants<T>::minCountPoT();
s -= 1;
while (s >> t)
++t;
return (1 << t);
} else {
size_t ret = piv_rsize;
while (ret < s)
ret += _PIContainerConstants<T>::stepAfterPoT();
return ret;
} }
ssize_t t = _PIContainerConstants<T>::minCountPoT(); return 0;
s -= 1;
while (s >> t)
++t;
return (1 << t);
} }
template<typename T1 = T, typename std::enable_if<!std::is_trivially_copyable<T1>::value, int>::type = 0> template<typename T1 = T, typename std::enable_if<!std::is_trivially_copyable<T1>::value, int>::type = 0>

View File

@@ -360,7 +360,6 @@ void usage() {
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
sys_mon.startOnSelf();
// piDebug = false; // piDebug = false;
PICLI cli(argc, argv); PICLI cli(argc, argv);
cli.addArgument("help"); cli.addArgument("help");
@@ -375,6 +374,7 @@ int main(int argc, char * argv[]) {
usage(); usage();
return 0; return 0;
} }
sys_mon.startOnSelf();
PIString name = cli.argumentValue("name"); PIString name = cli.argumentValue("name");
PIString sip = cli.argumentValue("address"); PIString sip = cli.argumentValue("address");
PISingleApplication * sapp = 0; PISingleApplication * sapp = 0;