Skip to content

Unrealistic / flawed cache benchmarking #83

@mfbx9da4

Description

@mfbx9da4

The cache benchmarking has a few issues:

  1. It only benchmarks small integers as keys of the underlying cache. This is my primary issue with the benchmarking. In my experience, I use memoization to avoid processing large in memory data structures. If the memoization function stringifies the incoming argument everytime, the stringification cost is highly likely to outweigh the performance benefits of memoization. Map is ideal for caching based on an object argument because v8 and other engines assign a random ID to every object under the hood and checking if it is the same object is as simple as comparing two ints. The cache benchmarking code should test massive objects as arguments to the memoization function.
  2. It does not model key deletion. Map is specifically designed with key deletion in mind whereas hidden classes on objects are not so well suited to this. Keys are likely to be added and deleted a lot in a memoized function so it's important to model this.
  3. It does not model the potential non-local performance impacts of using objects. In v8 the "megamorphic" cache system can become overloaded by the number of hidden classes and deoptimize code. I'm no v8 expert but I know enough to beware of microbenchmarking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions