Recent Releases of https://github.com/austinksmith/Hamsters.js

https://github.com/austinksmith/Hamsters.js - Hamsters v5.6.2 Released!

This release is a minor change that enhances the functionality of Node.js with Hamsters.js, version 5.6.1 introduced custom scaffolds and response handlers which allowed for things like progress bars etc. However there was a minor limitation in the way these handlers were assigned in Node.js making them impractical for continuous message handling. This is now resolved and you can now send as many messages from your workers to your main thread in Node.js as you desire.

If you would like to see an example of progress bars being updated using Hamsters.js take a look at the 1-billion-row-challenge repo.

- JavaScript
Published by austinksmith over 1 year ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.6.1 Released!

I'm happy to announce the release of Hamsters.js version 5.6.1 while this is a minor bump in versions its actually quite a big leap in feature improvements.

Observable

There is a new feature and class called hamsters.observable, you can use this class as an event emitter to log changes in objects you want to track inside your project, additionally this is now being used inside the library to allow for change monitoring of internal library variables to give better insights into what is taking place behind the scenes when the library is running. Please see the list below of examples on variables you can monitor.

```javascript

hamsters.pool.threads.on('change', function(threads) { console.log("Thread Pool Threads Changed"); });

hamsters.pool.running.on('change', function(runningThreads) { console.log("Thread Pool Running Threads Changed"); });

hamsters.pool.pending.on('change', function(pendingThreads) { console.log("Thread Pool Pending Threads Changed"); });

hamsters.distribute.remoteConnections.on('change', function(connections) { console.log("Distributed Remote Connections Changed"); });

hamsters.distribute.receiveChannels.on('change', function(receiveChannels) { console.log("Distributed P2P Receive Channels Changed"); });

hamsters.distribute.sendChannels.on('change', function(sendChannels) { console.log("Distributed P2P Send Channels Changed"); });

hamsters.distribute.clientInfo.on('change', function(clientInfo) { console.log("Distributed Connected Client Info Changed"); });

hamsters.distribute.pendingPromises.on('change', function(pendingPromises) { console.log("Distributed Pending Promises (Tasks) Changed"); }); ```

Scaffold

In previous releases of Hamsters.js you were confined to making use of the libraries built in web worker scaffolds, as Hamsters.js is meant to be a higher level abstraction to provide universal parallel computing support, pre-defined methods are required to preserve the use of the thread pool, however this presented some limitations in some of the workloads you can complete with Hamsters.js, one of these challenges was the 1 billion row challenge where you must parse a billion rows of sensor measurements from a txt file as fast as possible.

When attempting this in the past using Hamsters.js, there was a problem where since this is a txt file of objects I didn't have an efficient way to ensure that the workers themselves got the data from the file requiring parsing of the data on the main thread and then sending that data through a postMessage to each worker, this was a huge bottleneck resulting in a completion time using 8 threads on an 8th Gen Core i5 processor of 16 minutes and 32 seconds, surely there is a better way right?

Introducing custom scaffold support, you can now initialize Hamsters.js to use a custom scaffold that includes all the libraries you need accessable inside your threads! You will need to define a relative path, absolute path, or url to the worker file you want to use like below.

javascript hamsters.init({ scaffold: 'myCustomWorker.js' }): By making use of the scaffold param your threads will make use of your worker file, you can make use of the existing scaffolds the library uses as boilerplate under the src/scaffold folder and the src/common folder as well. Just remember not to remove too many of the libraries methods or you'll lose the benefits of having Hamsters.js in the first place.

Back to that billion row challenge, by using a custom scaffold and moving the file reading into the threads themselves, we can reap the benefits of Hamsters.js parallel computing and features like memoization if we desire. So the results speak for themselves, moving to version 5.6.1 and making the above changes resulted in a processing time of a mere 261.431 seconds! This beats multi-threaded python and concurrent ruby using jRuby which allows for actual parallel processing with ruby. Ruby took 695.027056 seconds, while Python took 446.83 seconds on the same machine.

Making the Hamsters.js approach 165.85% faster than Ruby, and 70.93% faster than python, overall a 279.39% improvement in performance compared to previous releases of Hamsters.js running the same challenge, if you would like to run the challenge yourself or view the source code to see how the custom scaffold was used you can view the repo here.

1-billion-row-challenge

Trainer

Similar to the above in previous versions of Hamsters.js there was no way to customize the response handler for when a thread returns a response, this is now possible by passing a trainer parameter at initialization. This enables you to create custom message handlers and implement things like progress bars and status updates into your workflow, ideal for longer running tasks.

