-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
EndeavourOS/Arch x86_64, dmd 2.107-beta.1, ldc 1.36.0.
I'm profiling the compilation process of my project which uses requests, which in turn uses cachetools.
In an empty app.d that only imports requests, HashMap._Bucket.toString() takes 100 milliseconds to compile, or about one third of the whole compilation process (excluding compiler start-up). It is not a template so it is always compiled.
cachetools/source/cachetools/containers/hashmap.d
Lines 108 to 121 in adc3d53
| struct _Bucket { | |
| hash_t hash; | |
| StoredKeyType key; | |
| StoredValueType value; | |
| string toString() const { | |
| import std.format; | |
| return "%s, hash: %0x,key: %s, value: %s".format([ | |
| EMPTY_HASH: "free", | |
| DELETED_HASH: "deleted", | |
| ALLOCATED_HASH: "allocated" | |
| ][cast(long)(hash & TYPE_MASK)], hash, key, value); | |
| } | |
| } |
We can't easily make std.format.format cheaper, but can we at least make toString a template? I have no use for it myself and I'd like to avoid the 100ms.
struct _Bucket {
hash_t hash;
StoredKeyType key;
StoredValueType value;
string toString()() const { // <-- added ()
import std.format;
return "%s, hash: %0x,key: %s, value: %s".format([
EMPTY_HASH: "free",
DELETED_HASH: "deleted",
ALLOCATED_HASH: "allocated"
][cast(long)(hash & TYPE_MASK)], hash, key, value);
}
}The example empty file:
import requests;
void main() {}Profile viewed in tracy:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
