Commit dcfba665 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Lower initial dict/set size from 64->8

By switching to our DenseMap/Set fork with that allows parameterizing
on this.

This is the same number that CPython uses.  We were previously
using llvm's default of 64, which is pretty high -- probably fine
for their use cases, but in Python programs with lots of sets/dicts
we spend a lot of time doing malloc() for all those 1kB+ allocations.
This also increases the time it takes to iterate over the dict/set,
since there are more empty buckets that have to be read + skipped.
parent b7ad9512
......@@ -15,8 +15,7 @@
#ifndef PYSTON_RUNTIME_SET_H
#define PYSTON_RUNTIME_SET_H
#include "llvm/ADT/DenseSet.h"
#include "core/from_llvm/DenseSet.h"
#include "core/types.h"
#include "runtime/types.h"
......@@ -29,7 +28,7 @@ extern "C" Box* createSet();
class BoxedSet : public Box {
public:
typedef llvm::DenseSet<BoxAndHash, BoxAndHash::Comparisons> Set;
typedef pyston::DenseSet<BoxAndHash, BoxAndHash::Comparisons, /* MinSize= */ 8> Set;
Set s;
Box** weakreflist; /* List of weak references */
......
......@@ -24,6 +24,7 @@
#include "codegen/irgen/future.h"
#include "core/contiguous_map.h"
#include "core/from_llvm/DenseMap.h"
#include "core/threading.h"
#include "core/types.h"
#include "gc/gc_alloc.h"
......@@ -707,7 +708,8 @@ struct BoxAndHash {
class BoxedDict : public Box {
public:
typedef llvm::DenseMap<BoxAndHash, Box*, BoxAndHash::Comparisons> DictMap;
typedef pyston::DenseMap<BoxAndHash, Box*, BoxAndHash::Comparisons, detail::DenseMapPair<BoxAndHash, Box*>,
/* MinSize= */ 8> DictMap;
DictMap d;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment