[NFC] Inline more core HeapType methods#8681
[NFC] Inline more core HeapType methods#8681kripken wants to merge 2 commits intoWebAssembly:mainfrom
Conversation
tlively
left a comment
There was a problem hiding this comment.
LGTM for such significant performance wins. A couple other things that might be interesting to try: 1) LTO, 2) putting just the fast paths that check bit patterns in the header and leaving everything that touches the HeapTypeInfo in the .cpp file.
|
We could also split some of this stuff into a separate wasm-type-impl.h header, but I'm not sure that gets us very much. |
|
I suspect LTO might help here, yeah. Though the hard part would be getting LTO enabled in all our builds. Also, the more LTO differs from normal builds, the more we'd need to always remember to profile on LTO builds locally, which could be annoying. Hmm, I'd rather not move only some methods into the header. There could be more bottlenecks we run into later. In fact this is a followup to the first set of methods we moved, so that first set was insufficient... |
|
I don't mean moving some of these methods into the header and others not, I mean taking a method like this: And keeping this in the header: And adding an additional private method If we do that for all the methods, then the fast paths will remain inlineable and we would still have But if there's still a significant performance downside with that approach, then I agree the current change is the best choice. |
|
Now I see your point, thanks. Ok, interesting, but this turns out not to work well. I used this diff: diff --git a/src/wasm-type.h b/src/wasm-type.h
index 972688928..471a9cbc5 100644
--- a/src/wasm-type.h
+++ b/src/wasm-type.h
@@ -164,6 +164,7 @@ public:
bool isShared() const;
Shareability getShared() const;
+ Shareability getSharedCompound() const;
// Check if the type is a given basic heap type, while ignoring whether it is
// shared or not.
@@ -1206,7 +1207,7 @@ inline Shareability HeapType::getShared() const {
if (isBasic()) {
return (getID() & SharedMask) != 0 ? Shared : Unshared;
}
- return getHeapTypeInfo(*this)->share;
+ return getSharedCompound();
}
inline bool HeapType::isBottom() const {
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index ae4983daa..be4c2661f 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -1345,6 +1345,10 @@ FeatureSet HeapType::getFeatures() const {
return collector.feats;
}
+Shareability HeapType::getSharedCompound() const {
+ return getHeapTypeInfo(*this)->share;
+}
+
HeapType RecGroup::Iterator::operator*() const {
if (parent->id & 1) {
// This is a trivial recursion group. Mask off the low bit to recover theThat does the idea for I believe the reason is that the call overhead is significant. That is, |
|
Interesting, thanks for checking. LGTM as-is. |
This makes Unsubtyping over 2x faster on a large Dart testcase. This was the
slowest pass there by far. On
-Osthis saves 5.5% of total time.I am not totally happy about moving this code into headers, but the benefit
is so big that I think it makes sense, unless we can think of an alternative? If
it helps, the key slowdowns this fixes are
HeapType::getShared()took33% of total runtime in Unsubtyping (!) and
HeapType::getKind()took 6%.