LRUMap implements the parts of an ordered map that we need to
efficiently implement DynamicCharAtlas. It's more code, but there's a
few advantages of this approach:
- Map isn't available on some older browsers, so this removes the need
for a polyfill.
- Moving an item to the end of the map's iteration order now only
requires unlinking and linking a linked-list node, whereas before we
had to delete and re-insert our value.
- Peeking at the oldest entry in the map no longer requires allocating
and destroying an iterator.
- We can preallocate the linked-list nodes we want to improve cache
locality. Similarly, we can recycle linked-list nodes to reduce
allocations and the GC pauses those allocations may cause.
- LRUMap seems to give slightly better results in Chrome's profiler than
Map did. We now spend about 5% of our time on map operations instead
of about 10%.
- In my (limited) testing, it doesn't look like LRUMap is slowing down
over time. Map appeared to get slightly slower the longer I ran the
terminal for, either due to memory fragmentation or some sort of leak.
I still need to write some tests for LRUMap, but I've been using this
implementation for the last hour without problems.
This adds a very minimal implementation of DynamicCharAtlas using a LRU
cache.
I've got some optimizations that I'll add on top of this, but this
proves the concept.
The API defined by BaseCharAtlas will let us support multiple char atlas
implementations at once.
I tested this by running the demo with Chrome's profiler, which shows
that calls are going to StaticCharAtlas/drawImage instead of
_drawUncachedChar. Applications using 256 colors also still work fine,
via _drawUncachedChar.
Two parts were commented out:
- _writeStopped: This is because _xoffSentToCatchUp references this variable
and the feature is sort of half implemented/disabled.
- _clearChar: This is because some comments still reference this, it's part
of the work needed to do better line redrawing.
'include' field in the tsconfig.json defines source scope (top level of this scope is "src" folder), so we do not need 'exclude' folders in the root of the project, because this folders had already excluded by 'include' scope.
Signed-off-by: Aleksandr Andrienko <aandrienko@codenvy.com>
- Add Gulp and new dependencies to `package.json`
- Add `gulpfile.js` with four tasks:
- `tsc`: For building TypeScript sources
- `bundle`: For bundling JavaScript modules in a monolith
- `sorcery`: For resolving the source map chains back to the original TypeScript files
- `build` (`default`): Runs the whole `tsc` → `bundle` → `sorcery` chain
- Clean up `Dockerfile`, since `cpio` is not needed any more
- Clean up not needed dependencies from `package.json`
- Remove `bin/build`
- Update `bin/release` to use `npm run build` instead of `./bin/build`
This change is largely just moving files with minor tweaks to them to fix,
the rest of the commit is build process changes:
- The addons/ and test/ dirs have been moved to src/
- The build directory has been removed
- TypeScript builds are output in out/, this is where tests are run
- The demo now relies on the dist/ build which is performed as part of ./bin/build
- Addons are now shipped under the ./build directory