Cuckoo metadata#24498
Conversation
- Implement cuckoo filter lookup logic - Implement new ready to run section - Add dumper to R2RDump - Parse section on load into data structure - Implement function to query filter - Add concept of enum of well known attributes - So that attribute name hashes themselves may be cached
… with use of R2R data
This should fix the current error seen when compiling on Linux. The OSX issue with immintrin.h will be dealt with later.
Are you going to use the nullable annotated S.P.Corelib as one of the tests? |
| #ifndef __WELLKNOWNATTRIBUTES_H_ | ||
| #define __WELLKNOWNATTRIBUTES_H_ | ||
|
|
||
| enum class WellKnownAttribute : DWORD |
There was a problem hiding this comment.
This is only attributes that the VM/JIT cares about, correct?
There was a problem hiding this comment.
At the moment. Yeah, its most of the ones the VM/JIT cares about. @sebastienros suggested I look into ASP.NET startup and see if I should see if I thought this might be useful to improve attribute query perf for managed code too.
@tannergooding The tests I am looking at are small process start tests, which are primarily impacted by S.P.Corelib type load perf, so yeah, its the primary test vehicle. I need to find out if there is a threshold for which doing the hashing calculation is just more expensive than the table scan, but I suspect it will work quite well. @tannergooding do you have a reference for the right way to detect if I can use ARM NEON instructions on Windows/Linux? With the current implementation, I'm not very optimistic about performance without the SIMD based comparison, so my preference would be to generate the optimized table unconditionally, but only use it if SIMD instructions are available for use. |
We have some existing code in the VM utilizing You can see where we set the JIT flags and do other ISA checks for ARM/ARM64 here: https://github.com/dotnet/coreclr/blob/master/src/vm/codeman.cpp#L1481 It's also worth noting that Windows doesn't currently expose all the same ISA flags for ARM as Linux does, which goes through |
My guess is that the performance without SIMD would be just fine. The copy of the SIMD header looks like a maintenance nightmare... |
|
The SIMD header is deeply dissatisfying, however, I expect maintenance to be minimal. We've already been maintaining a very similar SIMD header for some SSE intrinsics in xmmintrin.h without much ongoing cost. I'll want to investigate the performance here before I make any judgements here though. |
…reclr into cuckoo_metadata
- With current xor based second hash system, cuckoo filters must be powers of two. This can be addressed later, after performance is analyzed.
- Probably doesn't work on *nix platforms, but I'll discover that in the cloud
|
|
||
| #ifndef DACCESS_COMPILE | ||
|
|
||
| #if defined(_M_X64) || defined(__x86_64__) || defined(__i386__) || defined(_M_IX86) |
There was a problem hiding this comment.
Can you please use _TARGET_AMD64_ / _TARGET_X86_ / _TARGET_ARM_ / _TARGET_ARM64_ instead?
There was a problem hiding this comment.
No, because these aren't about the target architecture. They are about the compilation architecture. I could not find a set of compilation architecture #defines to use.
There was a problem hiding this comment.
Ah, right. Then you can use _ARM_, _ARM64_, _X86_ and _AMD64_
|
|
||
| /* | ||
|
|
||
| The below hash combining function is based on the xxHash32 logic implemented |
There was a problem hiding this comment.
It seems we should put the license into THIRD-PARTY-NOTICES.TXT too.
There was a problem hiding this comment.
Its already in there. See License notice for xxHash.
- Our build environments aren't setup for NEON intrinsics - Performance win is affected by using non-SIMD path, but the cuckoo filter is still an overall win. Once this is all checked in, I'll open an issue to enable SIMD in our build.
- Fix the disable filter logic - Disable the presence table for non Corelib cases. Current performance data does not warrant the size increase in other generated binaries
|
The performance improvement seems to be limited to coreLib, so I've restricted the implementation to be Corelib only to avoid excess bloat in R2R images. This is disappointing, but not surprising, as corelib has types loaded and referenced from it at rates which far exceed that of other dlls. As we put together more startup measurement data, we should revisit this policy. |
…o_metadata Attempted to address conflict with native type parsing
| } | ||
|
|
||
| // For format version 3.1 and later, there is an optional attributes section | ||
| if (IsImageVersionAtLeast(3,1)) |
There was a problem hiding this comment.
Nit: I know that you are following the existing pattern, but these IsImageVersionAtLeast checks are unnecessary. (I think I have made the same comment the last time new structure got added here.)
|
Build breaks: |
|
What else needs to be done here before this PR can be merged? |
janvorli
left a comment
There was a problem hiding this comment.
LGTM, I only found a small nit that you may ignore.
| if (!IsWinMD()) // ignore classic COM interop CAs in .winmd | ||
| { | ||
| if (this->GetManifestImport()->GetCustomAttributeByName(TokenFromRid(1, mdtAssembly), INTEROP_IMPORTEDFROMTYPELIB_TYPE, 0, 0) == S_OK) | ||
| if (GetManifestModule()->GetCustomAttribute(TokenFromRid(1, mdtAssembly), WellKnownAttribute::ImportedFromTypeLib, NULL, 0) == S_OK) |
There was a problem hiding this comment.
A nit - maybe we can use the Assembly::GetCustomAttribute wrapper here to make the line little less verbose. The same for the occurrence in the assembly.cpp above.
* Basic infra for cuckoo filter of attributes - Implement cuckoo filter lookup logic - Implement new ready to run section - Add dumper to R2RDump - Parse section on load into data structure - Implement function to query filter - Add concept of enum of well known attributes - So that attribute name hashes themselves may be cached * Wrap all even vaguely perf critical uses of attribute by name parsing with use of R2R data * Update emmintrin.h in the PAL header to contain the needed SSE2 intrinsics for the feature - Disable the presence table for non Corelib cases. Current performance data does not warrant the size increase in other generated binaries Commit migrated from dotnet/coreclr@adecd85
Replace attribute reading code with possibly higher performance path that uses a r2r generated cuckoo filter instead of searching CustomAttribute table.