[{"data":1,"prerenderedAt":345},["ShallowReactive",2],{"project-12814742":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":34,"aspects":35,"strip":44,"post_text":45,"what":46,"said":74,"maker_in_thread":143,"shape":145,"grid":149,"attempts":301,"same_week":306,"maker_shows":336,"maker_hidden":337,"reader_version":338,"card":339},"12814742","50K","Sorting 50K Array, HTML5 Web Worker Demo","title","Show HN: Sorting 50K Array, HTML5 Web Worker Demo","http:\u002F\u002Fafshinm.github.io\u002F50k\u002F","afshinm.github.io","afshinmeh",1477653170,2016,88,59,432,2264,20,"notable","languages","web workers demo","web_app",[24,25,26,27],"web workers","javascript","bubble sort","background threads","curious",-0.042,{"positive":31,"neutral":18,"mixed":32,"critical":33},5,1,7,33,{"execution":36,"performance":39,"idea":42,"design":43},{"positive":37,"critical":38},0,2,{"positive":40,"critical":41},4,3,{"positive":32,"critical":37},{"positive":37,"critical":38},[41,41,37,37,31,32,37,37,37,37,41,41,41,41,41,37,41,41,32,41,41,37,31,31,37,41,37,37,41,41,41,32,37,41,37,37,32,32,41,32],null,{"problem":47,"audience":45,"pricing":45,"motivation":45,"time_to_build":45,"stack":61,"openness":73,"stage":73,"team_size":73},{"value":48,"source":49,"evidence":50},"Running a heavy sort in the browser without blocking the UI","inferred",[51,53,57],{"id":52},"post",{"id":54,"by":55,"text":56},"12814897","keyle","I must be silly but I expected the web worker version to run faster. I must have understood \"many threads\". It ran nearly 200ms slower :) That said, not locking the UI thread and…",{"id":58,"by":59,"text":60},"12815307","jsingleton","Not silly at all. It can't run faster, as there is a maximum speed your machine could do this. Doing it in the background can't change this but it is non-blocking. Many threads…",[62,69],{"value":63,"source":49,"evidence":64},"JavaScript",[65],{"id":66,"by":67,"text":68},"12816027","dspillett","> I must be silly but I expected the web worker version to run faster. I must have understood \"many threads\". They are only using a single worker thread, not multiple, so it will…",{"value":70,"source":49,"evidence":71},"HTML5 Web Workers",[72],{"id":52},"unknown",{"praise":75,"objections":89,"requests":112,"questions":124,"alternatives":133},[76],{"value":77,"source":78,"evidence":79},"Keeping the UI responsive is worth a small slowdown","commenter",[80,81,85],{"id":54,"by":55,"text":56},{"id":82,"by":83,"text":84},"12815199","lai","On Android Chrome the web worker took 18 seconds while the non web worker took 11 seconds but was utterly unresponsive. Having a responsive ui using the web worker with later…",{"id":86,"by":87,"text":88},"12815575","nicolasd","The difference on my machine is not even 50ms - good tradeoff for more responsiveness",[90,105],{"value":91,"source":78,"evidence":92},"Web worker version is slower than the blocking sort",[93,97,101],{"id":94,"by":95,"text":96},"12814932","didip","Is this demo supposed to highlight the strength of web worker? It runs 300-400ms slower on web worker.",{"id":98,"by":99,"text":100},"12814967","sz4kerto","3.5 seconds on Chrome. Native code does this around 10000% faster.",{"id":102,"by":103,"text":104},"12815918","thinkMOAR","2.8 seconds without 3.3 seconds with webworker Imho not acceptable trade-off, did not hear the term web workers yet, and now i'm not even upset i did not and probably will…",{"value":106,"source":78,"evidence":107},"Chunking the work with yields avoids needing workers",[108],{"id":109,"by":110,"text":111},"12815748","mibbiting","You don't need web workers to be \"responsive\". You just need to cut the job up into bits, and yield to the UI thread every so often. It's utterly unresponsive because it's not…",[113],{"value":114,"source":78,"evidence":115},"Use a parallel or merge sort across multiple workers",[116,120],{"id":117,"by":118,"text":119},"12815002","laxd","Merge sort?",{"id":121,"by":122,"text":123},"12815292","OskarS","You can totally split sorting across different threads\u002Fcores, just divide the list up and do a final merge pass. Basically the idea behind external sorting, where the amount of…",[125],{"value":126,"source":78,"evidence":127},"Would multiple workers or a better algorithm speed it up?",[128,132],{"id":129,"by":130,"text":131},"12816284","chadscira","If you wanted to go crazy you can use transferables to get around the memory copy cost. It would be a fun experiment to figure out at what point does it make sense to use…",{"id":66,"by":67,"text":68},[134],{"value":135,"source":78,"evidence":136},"task.js",[137,140],{"id":138,"by":130,"text":139},"12815799","For anyone that is interested in easily using WebWorkers for this sort of work please check out task.js (https:\u002F\u002Fgithub.com\u002Ficodeforlove\u002Ftask.js). It allows you to send a pure…",{"id":141,"by":130,"text":142},"12816439","In response to your last comment, you should check out https:\u002F\u002Fgithub.com\u002Ficodeforlove\u002Ftask.js. It will do that and much more.",{"comments":37,"answered":37,"key":144},[],{"commenters":146,"max_depth":33,"maker_replies":37,"first_comment_mins":147,"lifespan_hours":148},37,38,70,[150,152,156,160,162,165,167,169,171,174,176,178,180,183,185,188,190,193,194,197,200,202,203,207,208,211,214,217,218,219,221,225,227,228,231,236,240,244,246,249,251,253,257,260,263,266,268,270,272,274,276,278,280,283,285,288,293,295,299],[138,37,41,151,130,37],"project\u002Fneutral\u002Fexecution",[153,32,41,154,155,37],"12815924","project\u002Fneutral\u002Fperformance","globuous",[157,32,37,158,159,37],"12816434","commenter\u002Fneutral\u002Fperformance","methyl",[141,32,37,161,130,37],"commenter\u002Fneutral\u002Fidea",[163,32,37,158,164,37],"12816586","fenomas",[166,32,37,161,130,37],"12817506",[82,38,31,168,83,37],"project\u002Fpositive\u002Fperformance",[109,38,32,170,110,37],"project\u002Fcritical\u002Fexecution",[172,38,37,161,173,37],"12815872","Jtsummers",[175,38,37,161,110,37],"12815957",[177,38,37,161,173,37],"12816040",[179,38,37,161,110,37],"12816622",[181,38,37,182,173,37],"12817268","commenter\u002Fneutral\u002Fnone",[184,38,37,161,173,37],"12817546",[186,38,37,182,187,37],"12816120","tylercubell",[54,41,41,189,55,37],"project\u002Fmixed\u002Fperformance",[191,41,41,154,192,37],"12814940","Touche",[117,41,41,151,118,37],[195,41,41,154,196,37],"12815052","SigmundA",[198,41,41,154,199,37],"12815090","cjdell",[201,41,37,158,192,37],"12815904",[121,41,41,151,122,37],[204,41,37,205,206,37],"12815436","other\u002Fneutral\u002Fnone","BatFastard",[58,41,41,154,59,37],[209,41,41,154,210,37],"12815375","sgift",[212,41,41,154,213,37],"12815656","wigster",[215,41,41,154,216,37],"12816481","spdionis",[66,41,32,170,67,37],[129,41,41,154,130,37],[220,41,41,154,67,37],"12817484",[222,40,37,223,224,37],"12815562","other\u002Fneutral\u002Fperformance","fizzbatter",[226,40,37,158,164,37],"12816443",[86,31,31,168,87,37],[229,31,31,168,230,37],"12815639","tychuz",[232,233,31,234,235,37],"12814929",6,"project\u002Fpositive\u002Fidea","caleblloyd",[237,233,37,238,239,37],"12815956","other\u002Fneutral\u002Fidea","nol13",[241,233,41,242,243,37],"12820449","project\u002Fneutral\u002Fidea","pkstn",[245,233,37,161,235,37],"12823951",[247,33,37,205,248,37],"12816536","martin-adams",[250,33,37,205,130,37],"12816567",[252,33,37,182,248,37],"12816596",[254,255,41,151,256,37],"12817470",8,"psadri",[94,258,32,259,95,37],9,"project\u002Fcritical\u002Fperformance",[261,258,31,168,262,37],"12814984","spiderfarmer",[264,258,41,154,265,37],"12815059","sumnulu",[267,258,41,242,173,37],"12815617",[102,269,32,259,103,37],10,[271,269,37,158,130,37],"12815950",[273,269,37,158,103,37],"12816490",[275,269,41,154,173,37],"12817305",[277,269,37,158,130,37],"12822205",[279,269,37,182,103,37],"12835157",[281,269,37,158,282,37],"12816440","teaearlgraycold",[98,284,32,259,99,37],11,[286,284,41,151,287,37],"12814980","reitzensteinm",[289,290,32,291,292,37],"12815011",12,"project\u002Fcritical\u002Fdesign","mattmanser",[294,290,41,154,196,37],"12815071",[296,290,37,297,298,37],"12815193","commenter\u002Fneutral\u002Fdesign","VeejayRampay",[300,290,32,291,292,37],"12817149",[302,305],{"id":303,"t":304,"points":290,"comments":290},"8093905",1406493713,{"id":4,"t":12,"points":14,"comments":15},[307,312,317,322,327,331],{"id":308,"name":309,"points":310,"category":311},"12834327","sudo-touchid",347,"security_privacy",{"id":313,"name":314,"points":315,"category":316},"12843466","My first web app",297,"web_saas",{"id":318,"name":319,"points":320,"category":321},"12803860","Zone Messenger",194,"consumer_social",{"id":323,"name":324,"points":325,"category":326},"12838152","Fast Style Transfer",184,"ai",{"id":328,"name":329,"points":330,"category":311},"12802785","Android 'root' phones via dirtyc0w exploit",143,{"id":332,"name":333,"points":334,"category":335},"12842797","KQ",116,"dev_tools",13,false,"v2",{"id":340,"name":5,"line":6,"ai":337,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":341,"top":18,"kw":342,"maker":11,"domain":10,"tier":19,"attempts":38,"strip":343,"url":9,"mix":344,"praise":77,"objection":91,"sub":21},12814742,-0.04,[24,25,26,27],"3300510000333330331330550300333103001131",[31,18,32,33],1794036548959]