1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00

Store contexts as symbols

This provides some deduplication since most contexts are used multiple
times.

Also, store singleton contexts directly in the Value object. This
saves a 16-byte Context object. This is useful because the vast
majority of contexts are singletons, e.g. 23723 out of 26138 in a
NixOS 19.03 system configuration.
This commit is contained in:
Eelco Dolstra 2019-04-23 11:07:47 +02:00
parent e392ff53e9
commit 2160258cc4
8 changed files with 78 additions and 37 deletions

View file

@ -100,6 +100,7 @@ void GC::gc()
break;
}
case tContext:
case tInt:
case tBool:
case tNull:
@ -107,9 +108,14 @@ void GC::gc()
case tFloat:
break;
case tString:
// FIXME
case tString: {
auto obj2 = (Value *) obj;
// FIXME: GC string
// See setContext().
if (!(((ptrdiff_t) obj2->string.context) & 1))
push(obj2->string.context);
break;
}
case tPath:
// FIXME
@ -245,9 +251,12 @@ std::pair<Size, Size> GC::Arena::freeUnmarked()
case tWithAttrsEnv:
objSize = ((Env *) obj)->words();
break;
case tContext:
objSize = ((Context *) obj)->getSize() + 1;
break;
default:
printError("GC encountered invalid object with tag %d", tag);
abort();
//throw Error("GC encountered invalid object with tag %d", tag);
}
}