summaryrefslogtreecommitdiff
path: root/sys/src/9/port/portdat.h
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2022-01-23 21:33:58 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2022-01-23 21:33:58 +0000
commit60adc40118dda2edf2a238d22d050a7bae5e0d66 (patch)
tree4f20cbe0a8f68485c0c777f689103d673abc76b9 /sys/src/9/port/portdat.h
parenta5a8a92adf39b1a4525d6b0ddebc75e6db03e5b3 (diff)
devenv: allow environment total size of up to 1MB
Sometimes, there is the one-off occation when one needs to pass a huge list in rc... This change makes devenv track total memory consumption of environment groups allowing them to grow up to 1MB in size (including overhead). (Before, only the variable size was restricted, but not the amount of files being created). The maximum value size of a single environment variable is set to half of the total size, which allows the occational large value. (But not many of them). Because we track all memory consuption, it is also now possible to create around 10k small environment variales. A hashtable is added for name lookups and the qid.path was changed to allow direct indexing into the entry array without needing a scan lookup. All smalloc() calls have been removed, exhaustion is handled with error(Enomem) avoiding deadlock in case we run out of kernel memory.
Diffstat (limited to 'sys/src/9/port/portdat.h')
-rw-r--r--sys/src/9/port/portdat.h32
1 files changed, 19 insertions, 13 deletions
diff --git a/sys/src/9/port/portdat.h b/sys/src/9/port/portdat.h
index 5bb641f7f..421f673e6 100644
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -456,6 +456,8 @@ enum
NFD = 100, /* per process file descriptors */
PGHLOG = 9,
PGHSIZE = 1<<PGHLOG, /* Page hash for image lookup */
+ ENVLOG = 5,
+ ENVHASH = 1<<ENVLOG, /* Egrp hash for variable lookup */
};
#define REND(p,s) ((p)->rendhash[(s)&((1<<RENDLOG)-1)])
#define MOUNTH(p,qid) ((p)->mnthash[(qid).path&((1<<MNTLOG)-1)])
@@ -493,23 +495,27 @@ struct Rgrp
Proc *rendhash[RENDHASH]; /* Rendezvous tag hash */
};
-struct Egrp
-{
- Ref;
- RWlock;
- Evalue *ent;
- int nent;
- int ment;
- ulong path; /* qid.path of next Evalue to be allocated */
- ulong vers; /* of Egrp */
-};
-
struct Evalue
{
- char *name;
char *value;
int len;
- Qid qid;
+ ulong vers;
+ uvlong path; /* qid.path: Egrp.path << 32 | index (of Egrp.ent[]) */
+ Evalue *hash;
+ char name[];
+};
+
+struct Egrp
+{
+ Ref;
+ RWlock;
+ Evalue **ent;
+ int nent; /* numer of slots in ent[] */
+ int low; /* lowest free index in ent[] */
+ int alloc; /* bytes allocated for env */
+ ulong path; /* generator for qid path */
+ ulong vers; /* of Egrp */
+ Evalue *hash[ENVHASH]; /* hashtable for name lookup */
};
struct Fgrp