[{"data":1,"prerenderedAt":227},["ShallowReactive",2],{"project-43730458":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":29,"sentiment":30,"stance_mix":31,"scored_comments":34,"aspects":35,"strip":40,"post_text":42,"what":43,"said":81,"maker_in_thread":130,"shape":139,"grid":144,"attempts":188,"same_week":189,"maker_shows":32,"maker_hidden":219,"reader_version":220,"card":221},"43730458","go-sqlite3 libc","(bits) of a Libc, Optimized for Wasm","title","Show HN: (bits) of a Libc, Optimized for Wasm","https:\u002F\u002Fgithub.com\u002Fncruces\u002Fgo-sqlite3\u002Ftree\u002Fmain\u002Fsqlite3\u002Flibc","github.com","ncruces",1744999585,2025,78,16,911,3837,24,"notable","languages","c standard library","library",[24,25,26,27,28],"wasm simd","musl libc","wasi-libc","go sqlite driver","webassembly","curious",0.286,{"positive":32,"neutral":32,"mixed":33,"critical":33},3,0,6,{"execution":36,"docs":38,"idea":39},{"positive":37,"critical":33},1,{"positive":37,"critical":33},{"positive":37,"critical":33},[32,33,41,33,32,33,32,33,41,41,33,33,33,33,33,33],5,"I make a no-CGO Go SQLite driver, by compiling the amalgamation to Wasm, then loading the result with wazero (a CGO-free Wasm runtime).\n\nTo compile SQLite, I use wasi-sdk, which uses wasi-libc, which is based on musl. It's been said that musl is slow(er than glibc), which is true, to a point.\n\nmusl uses SWAR on a size_t to implement various functions in string.h. This is fine, except size_t is just 32-bit on Wasm.\n\nI found that implementing a few of those functions with Wasm SIMD128 can make them go around 4x faster.\n\nOther functions don't even use SWAR; redoing those can make them 16x faster.",{"problem":44,"audience":50,"pricing":50,"motivation":51,"time_to_build":50,"stack":55,"openness":79,"stage":80,"team_size":80},{"value":45,"source":46,"evidence":47},"musl's string functions are slow on Wasm because size_t is 32-bit and SWAR is used","maker",[48],{"id":49},"post",null,{"value":52,"source":46,"evidence":53},"Make SQLite on Wasm faster by optimizing musl string functions",[54],{"id":49},[56,60,64,68,72,75],{"value":57,"source":46,"evidence":58},"Go",[59],{"id":49},{"value":61,"source":46,"evidence":62},"WebAssembly",[63],{"id":49},{"value":65,"source":46,"evidence":66},"wazero",[67],{"id":49},{"value":69,"source":46,"evidence":70},"wasi-sdk",[71],{"id":49},{"value":25,"source":46,"evidence":73},[74],{"id":49},{"value":76,"source":46,"evidence":77},"SQLite",[78],{"id":49},"open_source","unknown",{"praise":82,"objections":95,"requests":102,"questions":114,"alternatives":125},[83],{"value":84,"source":85,"evidence":86},"Wasm SIMD approach is neat and a good idea for wasi-libc","commenter",[87,91],{"id":88,"by":89,"text":90},"43730878","fuhsnn","Wasm intrinsics look neat as a higher-level fixed size SIMD abstraction. I wonder how good the compilers can do if using them for AOT targets with libraries like simd-everywhere.…",{"id":92,"by":93,"text":94},"43730543","phickey","This looks like a nice approach to making wasi-libc faster. Could you submit these changes upstream?",[96],{"value":97,"source":46,"evidence":98},"Wasm bitmask is slower than no SIMD on Aarch64",[99],{"id":100,"by":11,"text":101},"43730651","I'd like to be a little more sure that I'm not totally messing things up before doing that, but yes, eventually, that would be a nice outcome. I've also only really tested…",[103,110],{"value":104,"source":85,"evidence":105},"Submit changes upstream to wasi-libc",[106,107],{"id":92,"by":93,"text":94},{"id":108,"by":93,"text":109},"43730846","The maintainers of wasi-libc are some of the best people to review this, and I don’t think it would be wasting their time to ask them to look at a PR.",{"value":111,"source":85,"evidence":112},"Add strstr() implementation",[113],{"id":88,"by":89,"text":90},[115,121],{"value":116,"source":85,"evidence":117},"What is SWAR?",[118],{"id":119,"by":120,"text":116},"43734331","forrestthewoods",{"value":122,"source":85,"evidence":123},"How well do compilers optimise these intrinsics for AOT targets?",[124],{"id":88,"by":89,"text":90},[126],{"value":127,"source":85,"evidence":128},"simd-everywhere",[129],{"id":88,"by":89,"text":90},{"comments":34,"answered":32,"key":131},[132,135,136],{"id":133,"text":134},"43731344","Yeah, so far I did exactly the ones (my build of) SQLite needed and not others. If there's interest, the set of implemented functions can definitely be extended.",{"id":100,"text":101},{"id":137,"text":138},"43731424","A PR is a significant investment from me. I'd have to figure out where something like this is supposed to fit, how the build infra works, etc. One of the nice things about Go is…",{"commenters":140,"max_depth":141,"maker_replies":34,"first_comment_mins":142,"lifespan_hours":143},8,4,10,63,[145,147,149,151,152,154,155,160,162,165,169,171,174,177,181,185],[88,33,32,146,89,33],"project\u002Fneutral\u002Fexecution",[133,33,33,148,11,37],"maker\u002Fneutral\u002Fexecution",[92,37,41,150,93,33],"project\u002Fpositive\u002Fexecution",[100,37,33,146,11,37],[108,37,32,153,93,33],"maker\u002Fneutral\u002Fnone",[137,37,33,153,11,37],[156,157,32,158,159,33],"43734170",2,"maker\u002Fneutral\u002Fdocs","cedws",[161,157,33,158,11,37],"43737586",[163,157,41,164,159,33],"43742551","maker\u002Fpositive\u002Fdocs",[166,32,41,167,168,33],"43749918","project\u002Fpositive\u002Fidea","tuananh",[119,141,33,170,120,33],"other\u002Fneutral\u002Fnone",[172,141,33,173,11,37],"43734741","other\u002Fneutral\u002Fdocs",[175,141,33,176,120,33],"43746292","other\u002Fpositive\u002Fdocs",[178,41,33,179,180,33],"43730859","other\u002Fpositive\u002Fidea","nu11ptr",[182,41,33,183,184,33],"43731316","commenter\u002Fcritical\u002Fidea","frumplestlatz",[186,41,33,187,11,37],"43731383","commenter\u002Fneutral\u002Fidea",[],[190,195,200,205,210,214],{"id":191,"name":192,"points":193,"category":194},"43739456","Tutorial-Codebase-Knowledge",923,"dev_tools",{"id":196,"name":197,"points":198,"category":199},"43754124","Dia",652,"ai",{"id":201,"name":202,"points":203,"category":204},"43729683","The Backdooms",531,"games",{"id":206,"name":207,"points":208,"category":209},"43734910","Undercutf1",301,"consumer_social",{"id":211,"name":212,"points":213,"category":209},"43745554","JuryNow",263,{"id":215,"name":216,"points":217,"category":218},"43771365","Scrimba",258,"learning_science",false,"v2",{"id":222,"name":5,"line":6,"ai":219,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":223,"top":18,"kw":224,"maker":11,"domain":10,"tier":19,"attempts":33,"strip":225,"url":9,"mix":226,"praise":84,"objection":97,"sub":21},43730458,0.29,[24,25,26,27,28],"3050303055000000",[32,32,33,33],1793991117879]