I'm working with Prevayler, doing some very simple stress testing.
On my program, I can get 10,000 reads in 500ms, but writing or changing one object takes 23ms. (I don't have detailed specs on this computer. Nothing impressive. Dual core 3.0ghz, 7200rpm HD, and likely 1333mhz ddr3 memory.)
Serialization seems to be the bottleneck.
What can be done to increase write/change performance?
JProfiler I ran the program in JProfiler (10,000 User Objects being written to disk.), it ran for 250 seconds, of that time 99.6% was used in running org.implementation.PrevaylerImpl.execute
UPDATE I switched over to XStreamSerializer, which increased write speed to 21ms per write, and decreased storage from
3555KB journal/10,000 Objects -> 2421KB
350KB snapshot/10,000 Objects -> 313KB
I would like to see 1000+ writes/second.
---- Main Method ----
Transactor trans = new Transactor();
for(int i =0;i<10000;i++)
{
trans.createUser("Username", "PasswordHash");
}
---- Transactor Class ----
public void createUser(String Username, String PasswordHash) {
String id = Helper.randomID();
//Avoids id duplicates, id is 7 digit base58. (Like Bitcoin, but shorter.)
//ID generation takes .0078ms.
while(getUser(id)!=null)
{
id=Helper.randomID();
}
prevayler.execute(new CreateUser(Username, PasswordHash,id));
}
---- CreateUser Class ----
public class CreateUser implements Transaction, Serializable{
String Username;
String PasswordHash;
String id;
public CreateUser(String Username, String PasswordHash, String id)
{
this.Username = Username;
this.PasswordHash = PasswordHash;
this.id = id;
}
public void executeOn(Object core,Date date) {
((Core)core).store(new User(Username, PasswordHash), id);
}
}
---- Core Class (Store method) ----
private final Map<String,Object> dataMap = new HashMap<String,Object>();
public void store(Object object, String id) {
dataMap.put(id, object);
//Adds User id to a seperate ArrayList<String>
if(object instanceof User )
{
userList.add(id);
}
}