Bug 224677 - Before deleting a MarkedBlock we do not need to clear its m_directory pointer.
Summary: Before deleting a MarkedBlock we do not need to clear its m_directory pointer.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Miller
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-16 10:06 PDT by Keith Miller
Modified: 2021-04-16 14:48 PDT (History)
8 users (show)

See Also:


Attachments
Patch (4.19 KB, patch)
2021-04-16 10:14 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (4.48 KB, patch)
2021-04-16 11:30 PDT, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Miller 2021-04-16 10:06:20 PDT
Before deleting a MarkedBlock we do not need to clear its m_directory pointer.
Comment 1 Keith Miller 2021-04-16 10:14:20 PDT
Created attachment 426246 [details]
Patch
Comment 2 Mark Lam 2021-04-16 10:31:04 PDT
Comment on attachment 426246 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426246&action=review

> Source/JavaScriptCore/ChangeLog:11
> +        This patch adds prevents this uncessary store to hopefully reduce the number

/adds prevents/prevents/

> Source/JavaScriptCore/heap/MarkedBlock.cpp:-79
> -    removeFromDirectory();

Why is this ok?  Wouldn't this leave the directory in a stale state?
Comment 3 Keith Miller 2021-04-16 10:34:23 PDT
Comment on attachment 426246 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426246&action=review

>> Source/JavaScriptCore/heap/MarkedBlock.cpp:-79
>> -    removeFromDirectory();
> 
> Why is this ok?  Wouldn't this leave the directory in a stale state?

Well, it's unnecessary. The only place we destruct handles (MarkedSpace::freeBlock) already removes the MarkedBlock from the directory before calling delete.
Comment 4 Keith Miller 2021-04-16 10:34:38 PDT
Comment on attachment 426246 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426246&action=review

>> Source/JavaScriptCore/ChangeLog:11
>> +        This patch adds prevents this uncessary store to hopefully reduce the number
> 
> /adds prevents/prevents/

fixed.

>>> Source/JavaScriptCore/heap/MarkedBlock.cpp:-79
>>> -    removeFromDirectory();
>> 
>> Why is this ok?  Wouldn't this leave the directory in a stale state?
> 
> Well, it's unnecessary. The only place we destruct handles (MarkedSpace::freeBlock) already removes the MarkedBlock from the directory before calling delete.

Well, it's unnecessary. The only place we destruct handles (MarkedSpace::freeBlock) already removes the MarkedBlock from the directory before calling delete.
Comment 5 Geoffrey Garen 2021-04-16 10:34:56 PDT
Comment on attachment 426246 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426246&action=review

> Source/JavaScriptCore/ChangeLog:10
> +        paging in the footer from disk, which some data we have seen shows is happening.

from disk or from the compressor

> Source/JavaScriptCore/ChangeLog:11
> +        This patch adds prevents this uncessary store to hopefully reduce the number

adds prevents => prevents

> Source/JavaScriptCore/ChangeLog:12
> +        of pageins caused by Safari web content on Mac.

compressor effect pertains to iOS too

> Source/JavaScriptCore/heap/BlockDirectory.cpp:145
> +    removeBlockForDeletion(block);

Surprising to say "for deletion" when we are not deleting.

How about instead adding an enum class WillDeleteBlock { Yes, No } parameter to removeBlock() that defaults to WillDeleteBlock::No? Then removeBlock() can call didRemoveFromDirectory if willDeleteBlock == WillDeleteBlock::YES.

> Source/JavaScriptCore/heap/MarkedBlock.cpp:-79
> -    removeFromDirectory();

Is this OK? Why?
Comment 6 Yusuke Suzuki 2021-04-16 10:36:09 PDT
Comment on attachment 426246 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426246&action=review

>>>>> Source/JavaScriptCore/heap/MarkedBlock.cpp:-79
>>>>> -    removeFromDirectory();
>>>> 
>>>> Why is this ok?  Wouldn't this leave the directory in a stale state?
>>> 
>>> Well, it's unnecessary. The only place we destruct handles (MarkedSpace::freeBlock) already removes the MarkedBlock from the directory before calling delete.
>> 
>> Well, it's unnecessary. The only place we destruct handles (MarkedSpace::freeBlock) already removes the MarkedBlock from the directory before calling delete.
> 
> Is this OK? Why?

Only MarkedSpace::freeBlock calls this destructor, and it is calling removeBlockForDeletion.
So, this does nothing in practice. When calling it, m_directory was always nullptr.
Comment 7 Keith Miller 2021-04-16 10:45:19 PDT
Comment on attachment 426246 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426246&action=review

>> Source/JavaScriptCore/heap/BlockDirectory.cpp:145
>> +    removeBlockForDeletion(block);
> 
> Surprising to say "for deletion" when we are not deleting.
> 
> How about instead adding an enum class WillDeleteBlock { Yes, No } parameter to removeBlock() that defaults to WillDeleteBlock::No? Then removeBlock() can call didRemoveFromDirectory if willDeleteBlock == WillDeleteBlock::YES.

Sure, that's fine.

>>>>>> Source/JavaScriptCore/heap/MarkedBlock.cpp:-79
>>>>>> -    removeFromDirectory();
>>>>> 
>>>>> Why is this ok?  Wouldn't this leave the directory in a stale state?
>>>> 
>>>> Well, it's unnecessary. The only place we destruct handles (MarkedSpace::freeBlock) already removes the MarkedBlock from the directory before calling delete.
>>> 
>>> Well, it's unnecessary. The only place we destruct handles (MarkedSpace::freeBlock) already removes the MarkedBlock from the directory before calling delete.
>> 
>> Is this OK? Why?
> 
> Only MarkedSpace::freeBlock calls this destructor, and it is calling removeBlockForDeletion.
> So, this does nothing in practice. When calling it, m_directory was always nullptr.

I'll actually change this so we still call removeFromDirectory() here and remove the call from MarkedSpace::freeBlock. That way it's a bit more obvious what's going on.
Comment 8 Geoffrey Garen 2021-04-16 10:46:10 PDT
> How about instead adding an enum class WillDeleteBlock { Yes, No } parameter
> to removeBlock() that defaults to WillDeleteBlock::No? Then removeBlock()
> can call didRemoveFromDirectory if willDeleteBlock == WillDeleteBlock::YES.

I mean NO! :P
Comment 9 Keith Miller 2021-04-16 11:30:58 PDT
Created attachment 426252 [details]
Patch for landing
Comment 10 EWS 2021-04-16 12:24:30 PDT
Committed r276155 (236646@main): <https://commits.webkit.org/236646@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426252 [details].
Comment 11 Geoffrey Garen 2021-04-16 14:48:45 PDT
rdar://76779547