Performant design decisions #682
Replies: 3 comments 3 replies
-
Hey @carloszimm 👋 I don't think it's all been documented in one place, but here are a couple older issues that discuss some of the decisions of
Keep in mind that those are from 2015 and 2017, and JS performance is always a moving target. There are probably things in mostjs that don't help with performance anymore (it's possible some never did! Performance is tricky!). For example, mostjs's map/filter fusion was incredibly fun and interesting to implement, but I doubt matters much anymore, and I'll probably vote to drop it from any new versions. Overall, I think I'd say it's probably best to approach performance from multiple angles, starting with your project's goals, then architecture, and finally implementation. Try to figure out where performance really matters for your specific project, and where it doesn't. As for implementation, simple is king. Do less. Don't try to solve every problem for everyone. Implement things as directly and obviously as possible. Try not to be "clever" unless you can prove (with data) that "clever" is actually better. In my experience, focusing on simplicity almost always work out well. Beyond that, reading about current generation VMs and their optimizations can be fun and interesting. You can use tooling to learn about how they optimize your code, and then look for ways to improve it. I hope that's somewhat helpful. |
Beta Was this translation helpful? Give feedback.
-
I figured it might be interesting to try to list some specific implementation-level things mostjs has done. Again, some of these might still matter, some might not, so they're probably worth evaluating before applying them elsewhere. I hope they at least give you some ideas to explore 😄 VM friendliness
Operator optimizations
Scheduler optimizations
Scheduler is especially complicated and probably not worth it. It was fun and challenging to implement, though. That's what I can think of at the moment. If I think of more, I'll add them. @TylorS may have more to add. |
Beta Was this translation helpful? Give feedback.
-
@TylorS has done more of this than me over recent years. Back in the early days of Another thing to consider is performance scaling. When inputs and applications are small, almost any solution will be fine, and it's usually best just to do the most obvious thing. Need to map, filter, and reduce 10k items? Just put them in an Array and .map.filter.reduce. Need to map, filter, and reduce 1 billion items? An Array may not be the best solution depending on your time budget. @TylorS pointed out performance scaling as well: mostjs's performance typically scales more linearly than other similar libs (I haven't kept track of other libs, so it's entirely possible some do scale more linearly now). You can see this in @TylorS's perf results, as well as in the "merge nested streams" microbenchmark results I mentioned previously. I don't intend any of this as negative toward other projects in any way. Each of these projects has had different goals and priorities, and solves a slightly different set of problems. |
Beta Was this translation helpful? Give feedback.
-
Hello, guys!
I was wondering about the implementation design decisions taken by mostjs (either v.1 or v.2) that makes it faster than other libraries.
Is that detailed anywhere publicly accessible?
Do you guys still have a perf test to make sure that those performant decisions still hold?
Beta Was this translation helpful? Give feedback.
All reactions