``javascript const hamsterTrainer = (index, task, threadId, hamster, resolve, reject) => { const onThreadResponse = (message) => { if(message.data.type === "log") { //Custom log message type from our worker thread console.log(We have a log from thread id#${threadId}: ${message.data.message}`); } else { // Process with Hamsters.js like normal this.hamsters.pool.processReturn(index, message, task); if (this.hamsters.habitat.debug) { task.scheduler.metrics.threads[threadId].completed_at = Date.now(); } this.hamsters.pool.removeFromRunning(task, threadId); if (task.scheduler.workers.length === 0 && task.scheduler.count === task.scheduler.threads) { this.hamsters.pool.returnOutputAndRemoveTask(task, resolve); } if (!this.hamsters.habitat.persistence) { hamster.terminate(); } if (this.hamsters.pool.pending.length() !== 0) { const queueHamster = this.hamsters.pool.fetchHamster(this.hamsters.pool.running.length()); this.hamsters.pool.processQueuedItem(queueHamster, this.hamsters.pool.pending.shift()); } } }; this.hamsters.pool.setOnMessage(hamster, onThreadResponse, reject); }

hamsters.init({
   trainer: hamsterTrainer
});

```

# Async

You can now make use of async await inside of your Hamsters.js functions and everything should work seamlessly as if you were using async await on the main thread. Hamsters.js will automatically detect which functions are async and make the appropriate adjustments behind the scenes.

javascript hamsters.run(params, async function() { await longRunningPromise; }, function(results) { //Do something with results });

# Notes

This release of Hamsters.js opens up many more possibilities than in the past, I hope they are made use of and they improve your overall experience using the library, thank you for using the library and helping to make the web a more modern experience. If you enjoy Hamsters.js and want to continue to see updates like this please DONATE today.

- JavaScript
Published by austinksmith over 1 year ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.6.0 Released!

I'm happy to announce the release of Hamsters.js version 5.6.0, this release brings a few changes to the overall project structure and upgrades many of the development dependencies the library relies on such as babel and webpack, these have been upgraded to the latest version and the library is now being minified properly when built resulting in a significantly smaller binary file size , now down to less than 30KB.

Release Notes

  • Updated dev dependencies, patching all known security vulnerabilities.
  • Restructured scaffold files for maintainability and proper support for new babel version
  • Switched test cases from using PhantomJS (now deprecated), and Firefox, to using ChromeHeadless

Warnings

  • Explicit support for ES5 is no longer provided, moving forward Hamsters.js will make use of ES6+ features for performance reasons, babel is now configured to target ES6 environments.

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.5.9 Released!

This release brings a bug fix, and lays the ground work for new distributed computing features. These features do require the use of a node.js server application that will require some sort of license to use in the future. The details are still being ironed out however you can still use the new version of Hamsters.js with the client side support for these features already baked in (subject to change in future versions). If you do not have the node.js server application setup and running and you do not pass the server relay url as a start option to the library then the distributed and networking related features are disabled and unusable.

This release also should improve performance slightly especially for Node.js.

Bug Fixes

  • Resolved potential race condition when making use of multiple threads being called using javascript hamsters.promise

Improvements

  • Node.js is now making use of the new transferable logic introduced in v5.5.8
  • The transferable logic for both Node.js and Web have been updated to improve performance

Features

  • Distributed Computing! - This new feature will allow the distribution of tasks between clients, currently this is limited to using 1 thread at a time so a client can execute a function and have the work be completed on a different clients machine and the results be processed seamlessly as though the work was done on the original clients machine. Future releases will expand on this, alongside the release of the required server side application for this feature to work, the eventual goal is super computing, with a single client having access to the full computing power of every client connected to the same application.

hamstersjs_wallpaper

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.5.8 Released!

I'm happy to announce the release of version 5.5.8 of Hamsters.js, this release changes how transferable objects are handled and will now make use of transferable objects in all scenarios where a transferable data type is being sent. Previously only typed arrays were being sent using transferable objects now it can be any of the following.

javascript const typedArrayTypes = [ 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array' ]; const otherTransferables = [ 'ArrayBuffer', 'MessagePort', 'ImageBitmap', 'OffscreenCanvas' ];

Future releases will expand on this to allow you to handle these as responses better.

Enjoy!

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.7 Released!

This release is a hotfix release and patches support for using SharedArray buffers and not also passing array in your params object.

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.6 Released!

We're happy to release version 5.5.6 of Hamsters.js, this release fixes a bug when mixedOutput: true is passed in the params object and also cleans up the library architecture a little by moving hamsters.js tasks into their own class for creation. As well as some improvements to the memoization store, now its a LRU cache with a maximum of 100 entries in the database preventing memory usage from growing infinitely.

See the list below.

Bug Fixes

  1. Fixed issues where final outputs would be erroneous when mixedOutput: true passed in params

Improvements

  1. Moved hamstersjs task creation from being a simple in memory object to being a full fledged class
  2. Memoization store is now a Least Recently Used Cache, with a max of 100 database entries

Hamsters.js Memoization

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.5 Released!

We're happy to release version 5.5.5 of Hamsters.js, this release builds fixes several issues and brings back a new feature that was part of Hamsters.js early days.

See the list below.

Bug Fixes

  1. Pool is undefined error when tasks get queued for processing
  2. In situations where the thread pool is maxed out, a new thread will not spawn
  3. Library not starting in Node.js in some instances

Features

  1. Memoization, cache the results of your Hamsters.js functions. You can read more about how to use the new memoize feature here

Hamsters.js now supports memoization

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.4 Released!

We're happy to release version 5.5.3 of Hamsters.js, this release builds upon the newly introduced support for Atomic Operations in version 5.5.3 , this is an additional performance optimization that eliminates the overhead of passing the sharedArray to each thread.

In testing this resulted in a performance improvement of between 3.15% to 8.63% , depending on the number of threads being used.

Tested running the Atomic Operations Example with a million integers, comparing v5.5.3 to v5.5.4 using an Ubuntu 22.04 LTS 64-bit test machine with a Core i5-8300H 2.3ghz 4 cores 8 threads, 16GB DDR4 2400mhz dual channel.

Additionally the README and Hamsters.js Wiki have been updated with new information on making use of Atomics!

Hamsters.js supports  even faster Atomic Operations

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.3 Released!

We're happy to release version 5.5.3 of Hamsters.js, this release brings the very long coming support for Atomic Operations, allowing us to completely eliminate the majority of thread communication overhead improving performance significantly.

Hamsters.js supports Atomic Operations

We are in the process of updating the wiki documentation for this new feature, When running the new benchmark and comparing the results to our Collatz Conjecture example without SharedArrays, and our Atomic Operations Example which uses SharedArrays && Atomic Operations, we can see performance increases in the table below. The following results were taken on a Core i5 8300H 2.3ghz 4c/8t processor, 16GB of DDR4 2400mhz dual channel, running on Ubuntu 22.04 LTS

FireFox 126.0.1 (64-bit) -

| Number of Threads | Time Taken (Result Set 1 - No SharedArrays) | Time Taken (Result Set 2 - SharedArrays) | Time Difference (ms) | % Performance Increase | |-------------------|---------------------------------------------|------------------------------------------|----------------------|------------------------| | 1 | 9,908ms | 9,421.54ms | 486.46ms | 4.91% | | 2 | 5,962ms | 5,302.82ms | 659.18ms | 11.06% | | 3 | 4,637ms | 3,830.7ms | 806.3ms | 17.39% | | 4 | 4,302ms | 4,118.26ms | 183.74ms | 4.27% | | 5 | 3,489ms | 3,828.34ms | -339.34ms | -9.73% | | 6 | 3,514ms | 3,576.22ms | -62.22ms | -1.77% | | 7 | 3,367ms | 3,104.14ms | 262.86ms | 7.81% | | 8 | 3,302ms | 3,098.24ms | 203.76ms | 6.17% | | Average | 5,060.13ms | 4,660.16ms | 399.97ms | 8.24% |

Brave v1.66.118 -

| Number of Threads | Time Taken (Result Set 1 - No SharedArrays) | Time Taken (Result Set 2 - SharedArrays) | Time Difference (ms) | % Performance Increase | |-------------------|---------------------------------------------|------------------------------------------|----------------------|------------------------| | 1 | 66,725ms | 58,918ms | 7,807ms | 11.70% | | 2 | 37,278ms | 32,366ms | 4,912ms | 13.18% | | 3 | 27,766ms | 23,642ms | 4,124ms | 14.85% | | 4 | 23,445ms | 19,418ms | 4,027ms | 17.18% | | 5 | 22,886ms | 21,160ms | 1,726ms | 7.54% | | 6 | 22,344ms | 19,723ms | 2,621ms | 11.73% | | 7 | 24,496ms | 18,582ms | 5,914ms | 24.14% | | 8 | 22,486ms | 18,965ms | 3,521ms | 15.66% | | Average | 30,928.75ms | 26,471.63ms | 4,457.13ms | 14.50% |

Enjoy!

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.2 Released!

We're happy to release version 5.5.2 of Hamsters.js, this release is aimed at performance and provides some gains for tasks that use only a single thread with a percentage improvement is approximately 21.4% in benchmarks.

  1. Removed unnecessary if statement and return during runtime - improves performance in all scenarios
  2. Removed expensive indexe's calculation from function calls that use only 1 function, improves performance for single threaded tasks
  3. Refined task object creation for better performance and removing unnecessary checks

Enjoy!

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.1 Released!

We're happy to release version 5.5.1 of Hamsters.js, this is more of a hotpatch than a release, it just builds upon v5.5.0

  • This is a simple bug fix that restores the typedArrayFromBuffer method that was previously removed in version v5.4.3

Enjoy!

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.5.0 Released!

We're happy to announce the release of version 5.5.0 of Hamsters.js this release brings some improvements to the library performance and architecture and a new optional parameter for functions that have outputs of different sizes than their inputs. Here are the list of changes below!

  • Refactored library initialization to reduce library memory usage before initialization and improve performance
  • Completely eliminated passing of library variables between functions, improves performance
  • Added new optional parameter called mixedOutput: Boolean you can pass true or false to this. Its recommended not to use this unless you needed as it can reduce performance slightly.
  • Refactored library classes to match JavaScript class naming conventions

Enjoy!

- JavaScript
Published by austinksmith almost 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.4.4 Released!

This release resolves a few issues that will increase overall performance however it comes at a cost of higher memory usage

Resolved index calculation to support odd numbers of threads such as triple core processors Added more unit tests Resolved some unit tests not working in Firefox browser Added task.output for output data, previously the library was modifying the input array as the output, this was great from a memory usage standpoint however its bad practice to modify inputs so that's no longer happening. Cleaned up code some

Enjoy!

- JavaScript
Published by austinksmith over 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters v5.4.3 Released!

This release was primarily targeted around more unit testing and fixing the debugging metrics, additionally there is a slight performance increase and resolves a memory leak.

  • Resolved memory leak of pool.tasks array overflowing with random data
  • Resolved issues with debugging mode not returning accurate thread start and completion times
  • Modified indexes calculation to be 100% accurate with new unit tests
  • Removed pool.tasks array and function calls, slight performance increase.
  • When using debugging mode you can now see individual performance for each thread as well as performance of each task, start and end * times as well as enqueued and dequeued times if a task gets queued waiting for a thread.

This release also drops support for Internet Explorer 9, support for Internet Explorer 10 is no longer guaranteed to work and has not been tested.

Enjoy!

- JavaScript
Published by austinksmith over 2 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.4.1 Released!

This release is mainly a bug fix release and does not include any optimizations or other changes beyond fixing the below issues.

  • Resolved issues running with reactNative
  • Resolved issues with overriding maxThreads not working on startup
  • Removed additional splice data aggregation method not supported by reactNative

Enjoy!

- JavaScript
Published by austinksmith over 4 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.4.0 Released!

I'm happy to announce the release of Hamsters.js v5.4.0, this version is a major overhaul and completes the implementation of the JIT data management system. This is truly a game changing release as it dramatically reduces memory usage while also increasing per thread scaling and reducing library overhead and total package size.

This release also comes with a few notable changes

  • Memoization support has been temporarily removed
  • JIT data management is now fully implemented, reducing memory allocation to at most 1 copy of the original input data
  • Removed old unused logic to reduce code package size
  • You can now control which threads operate on which pieces of your input data by passing a new optional indexes argument

    js const params = { array: [1,2,3,4], threads: 2, indexes: [ {start: 0, end: 0}, //Thread one will operate on only the first element {start: 1, end: 3} //Thread two will operate on the remaining elements ] };

- JavaScript
Published by austinksmith over 4 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.3.9 Released!

Hamsters.js v5.3.9 is officially live!

## Latest Updates

  • Fixed problems running on Internet Explorer
  • Internet Explorer support now moved to legacy only mode
  • Added Just In Time data management to improve scaling
  • Dramatically reduced runtime complexity
  • Added support for indexes for use with JIT data management, major performance increase. Future versions of Hamsters.js will expand on this functionality for more fine tuned management of which threads operate on which pieces of data.

Enjoy!

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.3.7 Released!

Hamsters.js v5.3.7 is officially live!

## Latest Updates

  • Fixed problems with data aggregation when using multiple threads on React Native

Enjoy!

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.3.6 Released!

Hamsters.js v5.3.6 is officially live!

## Latest Updates

  • Fixed problems with React Native 0.62 and non legacy mode using react-native-hamsters

  • Simplified react native thread logic

Enjoy!

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.3.5 Released!

Hamsters.js v5.3.5 is officially live!

## Latest Updates

  • Fixed bug with detection of startOptions and legacy argument when initializing library
  • Fixed react-native-hamsters package name for use with react-native-hamsters

Enjoy!

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - Hamsters.js v5.3.3 Released!

Hamsters.js v5.3.3 is officially live!

## Latest Updates

  • Fixed all outstanding react native bugs
  • Fixed broken legacy mode in Node.js and ReactNative
  • Added official support for react-native-hamsters
  • Fixed start options legacy mode not being respected
  • Cleaned up logic

Enjoy!

Hamsters.js v5.3.3 is officially live

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - Version v5.3.2 Released!

Hamsters.js v5.3.2 is officially live! - THIS IS A HOTFIX PATCH RELEASE FOR V5.3.1

## V5.3.2 Hot Fix Patch Updates

  • Restores Internet Explorer 10 Support
  • Fixes incorrect detection of available threads

## V5.3.1 Updates

  • Fixed all outstanding Node.js bugs including legacy fallback mode and Node.js native worker implementation support
  • Simplified initializing library logic to reduce startup time and memory allocation
  • Simplified main library logic to improve performance while library is running and reduce memory allocation
  • Refactored old logic to be cleaner
  • Removed explicit fallback support for Kindle3 Devices and Internet Explorer 10 Mobile Devices
  • Fixed bug reducing performance of transferable objects, massive performance gains observed
  • Reorganized library structure to improve maintainability
  • Initialization method no longer removed from library at startup
  • Now exposing internal habitat keys variable
  • Moved common folder outside core folder
  • Renamed common/rnHamsterWheel.js to common/reactNative.js
  • Created common/node.js file
  • Renamed /common/hamstersWheel.js to /common/internetExplorer.js

Enjoy!

Hamsters.js v5.3.2 is officially live

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - Version v5.3.1 Released!

Hamsters.js v5.3.1 is officially live!

## Latest Updates

  • Fixed all outstanding Node.js bugs including legacy fallback mode and Node.js native worker implementation support
  • Simplified initializing library logic to reduce startup time and memory allocation
  • Simplified main library logic to improve performance while library is running and reduce memory allocation
  • Refactored old logic to be cleaner
  • Removed explicit fallback support for Kindle3 Devices and Internet Explorer 10 Mobile Devices
  • Fixed bug reducing performance of transferable objects, massive performance gains observed
  • Reorganized library structure to improve maintainability
  • Initialization method no longer removed from library at startup
  • Now exposing internal habitat keys variable
  • Moved common folder outside core folder
  • Renamed common/rnHamsterWheel.js to common/reactNative.js
  • Created common/node.js file
  • Renamed /common/hamstersWheel.js to /common/internetExplorer.js

Enjoy!

Hamsters.js v5.3.1 is officially live

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - v5.2.1 Released!

Hamsters.js v5.2.1 is officially live!

## Latest Updates

  • Fixed bug causing a console log to occur when creating threads and not using debug mode
  • Simplified initializing library logic to reduce startup time and memory allocation
  • Simplified main library logic to improve performance while library is running and reduce memory allocation
  • Refactored old logic to be cleaner
  • Fixed typo where transferrable should have been transferables
  • Applied security patches for development dependencies

Enjoy!

Hamster

- JavaScript
Published by austinksmith almost 5 years ago

https://github.com/austinksmith/Hamsters.js - v5.1.3 Released!

Hamsters.js v5.1.3 is officially live and includes some great fixes and optimizations

## Bug Fixes

  • Resolved issues with Node.js on Windows not returning an output
  • Resolved performance limitations with transferrable objects

Improvements

  • Improved performance transferring data between main thread and threads
  • Added support for Node.js native worker implementation
  • Reduced the number of parameters used for internal logic

Enjoy!

Hamster

- JavaScript
Published by austinksmith almost 6 years ago

https://github.com/austinksmith/Hamsters.js - v5.1.2 Released!

Hamsters.js v5.1.2 is officially live and includes some great fixes and optimizations

## Bug Fixes

  • Resolved issues with promises not working correctly
  • Resolved automatic environment detection inconsistencies
  • Resolved non-persistence mode not functioning correctly
  • Resolved some inconsistencies with thread pool and work queue system
  • Resolved a bug in the logger system when searching for saved log items
  • Resolved some bugs with legacy mode execution

Improvements

  • More extensive test cases and code coverage
  • Various changes throughout the logic including more strict/verbose variable checks
  • Cleaned up some redundant funtionality
  • Removed duplicated logic in various places
  • Reduced logic complexity & improved performance

Enjoy and have a happy holiday!

King Hamster

- JavaScript
Published by austinksmith over 7 years ago

https://github.com/austinksmith/Hamsters.js - Version 5.1.1 Released!

With great excitement comes the announcement of version 5.1.1 of the Hamsters.js library, this release includes several fixes and general improvements.

  • Improved support for ReactNative, specifically included with the library is now a external worker scaffold file that is specially optimized for react-native-threads. This third party worker implementation is the most up to date available on npm at this point in time. Unfortunately it was discovered that this implementation only supports using strings to communicate with threads, the library will now ensure if using react native that only strings are used for communication, this will not result in the best possible performance but should ensure compliance with the ever changing react native landscape.

When making use off the library within reactNative, you must now copy the src/core/common folder to the root of your project directory.

  • Environment overrides, the library attempts to support as many devices and environments as possible, unfortunately sometimes automatic environment detection can fail causing the library to attempt to use unsupported features in a given environment. In order to prevent this from happening you can now override automatic environment detection and ensure the library operates in the mode designed for your environment.

js hamsters.init({ 'legacy', true/false 'reactnative' : true/false, 'browser': true/false, 'shell': true/false 'node': true/false }); * Import scripts, you can now instruct the library to import other libraries during execution by using the importScripts parameter, this synchronously loads the library into the workers execution context. You can read more about importScripts here. When making use of this feature you must pass a comma separated string to the library using a path relative to the workers execution context.

js var params = { importScripts: "foo.js" } hamsters.run(params.....

Lastly, some changes have been made to the build process to ensure the final library output is minified and optimized using the optimizeOrder plugin, if you have any new issues please report them as soon as possible, thanks!

Hamsters.js Javascript MultithreadingHamsters.js Javascript MultithreadingHamsters.js Javascript Multithreading

- JavaScript
Published by austinksmith about 8 years ago

https://github.com/austinksmith/Hamsters.js - Version 5.0.0 Released!

v5.0.0

With great excitement comes version 5.0.0 of Hamsters.js, this version was a complete rewrite from the ground up with an emphasis on maintainability and bringing the library up to modern development standards. Now it's easier than ever to multithread your javascript!

Highlights

  • Completely rewritten from the ground up using ES6 classes
  • Adopted webpack
  • Abandoned bower support
  • Node.js now automatically detects available cores
  • Running npm run test actually works now
  • Resolved reactNative support
  • New searchable logging system (hamsters.logger)
  • Support for promise based execution

The main goals of this release was to get the library back to it's basics, Hamsters.js has always aimed to be a high/low level abstraction for parallel and threaded workloads. To that aim we no longer provide any out of the box abstractions or tools that are not required for library functionality, you will find that in hamsters 5.0.0 calling hamsters.tools will now be undefined.

A word with the open source community

Please consider supporting this project via our open collective, Hamsters.js has operated for the 3 years purely on out of pocket funding and the project does not want to abandon its open source aims in order to keep the lights on.

During the libraries time as an open source project we have needed to defend the project from copyright infringement and theft, my goals as the creator of this project was to give back to the JavaScript community and hopefully push the industry into making multithreading a more mainstream web application feature...after all whats the point of all these cores if we can't use them haha.

Almost immediately after publishing the library under the Artistic 2.0 license the library was cloned and all mentions of the source of the cloned project were removed giving the appearance that said user created an original from scratch project. This has happened on several occasions to varying degree over the past 3 years leaving me with a rather bad impression of the open source community as a whole, and again recently I was forced to spend over $1000 to stop a bad actor from blatantly infringing on the projects website and trade dress.

In the interest of full transparency a DMCA take down notice was issued through github to the offending repository and the host of the infringing website was contacted as well using a DMCA take down notice. This user persisted in the copyright infringement and moved web host a total of 7 different times using several methods to attempt to hide the host being used.

Ultimately after hiring a lawyer and contacting the user directly and sending a draft copy of a notice to file suit the offending party stopped the bad practices (for the time being), with these experiences it has proven to be costly both financially and mentally to continue to offer open source projects and support them. We need community support not only to continue to provide updates and support new hardware and features but also defend against these scenarios. - https://opencollective.com/hamstersjs/

Spectre & Meltdown

Part of the reason version 5 has been delayed is due to the discovery of the Meltdown and Spectre bugs, I had been working lately to change how the library operates so it can seamlessly support atomic operations behind the scenes. This would allow the library to dramatically reduce run time overhead and allow multiple threads to access a single shared array unfortunately right around the time I had hoped to release the new version it was announced these vulnerabilities existed in Intel X86 processors.

As a mitigation attempt all major browsers have since removed support for the most critical aspect of this functionality and that is the SharedArrayBuffer, this has had a major detrimental impact on the projects goals as I have waited a very long time for SharedArrayBuffer's to become mainstream only to have them removed due to security problems introduced by Intel.

Should SharedArrayBuffer support be brought back to browsers (unlikely at this point), then I will release a new version including them which will result in a major performance bump for the library.

Final Words

This release marks 3 years Hamsters.js has been in development, this project started out as me simply wanting to learn more about parallelism and multithreading since I had rarely made use of it in my software development career. I want to thank everyone who has supported the project and has given their recommendations on how to improve the library, the lessons I learned through the development of this project have been monumental and they won't soon be forgotten.

Be sure to checkout the updated https://www.hamsters.io/wiki for more information on how to get started with v5.0.0

ENJOY

- JavaScript
Published by austinksmith over 8 years ago

https://github.com/austinksmith/Hamsters.js - v4.2.1 Released

This release aims to resolve issues in extremely heavy workloads that can in rare situations cause out of memory errors in certain browsers before the garbage collector has been invoked.

The screen shot below is an allocation timeline using v4.2.0 note the retained size of the typed Int32Array where roughly 81% of the original array backing store was retained.

version 4-2-0

Since v4.2.1 now explicitly marks the params and rtn objects within a thread as undefined and ready for garbage collection we can see the results using the same test do not retain any of this data after execution.

version 4-2-1

Please report any performance degradation you encounter in comparison to v4.2.0 as this may cause the garbage collector to run more frequently than before though it should eliminate these out of memory errors moving forward.

- JavaScript
Published by austinksmith over 8 years ago

https://github.com/austinksmith/Hamsters.js - v4.2.0 Released!

This release is targeted at decoupling the library logic into more easily logically separated pieces, future releases will expand on this more down the road with plans to offer more out of the box abstractions for tasks that can benefit from parallelism.

This release also includes many other general code improvements that should result in better performance and reduce the overall complexity of the library.

As this change also includes changes to the internal naming conventions of the library this release skips ahead from 4.1.4 all the way to 4.2.0 as it is a somewhat significant change, all logic written for previous releases should still be backwards compatible, please submit a bug ticket if you encounter any new issues.

- JavaScript
Published by austinksmith almost 9 years ago

https://github.com/austinksmith/Hamsters.js - v4.1.4 Released!

This release is another bug fix release that aims to resolve issues related to ReactNative support.

Resolved Issues

React Native Worker is undefined https://github.com/austinksmith/Hamsters.js/issues/35

Beta Features

This release also extends beta support for third party worker implementations on ReactNative, submit a ticket if you encounter an issue with a specific worker implementation.

- JavaScript
Published by austinksmith almost 9 years ago

https://github.com/austinksmith/Hamsters.js - v4.1.3 Released

v4.1.3

This release is another bug fix release that aims to resolve outstanding issues related to Node.js third party WebWorker implementations.

Resolved Issues Worker is undefined under Node.js https://github.com/austinksmith/Hamsters.js/issues/27

- JavaScript
Published by austinksmith almost 9 years ago

https://github.com/austinksmith/Hamsters.js - v4.1.2 Bug Fix Release

This release is mostly a stop gap release to resolve outstanding bugs that were reported, this will likely be the last version that is hand written and optimized specifically for each platform as the library complexity is getting a little out of hand. Future releases assuming they are performant will be written with the latest features in mind and transpiled to provide legacy support.

Resolved Issues

Microsoft Edge navigator.hardwareConcurrency is undefined error. Node Worker is undefined error.

Beta Features

When using the library within Node.js you can now pass an optional Worker parameter referencing which third party worker implementation you would like to use. This feature is in beta and may or may not work depending on the implementation you choose to use. Please submit a issue report if you encounter problems with a specific implementation.

```js var hamsters = require('hamsters.js'); var webWorker = require('....').Worker;

hamsters.init({ maxThreads: 3, persistence: false, Worker: webWorker }); ```

- JavaScript
Published by austinksmith about 9 years ago

https://github.com/austinksmith/Hamsters.js - v4.1.1 Released

This release resolves all remaining legacy fall back support bugs including issues with Node.js attempting to invoke workers that don't exist.

RESOLVED ISSUES Erroneous results when using legacy processing mode and invoking multiple threads - https://github.com/austinksmith/Hamsters.js/issues/27 Node.js Worker is not defined on initialization - https://github.com/austinksmith/Hamsters.js/issues/28 Hamsters.tools.loop functionality not taking into account legacy mode

Special thanks to @Zodiase for discovering the problems.

- JavaScript
Published by austinksmith about 9 years ago

https://github.com/austinksmith/Hamsters.js - v4.1.0 Released

This release is a somewhat large change which deviates from how the library was used in the past, library will no longer automatically initialize when your application loads. This decision was made in order to allow for more fine tuned control over the library operation and you can now pass an optional startOptions configuration object to control library behavior on initialization.

js var startOptions = { maxThreads: integer, cache: boolean, debug: booealn, persistence: boolean }; hamsters.init(startOptions);

At the moment only the above configuration options are available for your control, in later releases more options will be exposed.

Another notable change is when making use of the optional dataType argument the library will no longer automatically convert your input array into a TypedArray, you as the developer must ensure you are already passing the library the proper array type. The library will still ensure your final output matches the same dataType as you supplied in your arguments.

Finally this release includes many performance improvements and resolves some edge case problems related to the hamsters.tools.loop functionality.

ENJOY

Happy Hamster

- JavaScript
Published by austinksmith about 9 years ago

https://github.com/austinksmith/Hamsters.js - v4.0.0

Resolved Issues This change removes all remaining special cases for Node.js support, previously the library was having node look for the file under src/common/wheel.min.js which was typically reserved only for when using Internet Explorer 10. This is no longer the case and will require a proper working third party web worker implementation in order for Node.js to function outside of the legacy fallback mode.

- JavaScript
Published by austinksmith over 9 years ago

https://github.com/austinksmith/Hamsters.js - v3.9.9

Resolved Issues Node.js legacy fallback mode not working Library will leave less crud in memory after initial setup

- JavaScript
Published by austinksmith over 9 years ago

https://github.com/austinksmith/Hamsters.js - v3.9.8

Improvements - Node error using global variable self issue is now resolved - Memoization support is working again and moved to an in memory cache - Removed some old unused logic and optimized existing logic

Notes The memoization method has been moved from sessionStorage to being an in memory cache, this means the only limit to the number of cached results is how much memory is available on the client so please ensure you're only caching the results you really need to cache.

- JavaScript
Published by austinksmith over 9 years ago

https://github.com/austinksmith/Hamsters.js - v3.9.7

Very minor update, this release fixes issues with bower package settings

- JavaScript
Published by austinksmith over 9 years ago

https://github.com/austinksmith/Hamsters.js - v3.9.6

_V3.9.6 Release Notes_

This release consolidates the src/react-native version back into the normal es5/es6 library versions and the library should now officially work under Node.js.

RESOLVED ISSUES Path naming issues with IE10 support when making use of web workers NPM issues with module.exports, library should now officially work within Node.js

KNOWN ISSUES Memoization support is broken and not 100% functional, avoid using cache: true

- JavaScript
Published by austinksmith over 9 years ago

https://github.com/austinksmith/Hamsters.js - v3.9 HOTFIX Release

_V3.9.1 HOTFIX Release Notes_

RESOLVED Non transferrable object functionality has been restored thanks @wolfiex for discovering the issue Resolves processDataType returning the dataType instead of the data itself in the event it doesn't match with known TypedArrays

KNOWN ISSUES Memoization support is broken and not 100% functional, avoid using cache: true

- JavaScript
Published by austinksmith over 9 years ago

https://github.com/austinksmith/Hamsters.js - V3.9

_V3.9 Release Notes_

BETA SUPPORT React-native support ES6 support

RESOLVED Transferrable object issues Performance issues related to try catch logic

KNOWN ISSUES Memoization support is broken and not 100% functional, avoid using cache: true

- JavaScript
Published by austinksmith over 9 years ago

https://github.com/austinksmith/Hamsters.js - v3.8

Eliminates use of eval/new function for legacy devices Replaces eval call with new function call for loop tool abstraction Resolves legacy issues with loop tool abstraction Adds typed array support for legacy and worker environments where applicable (improves output consistency)

- JavaScript
Published by austinksmith over 10 years ago

https://github.com/austinksmith/Hamsters.js - v3.6

  1. Removes external file dependency for SharedWorker support inside Workers
  2. Adds fallback support inside workers for browsers that don't support SharedWorkers
  3. Library cleanup

- JavaScript
Published by austinksmith over 10 years ago

https://github.com/austinksmith/Hamsters.js - v3.5

Adds Node.js support

Implements true threading for Internet Explorer 10 when making use of the common files, falls back to using legacy processing when unable to connect to common/node/wheel.min.js file

Worker environment support (does not support transferrable objects)

- JavaScript
Published by austinksmith over 10 years ago

https://github.com/austinksmith/Hamsters.js - v3.4

Resolves issues with debugging and concurrency Introduces unit tests Improved debugging for legacy devices

- JavaScript
Published by austinksmith over 10 years ago

https://github.com/austinksmith/Hamsters.js - v3.3

Introduces persistence mode for real time applications such as online games Dramatically reduced garbage collection for consistent performance Any typed array passed into a functions params object will make use of transferrable objects now, not just 'array' Improved multicore performance scaling Dramatically reduced latency when using optional dataType argument

- JavaScript
Published by austinksmith almost 11 years ago

https://github.com/austinksmith/Hamsters.js - v3.2

Removes all remaining reliance on global window object, should now function outside of browsers No longer appends setup functions to self object Slight optimizations

- JavaScript
Published by austinksmith almost 11 years ago

https://github.com/austinksmith/Hamsters.js - v3.1

Increase maxThread fallback count from 2 to 4 Finalized performance improvements Library polish (jslint) Reduced library complexity and overhead

- JavaScript
Published by austinksmith almost 11 years ago

https://github.com/austinksmith/Hamsters.js - v3.0-Hotfix

Resolves critical security error in IE11

- JavaScript
Published by austinksmith almost 11 years ago

https://github.com/austinksmith/Hamsters.js - v3.0

Eliminates all dom interaction from the library Further reduces library runtime overhead & complexity Major performance improvements when using typed arrays Massively reduced thread creation performance cost Removed scar tissue Fixed minified version runtime issues (YUI compressor instead of UglifyJS)

- JavaScript
Published by austinksmith almost 11 years ago

https://github.com/austinksmith/Hamsters.js - v2.9

Resolves remaining blob creation memory issues in IE11 Improved memory management, single blob creation per session Reduced dom overhead and interaction, single dom element & interaction per session Improved thread creation performance & library startup Reduced library variable size and complexity Removed browser specific tweaks, rely on browser manufacturers to optimize structured cloning algorithms Improved general performance

- JavaScript
Published by austinksmith almost 11 years ago

https://github.com/austinksmith/Hamsters.js - v2.8

Adds legacy fallback mode for preliminary use within asm.js and node, these run on the main thread.

Slight optimization doesn't append dom objects to browsers/devices that will not be using them.

- JavaScript
Published by austinksmith almost 11 years ago

https://github.com/austinksmith/Hamsters.js - v2.7

  • Identified and resolved a bug that would occur when running a function not making use of the newer dataType arguments
  • Introduced automagical sorting options
  • Cleaned up runtime logic
  • Updated jsdoc guides

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - v2.6

Removes the remaining bottlenecks in the logic, performance enhancements.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - v2.5

Resolves remaining legacy device support issues introduced by typedArray support, resolves possible performance degradation in Safari.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - v2.4

Performance enhancements focused around a lower latency runtime, microoptimizations including smarter & faster memoization.

Average of 4ms latency reduction across the board.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - v2.3

Improved memoization, roughly double effective cache size by hashing the input, decoupling of logic, performance improvements.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 2.2

This release resolves issues for IE11 introduced by v2.1, also includes an optional result caching system.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 2.1

Version 2.1 introduces improved aggregation performance when using the optional dataType param, up to 50% aggregation boost depending on the browser used.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 2.0-Hotfix

This hotfix release corrects errors demonstrated in the minified release included with version 2.0.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 2.0

Version 2.0 introduces support for typedArrays and a configurable dataType param, using these typedArrays can result in a massive performance boost, up to 10x in testing over previous releases. Later versions will expand on this for more performance depending on the task at hand.

Minified version now included as well.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.9-Hotfix

Same release notes as 1.9, includes proper hamsters file.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.9

Performance improvements for chrome & firefox, up to 50% improvement depending on workload. Intelligently manage data passing based on workload size, future versions will expand on this to be more performant.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.8

Adjust max thread count calculation for best performance, fixed potential bug when thread pool active and there are many pending thread items.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.7

Improved memory management, reduced library overhead, adjusted maxThread calc for best performance, legacy fallback simulated threads now match HTML5 minimal setTimeOut specification of 4ms.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.6

Added support for Ipad 2 & Ipad 1 & IE Mobile devices. Added simulated threading for older devices, should give the appearance of responsiveness even when computations fallback to the main thread legacy processor.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.5

Graceful fallback support added for Internet Explorer Mobile & Monochrome Kindle 3 tablet, these devices do not properly support web workers.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.4

Legacy processor fallback, graceful performance degradation depending on browser web worker support.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.3-Hotfix

Resolved typo causing issues with IE

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.3

Resolves critical data missing bug which may occur in instances where a function invokes a single thread following a successful run of another hamsters function.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.2

Identified and resolved critical bug that could cause in some cases unexpected output results when the thread pool was active. This is a mission critical update and it is highly suggested to use v1.2 over previous releases.

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js - 1.1

Gracefull fallback for IE10 & IE11, removal of code scare tissue, slight micro-optimizations, improved error handling

- JavaScript
Published by austinksmith about 11 years ago

https://github.com/austinksmith/Hamsters.js -

Initial release version

- JavaScript
Published by austinksmith about 11 years ago