Graham Sutherland / Polynomial on Nostr: In the unedited code they're looping over a List<T> every time they add a new object ...
In the unedited code they're looping over a List<T> every time they add a new object to it, using IndexOf, to patch up ownership references. the problem is that IndexOf is O(n) and requires a generic comparison to be performed between the objects, which is very very slow. the comparison alone was responsible for 50% of CPU time. and this pattern exists because they have a specific schematic data object collection type with a restrictive API that wraps the List<T>. rather messy.
Published at
2024-11-17 19:41:08Event JSON
{
"id": "2467ff5184f664423e0b6c4c1cf9930ac9f524ff3a178e99f5d865929708da77",
"pubkey": "72025f2d3f9600cb4f992f4d20f3efc3f0bf6a650e5272ad7a920d716a648c81",
"created_at": 1731872468,
"kind": 1,
"tags": [
[
"e",
"b3316ba6ea595e02af5f97d05508f75811aeebca4e7b58211c00c22d1384e88c",
"wss://relay.mostr.pub",
"reply"
],
[
"proxy",
"https://chaos.social/users/gsuberland/statuses/113499994070636105",
"activitypub"
]
],
"content": "In the unedited code they're looping over a List\u003cT\u003e every time they add a new object to it, using IndexOf, to patch up ownership references. the problem is that IndexOf is O(n) and requires a generic comparison to be performed between the objects, which is very very slow. the comparison alone was responsible for 50% of CPU time. and this pattern exists because they have a specific schematic data object collection type with a restrictive API that wraps the List\u003cT\u003e. rather messy.",
"sig": "88e84886815975bf71c56759279b044cc9f12b4ab40a42addfa1a601714a784f00b7290f9d7894f0ea42c6e0cdc5c48df85c467f69fed9375405940ea1284734"
}