<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>170826</bug_id>
          
          <creation_ts>2017-04-13 13:48:16 -0700</creation_ts>
          <short_desc>WebAssembly: slow memory grow should over-allocate</short_desc>
          <delta_ts>2017-04-13 13:48:16 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=170557</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>170628</dependson>
          <blocked>159775</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="JF Bastien">jfbastien</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>jfbastien</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>saam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1297121</commentid>
    <comment_count>0</comment_count>
    <who name="JF Bastien">jfbastien</who>
    <bug_when>2017-04-13 13:48:16 -0700</bug_when>
    <thetext>In bug #170628 Keth suggested:


&gt;&gt; Source/JavaScriptCore/wasm/WasmMemory.cpp:480
&gt;&gt; +    void* newMemory = tryGetSlowMemory(desiredSize);
&gt;
&gt; I&apos;m not sure we want to grow to the exact size. Usually you want to double up so you can avoid the pathological case of repeatedly calling grow(1).
&gt;
&gt; I would make this:
&gt;
&gt; std::min(std::max(desiredSize, m_mappedCapacity * 2), 2 &lt;&lt; 32).

I&apos;m not sure I agree, but I think it&apos;s worth revisiting when we have real-world data.

I&apos;m dubious because:
 - We really want to have fast memories, not slow ones.
 - Emscripten is likely the one calling sbrk, so if that&apos;s the right heuristic it should already use it.
 - As part of bug #170825 I&apos;d like to impose a limit on virtual allocation of slow memories. This would bring that limit closer much faster.
 - We may cause memcpy more often because mmap fails to increase the virtual address space we already have (or mremap once we address bug #170557).

Given the doubts I have I&apos;d rather stay with what seems to be simpler for now.

I may be wrong though! If we see real-world code that suffers from this heuristic then we should reconsider.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>